diff --git a/examples/ex_2ch/oas_handlers_gen.go b/examples/ex_2ch/oas_handlers_gen.go index 42bf14107..427dab624 100644 --- a/examples/ex_2ch/oas_handlers_gen.go +++ b/examples/ex_2ch/oas_handlers_gen.go @@ -19,12 +19,24 @@ import ( "github.com/ogen-go/ogen/ogenerrors" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAPICaptcha2chcaptchaIDGetRequest handles GET /api/captcha/2chcaptcha/id operation. // // Получение ид для использования 2chcaptcha. // // GET /api/captcha/2chcaptcha/id func (s *Server) handleAPICaptcha2chcaptchaIDGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/2chcaptcha/id"), @@ -45,7 +57,16 @@ func (s *Server) handleAPICaptcha2chcaptchaIDGetRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleAPICaptcha2chcaptchaIDGetRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -140,6 +180,8 @@ func (s *Server) handleAPICaptcha2chcaptchaIDGetRequest(args [0]string, argsEsca // // GET /api/captcha/2chcaptcha/show func (s *Server) handleAPICaptcha2chcaptchaShowGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/2chcaptcha/show"), @@ -160,7 +202,16 @@ func (s *Server) handleAPICaptcha2chcaptchaShowGetRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -172,8 +223,27 @@ func (s *Server) handleAPICaptcha2chcaptchaShowGetRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -255,6 +325,8 @@ func (s *Server) handleAPICaptcha2chcaptchaShowGetRequest(args [0]string, argsEs // // GET /api/captcha/app/id/{public_key} func (s *Server) handleAPICaptchaAppIDPublicKeyGetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/app/id/{public_key}"), @@ -275,7 +347,16 @@ func (s *Server) handleAPICaptchaAppIDPublicKeyGetRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -287,8 +368,27 @@ func (s *Server) handleAPICaptchaAppIDPublicKeyGetRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -374,6 +474,8 @@ func (s *Server) handleAPICaptchaAppIDPublicKeyGetRequest(args [1]string, argsEs // // GET /api/captcha/invisible_recaptcha/id func (s *Server) handleAPICaptchaInvisibleRecaptchaIDGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/invisible_recaptcha/id"), @@ -394,7 +496,16 @@ func (s *Server) handleAPICaptchaInvisibleRecaptchaIDGetRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -406,8 +517,27 @@ func (s *Server) handleAPICaptchaInvisibleRecaptchaIDGetRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -489,6 +619,8 @@ func (s *Server) handleAPICaptchaInvisibleRecaptchaIDGetRequest(args [0]string, // // GET /api/captcha/invisible_recaptcha/mobile func (s *Server) handleAPICaptchaInvisibleRecaptchaMobileGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/invisible_recaptcha/mobile"), @@ -509,7 +641,16 @@ func (s *Server) handleAPICaptchaInvisibleRecaptchaMobileGetRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -521,8 +662,27 @@ func (s *Server) handleAPICaptchaInvisibleRecaptchaMobileGetRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -581,6 +741,8 @@ func (s *Server) handleAPICaptchaInvisibleRecaptchaMobileGetRequest(args [0]stri // // GET /api/captcha/recaptcha/id func (s *Server) handleAPICaptchaRecaptchaIDGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/recaptcha/id"), @@ -601,7 +763,16 @@ func (s *Server) handleAPICaptchaRecaptchaIDGetRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -613,8 +784,27 @@ func (s *Server) handleAPICaptchaRecaptchaIDGetRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -696,6 +886,8 @@ func (s *Server) handleAPICaptchaRecaptchaIDGetRequest(args [0]string, argsEscap // // GET /api/captcha/recaptcha/mobile func (s *Server) handleAPICaptchaRecaptchaMobileGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/captcha/recaptcha/mobile"), @@ -716,7 +908,16 @@ func (s *Server) handleAPICaptchaRecaptchaMobileGetRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -728,8 +929,27 @@ func (s *Server) handleAPICaptchaRecaptchaMobileGetRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -788,6 +1008,8 @@ func (s *Server) handleAPICaptchaRecaptchaMobileGetRequest(args [0]string, argsE // // GET /api/dislike func (s *Server) handleAPIDislikeGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/dislike"), @@ -808,7 +1030,16 @@ func (s *Server) handleAPIDislikeGetRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -820,8 +1051,27 @@ func (s *Server) handleAPIDislikeGetRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -903,6 +1153,8 @@ func (s *Server) handleAPIDislikeGetRequest(args [0]string, argsEscaped bool, w // // GET /api/like func (s *Server) handleAPILikeGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/like"), @@ -923,7 +1175,16 @@ func (s *Server) handleAPILikeGetRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -935,8 +1196,27 @@ func (s *Server) handleAPILikeGetRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1020,6 +1300,8 @@ func (s *Server) handleAPILikeGetRequest(args [0]string, argsEscaped bool, w htt // // GET /api/mobile/v2/after/{board}/{thread}/{num} func (s *Server) handleAPIMobileV2AfterBoardThreadNumGetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/mobile/v2/after/{board}/{thread}/{num}"), @@ -1040,7 +1322,16 @@ func (s *Server) handleAPIMobileV2AfterBoardThreadNumGetRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1052,8 +1343,27 @@ func (s *Server) handleAPIMobileV2AfterBoardThreadNumGetRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1139,6 +1449,8 @@ func (s *Server) handleAPIMobileV2AfterBoardThreadNumGetRequest(args [3]string, // // GET /api/mobile/v2/boards func (s *Server) handleAPIMobileV2BoardsGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/mobile/v2/boards"), @@ -1159,7 +1471,16 @@ func (s *Server) handleAPIMobileV2BoardsGetRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1171,8 +1492,27 @@ func (s *Server) handleAPIMobileV2BoardsGetRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1231,6 +1571,8 @@ func (s *Server) handleAPIMobileV2BoardsGetRequest(args [0]string, argsEscaped b // // GET /api/mobile/v2/info/{board}/{thread} func (s *Server) handleAPIMobileV2InfoBoardThreadGetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/mobile/v2/info/{board}/{thread}"), @@ -1251,7 +1593,16 @@ func (s *Server) handleAPIMobileV2InfoBoardThreadGetRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1263,8 +1614,27 @@ func (s *Server) handleAPIMobileV2InfoBoardThreadGetRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1346,6 +1716,8 @@ func (s *Server) handleAPIMobileV2InfoBoardThreadGetRequest(args [2]string, args // // GET /api/mobile/v2/post/{board}/{num} func (s *Server) handleAPIMobileV2PostBoardNumGetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/api/mobile/v2/post/{board}/{num}"), @@ -1366,7 +1738,16 @@ func (s *Server) handleAPIMobileV2PostBoardNumGetRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1378,8 +1759,27 @@ func (s *Server) handleAPIMobileV2PostBoardNumGetRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1461,6 +1861,8 @@ func (s *Server) handleAPIMobileV2PostBoardNumGetRequest(args [2]string, argsEsc // // POST /user/passlogin func (s *Server) handleUserPassloginPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/user/passlogin"), @@ -1481,7 +1883,16 @@ func (s *Server) handleUserPassloginPostRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1493,8 +1904,27 @@ func (s *Server) handleUserPassloginPostRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1587,6 +2017,8 @@ func (s *Server) handleUserPassloginPostRequest(args [0]string, argsEscaped bool // // POST /user/posting func (s *Server) handleUserPostingPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/user/posting"), @@ -1607,7 +2039,16 @@ func (s *Server) handleUserPostingPostRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1619,8 +2060,27 @@ func (s *Server) handleUserPostingPostRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1698,6 +2158,8 @@ func (s *Server) handleUserPostingPostRequest(args [0]string, argsEscaped bool, // // POST /user/report func (s *Server) handleUserReportPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/user/report"), @@ -1718,7 +2180,16 @@ func (s *Server) handleUserReportPostRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1730,8 +2201,27 @@ func (s *Server) handleUserReportPostRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_ent/oas_handlers_gen.go b/examples/ex_ent/oas_handlers_gen.go index a587a206b..b0f94e465 100644 --- a/examples/ex_ent/oas_handlers_gen.go +++ b/examples/ex_ent/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCreatePetRequest handles createPet operation. // // Creates a new Pet and persists it to storage. // // POST /pets func (s *Server) handleCreatePetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createPet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleCreatePetRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleCreatePetRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -138,6 +178,8 @@ func (s *Server) handleCreatePetRequest(args [0]string, argsEscaped bool, w http // // POST /pets/{id}/categories func (s *Server) handleCreatePetCategoriesRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createPetCategories"), semconv.HTTPRequestMethodKey.String("POST"), @@ -159,7 +201,16 @@ func (s *Server) handleCreatePetCategoriesRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -171,8 +222,27 @@ func (s *Server) handleCreatePetCategoriesRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -265,6 +335,8 @@ func (s *Server) handleCreatePetCategoriesRequest(args [1]string, argsEscaped bo // // POST /pets/{id}/friends func (s *Server) handleCreatePetFriendsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createPetFriends"), semconv.HTTPRequestMethodKey.String("POST"), @@ -286,7 +358,16 @@ func (s *Server) handleCreatePetFriendsRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -298,8 +379,27 @@ func (s *Server) handleCreatePetFriendsRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -392,6 +492,8 @@ func (s *Server) handleCreatePetFriendsRequest(args [1]string, argsEscaped bool, // // POST /pets/{id}/owner func (s *Server) handleCreatePetOwnerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createPetOwner"), semconv.HTTPRequestMethodKey.String("POST"), @@ -413,7 +515,16 @@ func (s *Server) handleCreatePetOwnerRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -425,8 +536,27 @@ func (s *Server) handleCreatePetOwnerRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -519,6 +649,8 @@ func (s *Server) handleCreatePetOwnerRequest(args [1]string, argsEscaped bool, w // // DELETE /pets/{id} func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deletePet"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -540,7 +672,16 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -552,8 +693,27 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -631,6 +791,8 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http // // DELETE /pets/{id}/owner func (s *Server) handleDeletePetOwnerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deletePetOwner"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -652,7 +814,16 @@ func (s *Server) handleDeletePetOwnerRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -664,8 +835,27 @@ func (s *Server) handleDeletePetOwnerRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -743,6 +933,8 @@ func (s *Server) handleDeletePetOwnerRequest(args [1]string, argsEscaped bool, w // // GET /pets func (s *Server) handleListPetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -764,7 +956,16 @@ func (s *Server) handleListPetRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -776,8 +977,27 @@ func (s *Server) handleListPetRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -859,6 +1079,8 @@ func (s *Server) handleListPetRequest(args [0]string, argsEscaped bool, w http.R // // GET /pets/{id}/categories func (s *Server) handleListPetCategoriesRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPetCategories"), semconv.HTTPRequestMethodKey.String("GET"), @@ -880,7 +1102,16 @@ func (s *Server) handleListPetCategoriesRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -892,8 +1123,27 @@ func (s *Server) handleListPetCategoriesRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -979,6 +1229,8 @@ func (s *Server) handleListPetCategoriesRequest(args [1]string, argsEscaped bool // // GET /pets/{id}/friends func (s *Server) handleListPetFriendsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPetFriends"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1000,7 +1252,16 @@ func (s *Server) handleListPetFriendsRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1012,8 +1273,27 @@ func (s *Server) handleListPetFriendsRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1099,6 +1379,8 @@ func (s *Server) handleListPetFriendsRequest(args [1]string, argsEscaped bool, w // // GET /pets/{id} func (s *Server) handleReadPetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1120,7 +1402,16 @@ func (s *Server) handleReadPetRequest(args [1]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1132,8 +1423,27 @@ func (s *Server) handleReadPetRequest(args [1]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1211,6 +1521,8 @@ func (s *Server) handleReadPetRequest(args [1]string, argsEscaped bool, w http.R // // GET /pets/{id}/owner func (s *Server) handleReadPetOwnerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPetOwner"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1232,7 +1544,16 @@ func (s *Server) handleReadPetOwnerRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1244,8 +1565,27 @@ func (s *Server) handleReadPetOwnerRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1323,6 +1663,8 @@ func (s *Server) handleReadPetOwnerRequest(args [1]string, argsEscaped bool, w h // // PATCH /pets/{id} func (s *Server) handleUpdatePetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("updatePet"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -1344,7 +1686,16 @@ func (s *Server) handleUpdatePetRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1356,8 +1707,27 @@ func (s *Server) handleUpdatePetRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_firecracker/oas_handlers_gen.go b/examples/ex_firecracker/oas_handlers_gen.go index 2782f4b1b..9c53277ca 100644 --- a/examples/ex_firecracker/oas_handlers_gen.go +++ b/examples/ex_firecracker/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCreateSnapshotRequest handles createSnapshot operation. // // Creates a snapshot of the microVM state. The microVM should be in the `Paused` state. // // PUT /snapshot/create func (s *Server) handleCreateSnapshotRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createSnapshot"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -47,7 +59,16 @@ func (s *Server) handleCreateSnapshotRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleCreateSnapshotRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -149,6 +189,8 @@ func (s *Server) handleCreateSnapshotRequest(args [0]string, argsEscaped bool, w // // PUT /actions func (s *Server) handleCreateSyncActionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createSyncAction"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -170,7 +212,16 @@ func (s *Server) handleCreateSyncActionRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -182,8 +233,27 @@ func (s *Server) handleCreateSyncActionRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -272,6 +342,8 @@ func (s *Server) handleCreateSyncActionRequest(args [0]string, argsEscaped bool, // // GET /balloon func (s *Server) handleDescribeBalloonConfigRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("describeBalloonConfig"), semconv.HTTPRequestMethodKey.String("GET"), @@ -293,7 +365,16 @@ func (s *Server) handleDescribeBalloonConfigRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -305,8 +386,27 @@ func (s *Server) handleDescribeBalloonConfigRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -376,6 +476,8 @@ func (s *Server) handleDescribeBalloonConfigRequest(args [0]string, argsEscaped // // GET /balloon/statistics func (s *Server) handleDescribeBalloonStatsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("describeBalloonStats"), semconv.HTTPRequestMethodKey.String("GET"), @@ -397,7 +499,16 @@ func (s *Server) handleDescribeBalloonStatsRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -409,8 +520,27 @@ func (s *Server) handleDescribeBalloonStatsRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -480,6 +610,8 @@ func (s *Server) handleDescribeBalloonStatsRequest(args [0]string, argsEscaped b // // GET / func (s *Server) handleDescribeInstanceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("describeInstance"), semconv.HTTPRequestMethodKey.String("GET"), @@ -501,7 +633,16 @@ func (s *Server) handleDescribeInstanceRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -513,8 +654,27 @@ func (s *Server) handleDescribeInstanceRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -584,6 +744,8 @@ func (s *Server) handleDescribeInstanceRequest(args [0]string, argsEscaped bool, // // GET /vm/config func (s *Server) handleGetExportVmConfigRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getExportVmConfig"), semconv.HTTPRequestMethodKey.String("GET"), @@ -605,7 +767,16 @@ func (s *Server) handleGetExportVmConfigRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -617,8 +788,27 @@ func (s *Server) handleGetExportVmConfigRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -690,6 +880,8 @@ func (s *Server) handleGetExportVmConfigRequest(args [0]string, argsEscaped bool // // GET /machine-config func (s *Server) handleGetMachineConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getMachineConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -711,7 +903,16 @@ func (s *Server) handleGetMachineConfigurationRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -723,8 +924,27 @@ func (s *Server) handleGetMachineConfigurationRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -795,6 +1015,8 @@ func (s *Server) handleGetMachineConfigurationRequest(args [0]string, argsEscape // // PUT /snapshot/load func (s *Server) handleLoadSnapshotRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("loadSnapshot"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -816,7 +1038,16 @@ func (s *Server) handleLoadSnapshotRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -828,8 +1059,27 @@ func (s *Server) handleLoadSnapshotRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -918,6 +1168,8 @@ func (s *Server) handleLoadSnapshotRequest(args [0]string, argsEscaped bool, w h // // PUT /mmds/config func (s *Server) handleMmdsConfigPutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("PUT"), semconv.HTTPRouteKey.String("/mmds/config"), @@ -938,7 +1190,16 @@ func (s *Server) handleMmdsConfigPutRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -950,8 +1211,27 @@ func (s *Server) handleMmdsConfigPutRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1040,6 +1320,8 @@ func (s *Server) handleMmdsConfigPutRequest(args [0]string, argsEscaped bool, w // // GET /mmds func (s *Server) handleMmdsGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/mmds"), @@ -1060,7 +1342,16 @@ func (s *Server) handleMmdsGetRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1072,8 +1363,27 @@ func (s *Server) handleMmdsGetRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1143,6 +1453,8 @@ func (s *Server) handleMmdsGetRequest(args [0]string, argsEscaped bool, w http.R // // PATCH /mmds func (s *Server) handleMmdsPatchRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("PATCH"), semconv.HTTPRouteKey.String("/mmds"), @@ -1163,7 +1475,16 @@ func (s *Server) handleMmdsPatchRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1175,8 +1496,27 @@ func (s *Server) handleMmdsPatchRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1265,6 +1605,8 @@ func (s *Server) handleMmdsPatchRequest(args [0]string, argsEscaped bool, w http // // PUT /mmds func (s *Server) handleMmdsPutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("PUT"), semconv.HTTPRouteKey.String("/mmds"), @@ -1285,7 +1627,16 @@ func (s *Server) handleMmdsPutRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1297,8 +1648,27 @@ func (s *Server) handleMmdsPutRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1388,6 +1758,8 @@ func (s *Server) handleMmdsPutRequest(args [0]string, argsEscaped bool, w http.R // // PATCH /balloon func (s *Server) handlePatchBalloonRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("patchBalloon"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -1409,7 +1781,16 @@ func (s *Server) handlePatchBalloonRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1421,8 +1802,27 @@ func (s *Server) handlePatchBalloonRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1512,6 +1912,8 @@ func (s *Server) handlePatchBalloonRequest(args [0]string, argsEscaped bool, w h // // PATCH /balloon/statistics func (s *Server) handlePatchBalloonStatsIntervalRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("patchBalloonStatsInterval"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -1533,7 +1935,16 @@ func (s *Server) handlePatchBalloonStatsIntervalRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1545,8 +1956,27 @@ func (s *Server) handlePatchBalloonStatsIntervalRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1636,6 +2066,8 @@ func (s *Server) handlePatchBalloonStatsIntervalRequest(args [0]string, argsEsca // // PATCH /drives/{drive_id} func (s *Server) handlePatchGuestDriveByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("patchGuestDriveByID"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -1657,7 +2089,16 @@ func (s *Server) handlePatchGuestDriveByIDRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1669,8 +2110,27 @@ func (s *Server) handlePatchGuestDriveByIDRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1774,6 +2234,8 @@ func (s *Server) handlePatchGuestDriveByIDRequest(args [1]string, argsEscaped bo // // PATCH /network-interfaces/{iface_id} func (s *Server) handlePatchGuestNetworkInterfaceByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("patchGuestNetworkInterfaceByID"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -1795,7 +2257,16 @@ func (s *Server) handlePatchGuestNetworkInterfaceByIDRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1807,8 +2278,27 @@ func (s *Server) handlePatchGuestNetworkInterfaceByIDRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1913,6 +2403,8 @@ func (s *Server) handlePatchGuestNetworkInterfaceByIDRequest(args [1]string, arg // // PATCH /machine-config func (s *Server) handlePatchMachineConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("patchMachineConfiguration"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -1934,7 +2426,16 @@ func (s *Server) handlePatchMachineConfigurationRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1946,8 +2447,27 @@ func (s *Server) handlePatchMachineConfigurationRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2036,6 +2556,8 @@ func (s *Server) handlePatchMachineConfigurationRequest(args [0]string, argsEsca // // PATCH /vm func (s *Server) handlePatchVmRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("patchVm"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -2057,7 +2579,16 @@ func (s *Server) handlePatchVmRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2069,8 +2600,27 @@ func (s *Server) handlePatchVmRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2160,6 +2710,8 @@ func (s *Server) handlePatchVmRequest(args [0]string, argsEscaped bool, w http.R // // PUT /balloon func (s *Server) handlePutBalloonRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putBalloon"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2181,7 +2733,16 @@ func (s *Server) handlePutBalloonRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2193,8 +2754,27 @@ func (s *Server) handlePutBalloonRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2284,6 +2864,8 @@ func (s *Server) handlePutBalloonRequest(args [0]string, argsEscaped bool, w htt // // PUT /boot-source func (s *Server) handlePutGuestBootSourceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putGuestBootSource"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2305,7 +2887,16 @@ func (s *Server) handlePutGuestBootSourceRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2317,8 +2908,27 @@ func (s *Server) handlePutGuestBootSourceRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2408,6 +3018,8 @@ func (s *Server) handlePutGuestBootSourceRequest(args [0]string, argsEscaped boo // // PUT /drives/{drive_id} func (s *Server) handlePutGuestDriveByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putGuestDriveByID"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2429,7 +3041,16 @@ func (s *Server) handlePutGuestDriveByIDRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2441,8 +3062,27 @@ func (s *Server) handlePutGuestDriveByIDRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2546,6 +3186,8 @@ func (s *Server) handlePutGuestDriveByIDRequest(args [1]string, argsEscaped bool // // PUT /network-interfaces/{iface_id} func (s *Server) handlePutGuestNetworkInterfaceByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putGuestNetworkInterfaceByID"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2567,7 +3209,16 @@ func (s *Server) handlePutGuestNetworkInterfaceByIDRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2579,8 +3230,27 @@ func (s *Server) handlePutGuestNetworkInterfaceByIDRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2685,6 +3355,8 @@ func (s *Server) handlePutGuestNetworkInterfaceByIDRequest(args [1]string, argsE // // PUT /vsock func (s *Server) handlePutGuestVsockRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putGuestVsock"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2706,7 +3378,16 @@ func (s *Server) handlePutGuestVsockRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2718,8 +3399,27 @@ func (s *Server) handlePutGuestVsockRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2808,6 +3508,8 @@ func (s *Server) handlePutGuestVsockRequest(args [0]string, argsEscaped bool, w // // PUT /logger func (s *Server) handlePutLoggerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putLogger"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2829,7 +3531,16 @@ func (s *Server) handlePutLoggerRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2841,8 +3552,27 @@ func (s *Server) handlePutLoggerRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2934,6 +3664,8 @@ func (s *Server) handlePutLoggerRequest(args [0]string, argsEscaped bool, w http // // PUT /machine-config func (s *Server) handlePutMachineConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putMachineConfiguration"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -2955,7 +3687,16 @@ func (s *Server) handlePutMachineConfigurationRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2967,8 +3708,27 @@ func (s *Server) handlePutMachineConfigurationRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3057,6 +3817,8 @@ func (s *Server) handlePutMachineConfigurationRequest(args [0]string, argsEscape // // PUT /metrics func (s *Server) handlePutMetricsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("putMetrics"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -3078,7 +3840,16 @@ func (s *Server) handlePutMetricsRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3090,8 +3861,27 @@ func (s *Server) handlePutMetricsRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_github/oas_handlers_gen.go b/examples/ex_github/oas_handlers_gen.go index e202b3756..1e775be7a 100644 --- a/examples/ex_github/oas_handlers_gen.go +++ b/examples/ex_github/oas_handlers_gen.go @@ -20,6 +20,16 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest handles actions/add-repo-access-to-self-hosted-runner-group-in-org operation. // // The self-hosted runner groups REST API is available with GitHub Enterprise Cloud. For more @@ -34,6 +44,8 @@ import ( // // PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id} func (s *Server) handleActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/add-repo-access-to-self-hosted-runner-group-in-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -55,7 +67,16 @@ func (s *Server) handleActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67,8 +88,27 @@ func (s *Server) handleActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -158,6 +198,8 @@ func (s *Server) handleActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest(a // // PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id} func (s *Server) handleActionsAddSelectedRepoToOrgSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/add-selected-repo-to-org-secret"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -179,7 +221,16 @@ func (s *Server) handleActionsAddSelectedRepoToOrgSecretRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -191,8 +242,27 @@ func (s *Server) handleActionsAddSelectedRepoToOrgSecretRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -283,6 +353,8 @@ func (s *Server) handleActionsAddSelectedRepoToOrgSecretRequest(args [3]string, // // PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id} func (s *Server) handleActionsAddSelfHostedRunnerToGroupForOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/add-self-hosted-runner-to-group-for-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -304,7 +376,16 @@ func (s *Server) handleActionsAddSelfHostedRunnerToGroupForOrgRequest(args [3]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -316,8 +397,27 @@ func (s *Server) handleActionsAddSelfHostedRunnerToGroupForOrgRequest(args [3]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -407,6 +507,8 @@ func (s *Server) handleActionsAddSelfHostedRunnerToGroupForOrgRequest(args [3]st // // POST /repos/{owner}/{repo}/actions/runs/{run_id}/approve func (s *Server) handleActionsApproveWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/approve-workflow-run"), semconv.HTTPRequestMethodKey.String("POST"), @@ -428,7 +530,16 @@ func (s *Server) handleActionsApproveWorkflowRunRequest(args [3]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -440,8 +551,27 @@ func (s *Server) handleActionsApproveWorkflowRunRequest(args [3]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -529,6 +659,8 @@ func (s *Server) handleActionsApproveWorkflowRunRequest(args [3]string, argsEsca // // POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel func (s *Server) handleActionsCancelWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/cancel-workflow-run"), semconv.HTTPRequestMethodKey.String("POST"), @@ -550,7 +682,16 @@ func (s *Server) handleActionsCancelWorkflowRunRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -562,8 +703,27 @@ func (s *Server) handleActionsCancelWorkflowRunRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -702,6 +862,8 @@ func (s *Server) handleActionsCancelWorkflowRunRequest(args [3]string, argsEscap // // PUT /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name} func (s *Server) handleActionsCreateOrUpdateEnvironmentSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-or-update-environment-secret"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -723,7 +885,16 @@ func (s *Server) handleActionsCreateOrUpdateEnvironmentSecretRequest(args [3]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -735,8 +906,27 @@ func (s *Server) handleActionsCreateOrUpdateEnvironmentSecretRequest(args [3]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -890,6 +1080,8 @@ func (s *Server) handleActionsCreateOrUpdateEnvironmentSecretRequest(args [3]str // // PUT /orgs/{org}/actions/secrets/{secret_name} func (s *Server) handleActionsCreateOrUpdateOrgSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-or-update-org-secret"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -911,7 +1103,16 @@ func (s *Server) handleActionsCreateOrUpdateOrgSecretRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -923,8 +1124,27 @@ func (s *Server) handleActionsCreateOrUpdateOrgSecretRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1074,6 +1294,8 @@ func (s *Server) handleActionsCreateOrUpdateOrgSecretRequest(args [2]string, arg // // PUT /repos/{owner}/{repo}/actions/secrets/{secret_name} func (s *Server) handleActionsCreateOrUpdateRepoSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-or-update-repo-secret"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -1095,7 +1317,16 @@ func (s *Server) handleActionsCreateOrUpdateRepoSecretRequest(args [3]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1107,8 +1338,27 @@ func (s *Server) handleActionsCreateOrUpdateRepoSecretRequest(args [3]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1216,6 +1466,8 @@ func (s *Server) handleActionsCreateOrUpdateRepoSecretRequest(args [3]string, ar // // POST /orgs/{org}/actions/runners/registration-token func (s *Server) handleActionsCreateRegistrationTokenForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-registration-token-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1237,7 +1489,16 @@ func (s *Server) handleActionsCreateRegistrationTokenForOrgRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1249,8 +1510,27 @@ func (s *Server) handleActionsCreateRegistrationTokenForOrgRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1336,6 +1616,8 @@ func (s *Server) handleActionsCreateRegistrationTokenForOrgRequest(args [1]strin // // POST /repos/{owner}/{repo}/actions/runners/registration-token func (s *Server) handleActionsCreateRegistrationTokenForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-registration-token-for-repo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1357,7 +1639,16 @@ func (s *Server) handleActionsCreateRegistrationTokenForRepoRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1369,8 +1660,27 @@ func (s *Server) handleActionsCreateRegistrationTokenForRepoRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1461,6 +1771,8 @@ func (s *Server) handleActionsCreateRegistrationTokenForRepoRequest(args [2]stri // // POST /orgs/{org}/actions/runners/remove-token func (s *Server) handleActionsCreateRemoveTokenForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-remove-token-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1482,7 +1794,16 @@ func (s *Server) handleActionsCreateRemoveTokenForOrgRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1494,8 +1815,27 @@ func (s *Server) handleActionsCreateRemoveTokenForOrgRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1581,6 +1921,8 @@ func (s *Server) handleActionsCreateRemoveTokenForOrgRequest(args [1]string, arg // // POST /repos/{owner}/{repo}/actions/runners/remove-token func (s *Server) handleActionsCreateRemoveTokenForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-remove-token-for-repo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1602,7 +1944,16 @@ func (s *Server) handleActionsCreateRemoveTokenForRepoRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1614,8 +1965,27 @@ func (s *Server) handleActionsCreateRemoveTokenForRepoRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1701,6 +2071,8 @@ func (s *Server) handleActionsCreateRemoveTokenForRepoRequest(args [2]string, ar // // POST /orgs/{org}/actions/runner-groups func (s *Server) handleActionsCreateSelfHostedRunnerGroupForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/create-self-hosted-runner-group-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1722,7 +2094,16 @@ func (s *Server) handleActionsCreateSelfHostedRunnerGroupForOrgRequest(args [1]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1734,8 +2115,27 @@ func (s *Server) handleActionsCreateSelfHostedRunnerGroupForOrgRequest(args [1]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1830,6 +2230,8 @@ func (s *Server) handleActionsCreateSelfHostedRunnerGroupForOrgRequest(args [1]s // // DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id} func (s *Server) handleActionsDeleteArtifactRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-artifact"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -1851,7 +2253,16 @@ func (s *Server) handleActionsDeleteArtifactRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1863,8 +2274,27 @@ func (s *Server) handleActionsDeleteArtifactRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1952,6 +2382,8 @@ func (s *Server) handleActionsDeleteArtifactRequest(args [3]string, argsEscaped // // DELETE /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name} func (s *Server) handleActionsDeleteEnvironmentSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-environment-secret"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -1973,7 +2405,16 @@ func (s *Server) handleActionsDeleteEnvironmentSecretRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1985,8 +2426,27 @@ func (s *Server) handleActionsDeleteEnvironmentSecretRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2074,6 +2534,8 @@ func (s *Server) handleActionsDeleteEnvironmentSecretRequest(args [3]string, arg // // DELETE /orgs/{org}/actions/secrets/{secret_name} func (s *Server) handleActionsDeleteOrgSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-org-secret"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2095,7 +2557,16 @@ func (s *Server) handleActionsDeleteOrgSecretRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2107,8 +2578,27 @@ func (s *Server) handleActionsDeleteOrgSecretRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2192,6 +2682,8 @@ func (s *Server) handleActionsDeleteOrgSecretRequest(args [2]string, argsEscaped // // DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name} func (s *Server) handleActionsDeleteRepoSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-repo-secret"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2213,7 +2705,16 @@ func (s *Server) handleActionsDeleteRepoSecretRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2225,8 +2726,27 @@ func (s *Server) handleActionsDeleteRepoSecretRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2314,6 +2834,8 @@ func (s *Server) handleActionsDeleteRepoSecretRequest(args [3]string, argsEscape // // DELETE /orgs/{org}/actions/runners/{runner_id} func (s *Server) handleActionsDeleteSelfHostedRunnerFromOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-self-hosted-runner-from-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2335,7 +2857,16 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerFromOrgRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2347,8 +2878,27 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerFromOrgRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2433,6 +2983,8 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerFromOrgRequest(args [2]strin // // DELETE /repos/{owner}/{repo}/actions/runners/{runner_id} func (s *Server) handleActionsDeleteSelfHostedRunnerFromRepoRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-self-hosted-runner-from-repo"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2454,7 +3006,16 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerFromRepoRequest(args [3]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2466,8 +3027,27 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerFromRepoRequest(args [3]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2557,6 +3137,8 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerFromRepoRequest(args [3]stri // // DELETE /orgs/{org}/actions/runner-groups/{runner_group_id} func (s *Server) handleActionsDeleteSelfHostedRunnerGroupFromOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-self-hosted-runner-group-from-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2578,7 +3160,16 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerGroupFromOrgRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2590,8 +3181,27 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerGroupFromOrgRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2677,6 +3287,8 @@ func (s *Server) handleActionsDeleteSelfHostedRunnerGroupFromOrgRequest(args [2] // // DELETE /repos/{owner}/{repo}/actions/runs/{run_id} func (s *Server) handleActionsDeleteWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-workflow-run"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2698,7 +3310,16 @@ func (s *Server) handleActionsDeleteWorkflowRunRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2710,8 +3331,27 @@ func (s *Server) handleActionsDeleteWorkflowRunRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2799,6 +3439,8 @@ func (s *Server) handleActionsDeleteWorkflowRunRequest(args [3]string, argsEscap // // DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs func (s *Server) handleActionsDeleteWorkflowRunLogsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/delete-workflow-run-logs"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2820,7 +3462,16 @@ func (s *Server) handleActionsDeleteWorkflowRunLogsRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2832,8 +3483,27 @@ func (s *Server) handleActionsDeleteWorkflowRunLogsRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2924,6 +3594,8 @@ func (s *Server) handleActionsDeleteWorkflowRunLogsRequest(args [3]string, argsE // // DELETE /orgs/{org}/actions/permissions/repositories/{repository_id} func (s *Server) handleActionsDisableSelectedRepositoryGithubActionsOrganizationRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/disable-selected-repository-github-actions-organization"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -2945,7 +3617,16 @@ func (s *Server) handleActionsDisableSelectedRepositoryGithubActionsOrganization startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2957,8 +3638,27 @@ func (s *Server) handleActionsDisableSelectedRepositoryGithubActionsOrganization var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3046,6 +3746,8 @@ func (s *Server) handleActionsDisableSelectedRepositoryGithubActionsOrganization // // GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format} func (s *Server) handleActionsDownloadArtifactRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/download-artifact"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3067,7 +3769,16 @@ func (s *Server) handleActionsDownloadArtifactRequest(args [4]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3079,8 +3790,27 @@ func (s *Server) handleActionsDownloadArtifactRequest(args [4]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3178,6 +3908,8 @@ func (s *Server) handleActionsDownloadArtifactRequest(args [4]string, argsEscape // // GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs func (s *Server) handleActionsDownloadJobLogsForWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/download-job-logs-for-workflow-run"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3199,7 +3931,16 @@ func (s *Server) handleActionsDownloadJobLogsForWorkflowRunRequest(args [3]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3211,8 +3952,27 @@ func (s *Server) handleActionsDownloadJobLogsForWorkflowRunRequest(args [3]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3304,6 +4064,8 @@ func (s *Server) handleActionsDownloadJobLogsForWorkflowRunRequest(args [3]strin // // GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs func (s *Server) handleActionsDownloadWorkflowRunLogsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/download-workflow-run-logs"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3325,7 +4087,16 @@ func (s *Server) handleActionsDownloadWorkflowRunLogsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3337,8 +4108,27 @@ func (s *Server) handleActionsDownloadWorkflowRunLogsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3429,6 +4219,8 @@ func (s *Server) handleActionsDownloadWorkflowRunLogsRequest(args [3]string, arg // // PUT /orgs/{org}/actions/permissions/repositories/{repository_id} func (s *Server) handleActionsEnableSelectedRepositoryGithubActionsOrganizationRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/enable-selected-repository-github-actions-organization"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -3450,7 +4242,16 @@ func (s *Server) handleActionsEnableSelectedRepositoryGithubActionsOrganizationR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3462,8 +4263,27 @@ func (s *Server) handleActionsEnableSelectedRepositoryGithubActionsOrganizationR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3550,6 +4370,8 @@ func (s *Server) handleActionsEnableSelectedRepositoryGithubActionsOrganizationR // // GET /orgs/{org}/actions/permissions/selected-actions func (s *Server) handleActionsGetAllowedActionsOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-allowed-actions-organization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3571,7 +4393,16 @@ func (s *Server) handleActionsGetAllowedActionsOrganizationRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3583,8 +4414,27 @@ func (s *Server) handleActionsGetAllowedActionsOrganizationRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3667,6 +4517,8 @@ func (s *Server) handleActionsGetAllowedActionsOrganizationRequest(args [1]strin // // GET /repos/{owner}/{repo}/actions/permissions/selected-actions func (s *Server) handleActionsGetAllowedActionsRepositoryRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-allowed-actions-repository"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3688,7 +4540,16 @@ func (s *Server) handleActionsGetAllowedActionsRepositoryRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3700,8 +4561,27 @@ func (s *Server) handleActionsGetAllowedActionsRepositoryRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3785,6 +4665,8 @@ func (s *Server) handleActionsGetAllowedActionsRepositoryRequest(args [2]string, // // GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id} func (s *Server) handleActionsGetArtifactRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-artifact"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3806,7 +4688,16 @@ func (s *Server) handleActionsGetArtifactRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3818,8 +4709,27 @@ func (s *Server) handleActionsGetArtifactRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3908,6 +4818,8 @@ func (s *Server) handleActionsGetArtifactRequest(args [3]string, argsEscaped boo // // GET /repositories/{repository_id}/environments/{environment_name}/secrets/public-key func (s *Server) handleActionsGetEnvironmentPublicKeyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-environment-public-key"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3929,7 +4841,16 @@ func (s *Server) handleActionsGetEnvironmentPublicKeyRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3941,8 +4862,27 @@ func (s *Server) handleActionsGetEnvironmentPublicKeyRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4026,6 +4966,8 @@ func (s *Server) handleActionsGetEnvironmentPublicKeyRequest(args [2]string, arg // // GET /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name} func (s *Server) handleActionsGetEnvironmentSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-environment-secret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4047,7 +4989,16 @@ func (s *Server) handleActionsGetEnvironmentSecretRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4059,8 +5010,27 @@ func (s *Server) handleActionsGetEnvironmentSecretRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4148,6 +5118,8 @@ func (s *Server) handleActionsGetEnvironmentSecretRequest(args [3]string, argsEs // // GET /orgs/{org}/actions/permissions func (s *Server) handleActionsGetGithubActionsPermissionsOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-github-actions-permissions-organization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4169,7 +5141,16 @@ func (s *Server) handleActionsGetGithubActionsPermissionsOrganizationRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4181,8 +5162,27 @@ func (s *Server) handleActionsGetGithubActionsPermissionsOrganizationRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4263,6 +5263,8 @@ func (s *Server) handleActionsGetGithubActionsPermissionsOrganizationRequest(arg // // GET /repos/{owner}/{repo}/actions/permissions func (s *Server) handleActionsGetGithubActionsPermissionsRepositoryRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-github-actions-permissions-repository"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4284,7 +5286,16 @@ func (s *Server) handleActionsGetGithubActionsPermissionsRepositoryRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4296,8 +5307,27 @@ func (s *Server) handleActionsGetGithubActionsPermissionsRepositoryRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4381,6 +5411,8 @@ func (s *Server) handleActionsGetGithubActionsPermissionsRepositoryRequest(args // // GET /repos/{owner}/{repo}/actions/jobs/{job_id} func (s *Server) handleActionsGetJobForWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-job-for-workflow-run"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4402,7 +5434,16 @@ func (s *Server) handleActionsGetJobForWorkflowRunRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4414,8 +5455,27 @@ func (s *Server) handleActionsGetJobForWorkflowRunRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4504,6 +5564,8 @@ func (s *Server) handleActionsGetJobForWorkflowRunRequest(args [3]string, argsEs // // GET /orgs/{org}/actions/secrets/public-key func (s *Server) handleActionsGetOrgPublicKeyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-org-public-key"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4525,7 +5587,16 @@ func (s *Server) handleActionsGetOrgPublicKeyRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4537,8 +5608,27 @@ func (s *Server) handleActionsGetOrgPublicKeyRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4618,6 +5708,8 @@ func (s *Server) handleActionsGetOrgPublicKeyRequest(args [1]string, argsEscaped // // GET /orgs/{org}/actions/secrets/{secret_name} func (s *Server) handleActionsGetOrgSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-org-secret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4639,7 +5731,16 @@ func (s *Server) handleActionsGetOrgSecretRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4651,8 +5752,27 @@ func (s *Server) handleActionsGetOrgSecretRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4737,6 +5857,8 @@ func (s *Server) handleActionsGetOrgSecretRequest(args [2]string, argsEscaped bo // // GET /repos/{owner}/{repo}/actions/secrets/public-key func (s *Server) handleActionsGetRepoPublicKeyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-repo-public-key"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4758,7 +5880,16 @@ func (s *Server) handleActionsGetRepoPublicKeyRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4770,8 +5901,27 @@ func (s *Server) handleActionsGetRepoPublicKeyRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4855,6 +6005,8 @@ func (s *Server) handleActionsGetRepoPublicKeyRequest(args [2]string, argsEscape // // GET /repos/{owner}/{repo}/actions/secrets/{secret_name} func (s *Server) handleActionsGetRepoSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-repo-secret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4876,7 +6028,16 @@ func (s *Server) handleActionsGetRepoSecretRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4888,8 +6049,27 @@ func (s *Server) handleActionsGetRepoSecretRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4977,6 +6157,8 @@ func (s *Server) handleActionsGetRepoSecretRequest(args [3]string, argsEscaped b // // GET /repos/{owner}/{repo}/actions/runs/{run_id}/approvals func (s *Server) handleActionsGetReviewsForRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-reviews-for-run"), semconv.HTTPRequestMethodKey.String("GET"), @@ -4998,7 +6180,16 @@ func (s *Server) handleActionsGetReviewsForRunRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5010,8 +6201,27 @@ func (s *Server) handleActionsGetReviewsForRunRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5098,6 +6308,8 @@ func (s *Server) handleActionsGetReviewsForRunRequest(args [3]string, argsEscape // // GET /orgs/{org}/actions/runners/{runner_id} func (s *Server) handleActionsGetSelfHostedRunnerForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-self-hosted-runner-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5119,7 +6331,16 @@ func (s *Server) handleActionsGetSelfHostedRunnerForOrgRequest(args [2]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5131,8 +6352,27 @@ func (s *Server) handleActionsGetSelfHostedRunnerForOrgRequest(args [2]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5216,6 +6456,8 @@ func (s *Server) handleActionsGetSelfHostedRunnerForOrgRequest(args [2]string, a // // GET /repos/{owner}/{repo}/actions/runners/{runner_id} func (s *Server) handleActionsGetSelfHostedRunnerForRepoRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-self-hosted-runner-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5237,7 +6479,16 @@ func (s *Server) handleActionsGetSelfHostedRunnerForRepoRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5249,8 +6500,27 @@ func (s *Server) handleActionsGetSelfHostedRunnerForRepoRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5340,6 +6610,8 @@ func (s *Server) handleActionsGetSelfHostedRunnerForRepoRequest(args [3]string, // // GET /orgs/{org}/actions/runner-groups/{runner_group_id} func (s *Server) handleActionsGetSelfHostedRunnerGroupForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-self-hosted-runner-group-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5361,7 +6633,16 @@ func (s *Server) handleActionsGetSelfHostedRunnerGroupForOrgRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5373,8 +6654,27 @@ func (s *Server) handleActionsGetSelfHostedRunnerGroupForOrgRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5458,6 +6758,8 @@ func (s *Server) handleActionsGetSelfHostedRunnerGroupForOrgRequest(args [2]stri // // GET /repos/{owner}/{repo}/actions/runs/{run_id} func (s *Server) handleActionsGetWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-workflow-run"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5479,7 +6781,16 @@ func (s *Server) handleActionsGetWorkflowRunRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5491,8 +6802,27 @@ func (s *Server) handleActionsGetWorkflowRunRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5587,6 +6917,8 @@ func (s *Server) handleActionsGetWorkflowRunRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing func (s *Server) handleActionsGetWorkflowRunUsageRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/get-workflow-run-usage"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5608,7 +6940,16 @@ func (s *Server) handleActionsGetWorkflowRunUsageRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5620,8 +6961,27 @@ func (s *Server) handleActionsGetWorkflowRunUsageRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5709,6 +7069,8 @@ func (s *Server) handleActionsGetWorkflowRunUsageRequest(args [3]string, argsEsc // // GET /repos/{owner}/{repo}/actions/artifacts func (s *Server) handleActionsListArtifactsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-artifacts-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5730,7 +7092,16 @@ func (s *Server) handleActionsListArtifactsForRepoRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5742,8 +7113,27 @@ func (s *Server) handleActionsListArtifactsForRepoRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5835,6 +7225,8 @@ func (s *Server) handleActionsListArtifactsForRepoRequest(args [2]string, argsEs // // GET /repositories/{repository_id}/environments/{environment_name}/secrets func (s *Server) handleActionsListEnvironmentSecretsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-environment-secrets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5856,7 +7248,16 @@ func (s *Server) handleActionsListEnvironmentSecretsRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5868,8 +7269,27 @@ func (s *Server) handleActionsListEnvironmentSecretsRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5963,6 +7383,8 @@ func (s *Server) handleActionsListEnvironmentSecretsRequest(args [2]string, args // // GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs func (s *Server) handleActionsListJobsForWorkflowRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-jobs-for-workflow-run"), semconv.HTTPRequestMethodKey.String("GET"), @@ -5984,7 +7406,16 @@ func (s *Server) handleActionsListJobsForWorkflowRunRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5996,8 +7427,27 @@ func (s *Server) handleActionsListJobsForWorkflowRunRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6097,6 +7547,8 @@ func (s *Server) handleActionsListJobsForWorkflowRunRequest(args [3]string, args // // GET /orgs/{org}/actions/secrets func (s *Server) handleActionsListOrgSecretsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-org-secrets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6118,7 +7570,16 @@ func (s *Server) handleActionsListOrgSecretsRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6130,8 +7591,27 @@ func (s *Server) handleActionsListOrgSecretsRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6221,6 +7701,8 @@ func (s *Server) handleActionsListOrgSecretsRequest(args [1]string, argsEscaped // // GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories func (s *Server) handleActionsListRepoAccessToSelfHostedRunnerGroupInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-repo-access-to-self-hosted-runner-group-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6242,7 +7724,16 @@ func (s *Server) handleActionsListRepoAccessToSelfHostedRunnerGroupInOrgRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6254,8 +7745,27 @@ func (s *Server) handleActionsListRepoAccessToSelfHostedRunnerGroupInOrgRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6347,6 +7857,8 @@ func (s *Server) handleActionsListRepoAccessToSelfHostedRunnerGroupInOrgRequest( // // GET /repos/{owner}/{repo}/actions/secrets func (s *Server) handleActionsListRepoSecretsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-repo-secrets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6368,7 +7880,16 @@ func (s *Server) handleActionsListRepoSecretsRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6380,8 +7901,27 @@ func (s *Server) handleActionsListRepoSecretsRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6473,6 +8013,8 @@ func (s *Server) handleActionsListRepoSecretsRequest(args [2]string, argsEscaped // // GET /repos/{owner}/{repo}/actions/workflows func (s *Server) handleActionsListRepoWorkflowsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-repo-workflows"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6494,7 +8036,16 @@ func (s *Server) handleActionsListRepoWorkflowsRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6506,8 +8057,27 @@ func (s *Server) handleActionsListRepoWorkflowsRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6598,6 +8168,8 @@ func (s *Server) handleActionsListRepoWorkflowsRequest(args [2]string, argsEscap // // GET /orgs/{org}/actions/runners/downloads func (s *Server) handleActionsListRunnerApplicationsForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-runner-applications-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6619,7 +8191,16 @@ func (s *Server) handleActionsListRunnerApplicationsForOrgRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6631,8 +8212,27 @@ func (s *Server) handleActionsListRunnerApplicationsForOrgRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6711,6 +8311,8 @@ func (s *Server) handleActionsListRunnerApplicationsForOrgRequest(args [1]string // // GET /repos/{owner}/{repo}/actions/runners/downloads func (s *Server) handleActionsListRunnerApplicationsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-runner-applications-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6732,7 +8334,16 @@ func (s *Server) handleActionsListRunnerApplicationsForRepoRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6744,8 +8355,27 @@ func (s *Server) handleActionsListRunnerApplicationsForRepoRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6830,6 +8460,8 @@ func (s *Server) handleActionsListRunnerApplicationsForRepoRequest(args [2]strin // // GET /orgs/{org}/actions/secrets/{secret_name}/repositories func (s *Server) handleActionsListSelectedReposForOrgSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-selected-repos-for-org-secret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6851,7 +8483,16 @@ func (s *Server) handleActionsListSelectedReposForOrgSecretRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6863,8 +8504,27 @@ func (s *Server) handleActionsListSelectedReposForOrgSecretRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6959,6 +8619,8 @@ func (s *Server) handleActionsListSelectedReposForOrgSecretRequest(args [2]strin // // GET /orgs/{org}/actions/permissions/repositories func (s *Server) handleActionsListSelectedRepositoriesEnabledGithubActionsOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-selected-repositories-enabled-github-actions-organization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -6980,7 +8642,16 @@ func (s *Server) handleActionsListSelectedRepositoriesEnabledGithubActionsOrgani startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6992,8 +8663,27 @@ func (s *Server) handleActionsListSelectedRepositoriesEnabledGithubActionsOrgani var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7083,6 +8773,8 @@ func (s *Server) handleActionsListSelectedRepositoriesEnabledGithubActionsOrgani // // GET /orgs/{org}/actions/runner-groups func (s *Server) handleActionsListSelfHostedRunnerGroupsForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-self-hosted-runner-groups-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -7104,7 +8796,16 @@ func (s *Server) handleActionsListSelfHostedRunnerGroupsForOrgRequest(args [1]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7116,8 +8817,27 @@ func (s *Server) handleActionsListSelfHostedRunnerGroupsForOrgRequest(args [1]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7204,6 +8924,8 @@ func (s *Server) handleActionsListSelfHostedRunnerGroupsForOrgRequest(args [1]st // // GET /orgs/{org}/actions/runners func (s *Server) handleActionsListSelfHostedRunnersForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-self-hosted-runners-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -7225,7 +8947,16 @@ func (s *Server) handleActionsListSelfHostedRunnersForOrgRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7237,8 +8968,27 @@ func (s *Server) handleActionsListSelfHostedRunnersForOrgRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7325,6 +9075,8 @@ func (s *Server) handleActionsListSelfHostedRunnersForOrgRequest(args [1]string, // // GET /repos/{owner}/{repo}/actions/runners func (s *Server) handleActionsListSelfHostedRunnersForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-self-hosted-runners-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -7346,7 +9098,16 @@ func (s *Server) handleActionsListSelfHostedRunnersForRepoRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7358,8 +9119,27 @@ func (s *Server) handleActionsListSelfHostedRunnersForRepoRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7453,6 +9233,8 @@ func (s *Server) handleActionsListSelfHostedRunnersForRepoRequest(args [2]string // // GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners func (s *Server) handleActionsListSelfHostedRunnersInGroupForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-self-hosted-runners-in-group-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -7474,7 +9256,16 @@ func (s *Server) handleActionsListSelfHostedRunnersInGroupForOrgRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7486,8 +9277,27 @@ func (s *Server) handleActionsListSelfHostedRunnersInGroupForOrgRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7579,6 +9389,8 @@ func (s *Server) handleActionsListSelfHostedRunnersInGroupForOrgRequest(args [2] // // GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts func (s *Server) handleActionsListWorkflowRunArtifactsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-workflow-run-artifacts"), semconv.HTTPRequestMethodKey.String("GET"), @@ -7600,7 +9412,16 @@ func (s *Server) handleActionsListWorkflowRunArtifactsRequest(args [3]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7612,8 +9433,27 @@ func (s *Server) handleActionsListWorkflowRunArtifactsRequest(args [3]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7712,6 +9552,8 @@ func (s *Server) handleActionsListWorkflowRunArtifactsRequest(args [3]string, ar // // GET /repos/{owner}/{repo}/actions/runs func (s *Server) handleActionsListWorkflowRunsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/list-workflow-runs-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -7733,7 +9575,16 @@ func (s *Server) handleActionsListWorkflowRunsForRepoRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7745,8 +9596,27 @@ func (s *Server) handleActionsListWorkflowRunsForRepoRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7863,6 +9733,8 @@ func (s *Server) handleActionsListWorkflowRunsForRepoRequest(args [2]string, arg // // POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun func (s *Server) handleActionsReRunWorkflowRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/re-run-workflow"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7884,7 +9756,16 @@ func (s *Server) handleActionsReRunWorkflowRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7896,8 +9777,27 @@ func (s *Server) handleActionsReRunWorkflowRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7990,6 +9890,8 @@ func (s *Server) handleActionsReRunWorkflowRequest(args [3]string, argsEscaped b // // DELETE /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id} func (s *Server) handleActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/remove-repo-access-to-self-hosted-runner-group-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -8011,7 +9913,16 @@ func (s *Server) handleActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8023,8 +9934,27 @@ func (s *Server) handleActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8114,6 +10044,8 @@ func (s *Server) handleActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgReques // // DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id} func (s *Server) handleActionsRemoveSelectedRepoFromOrgSecretRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/remove-selected-repo-from-org-secret"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -8135,7 +10067,16 @@ func (s *Server) handleActionsRemoveSelectedRepoFromOrgSecretRequest(args [3]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8147,8 +10088,27 @@ func (s *Server) handleActionsRemoveSelectedRepoFromOrgSecretRequest(args [3]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8239,6 +10199,8 @@ func (s *Server) handleActionsRemoveSelectedRepoFromOrgSecretRequest(args [3]str // // DELETE /orgs/{org}/actions/runner-groups/{runner_group_id}/runners/{runner_id} func (s *Server) handleActionsRemoveSelfHostedRunnerFromGroupForOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/remove-self-hosted-runner-from-group-for-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -8260,7 +10222,16 @@ func (s *Server) handleActionsRemoveSelfHostedRunnerFromGroupForOrgRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8272,8 +10243,27 @@ func (s *Server) handleActionsRemoveSelfHostedRunnerFromGroupForOrgRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8361,6 +10351,8 @@ func (s *Server) handleActionsRemoveSelfHostedRunnerFromGroupForOrgRequest(args // // POST /repos/{owner}/{repo}/actions/runs/{run_id}/retry func (s *Server) handleActionsRetryWorkflowRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/retry-workflow"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8382,7 +10374,16 @@ func (s *Server) handleActionsRetryWorkflowRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8394,8 +10395,27 @@ func (s *Server) handleActionsRetryWorkflowRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8482,6 +10502,8 @@ func (s *Server) handleActionsRetryWorkflowRequest(args [3]string, argsEscaped b // // POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments func (s *Server) handleActionsReviewPendingDeploymentsForRunRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/review-pending-deployments-for-run"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8503,7 +10525,16 @@ func (s *Server) handleActionsReviewPendingDeploymentsForRunRequest(args [3]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8515,8 +10546,27 @@ func (s *Server) handleActionsReviewPendingDeploymentsForRunRequest(args [3]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8627,6 +10677,8 @@ func (s *Server) handleActionsReviewPendingDeploymentsForRunRequest(args [3]stri // // PUT /orgs/{org}/actions/permissions/selected-actions func (s *Server) handleActionsSetAllowedActionsOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-allowed-actions-organization"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -8648,7 +10700,16 @@ func (s *Server) handleActionsSetAllowedActionsOrganizationRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8660,8 +10721,27 @@ func (s *Server) handleActionsSetAllowedActionsOrganizationRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8763,6 +10843,8 @@ func (s *Server) handleActionsSetAllowedActionsOrganizationRequest(args [1]strin // // PUT /repos/{owner}/{repo}/actions/permissions/selected-actions func (s *Server) handleActionsSetAllowedActionsRepositoryRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-allowed-actions-repository"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -8784,7 +10866,16 @@ func (s *Server) handleActionsSetAllowedActionsRepositoryRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8796,8 +10887,27 @@ func (s *Server) handleActionsSetAllowedActionsRepositoryRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8899,6 +11009,8 @@ func (s *Server) handleActionsSetAllowedActionsRepositoryRequest(args [2]string, // // PUT /orgs/{org}/actions/permissions func (s *Server) handleActionsSetGithubActionsPermissionsOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-github-actions-permissions-organization"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -8920,7 +11032,16 @@ func (s *Server) handleActionsSetGithubActionsPermissionsOrganizationRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8932,8 +11053,27 @@ func (s *Server) handleActionsSetGithubActionsPermissionsOrganizationRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9032,6 +11172,8 @@ func (s *Server) handleActionsSetGithubActionsPermissionsOrganizationRequest(arg // // PUT /repos/{owner}/{repo}/actions/permissions func (s *Server) handleActionsSetGithubActionsPermissionsRepositoryRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-github-actions-permissions-repository"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -9053,7 +11195,16 @@ func (s *Server) handleActionsSetGithubActionsPermissionsRepositoryRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9065,8 +11216,27 @@ func (s *Server) handleActionsSetGithubActionsPermissionsRepositoryRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9168,6 +11338,8 @@ func (s *Server) handleActionsSetGithubActionsPermissionsRepositoryRequest(args // // PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories func (s *Server) handleActionsSetRepoAccessToSelfHostedRunnerGroupInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-repo-access-to-self-hosted-runner-group-in-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -9189,7 +11361,16 @@ func (s *Server) handleActionsSetRepoAccessToSelfHostedRunnerGroupInOrgRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9201,8 +11382,27 @@ func (s *Server) handleActionsSetRepoAccessToSelfHostedRunnerGroupInOrgRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9303,6 +11503,8 @@ func (s *Server) handleActionsSetRepoAccessToSelfHostedRunnerGroupInOrgRequest(a // // PUT /orgs/{org}/actions/secrets/{secret_name}/repositories func (s *Server) handleActionsSetSelectedReposForOrgSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-selected-repos-for-org-secret"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -9324,7 +11526,16 @@ func (s *Server) handleActionsSetSelectedReposForOrgSecretRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9336,8 +11547,27 @@ func (s *Server) handleActionsSetSelectedReposForOrgSecretRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9439,6 +11669,8 @@ func (s *Server) handleActionsSetSelectedReposForOrgSecretRequest(args [2]string // // PUT /orgs/{org}/actions/permissions/repositories func (s *Server) handleActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-selected-repositories-enabled-github-actions-organization"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -9460,7 +11692,16 @@ func (s *Server) handleActionsSetSelectedRepositoriesEnabledGithubActionsOrganiz startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9472,8 +11713,27 @@ func (s *Server) handleActionsSetSelectedRepositoriesEnabledGithubActionsOrganiz var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9570,6 +11830,8 @@ func (s *Server) handleActionsSetSelectedRepositoriesEnabledGithubActionsOrganiz // // PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/runners func (s *Server) handleActionsSetSelfHostedRunnersInGroupForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/set-self-hosted-runners-in-group-for-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -9591,7 +11853,16 @@ func (s *Server) handleActionsSetSelfHostedRunnersInGroupForOrgRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9603,8 +11874,27 @@ func (s *Server) handleActionsSetSelfHostedRunnersInGroupForOrgRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9705,6 +11995,8 @@ func (s *Server) handleActionsSetSelfHostedRunnersInGroupForOrgRequest(args [2]s // // PATCH /orgs/{org}/actions/runner-groups/{runner_group_id} func (s *Server) handleActionsUpdateSelfHostedRunnerGroupForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("actions/update-self-hosted-runner-group-for-org"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -9726,7 +12018,16 @@ func (s *Server) handleActionsUpdateSelfHostedRunnerGroupForOrgRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9738,8 +12039,27 @@ func (s *Server) handleActionsUpdateSelfHostedRunnerGroupForOrgRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9836,6 +12156,8 @@ func (s *Server) handleActionsUpdateSelfHostedRunnerGroupForOrgRequest(args [2]s // // GET /user/starred/{owner}/{repo} func (s *Server) handleActivityCheckRepoIsStarredByAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/check-repo-is-starred-by-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9857,7 +12179,16 @@ func (s *Server) handleActivityCheckRepoIsStarredByAuthenticatedUserRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9869,8 +12200,27 @@ func (s *Server) handleActivityCheckRepoIsStarredByAuthenticatedUserRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9954,6 +12304,8 @@ func (s *Server) handleActivityCheckRepoIsStarredByAuthenticatedUserRequest(args // // DELETE /repos/{owner}/{repo}/subscription func (s *Server) handleActivityDeleteRepoSubscriptionRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/delete-repo-subscription"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -9975,7 +12327,16 @@ func (s *Server) handleActivityDeleteRepoSubscriptionRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9987,8 +12348,27 @@ func (s *Server) handleActivityDeleteRepoSubscriptionRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10074,6 +12454,8 @@ func (s *Server) handleActivityDeleteRepoSubscriptionRequest(args [2]string, arg // // DELETE /notifications/threads/{thread_id}/subscription func (s *Server) handleActivityDeleteThreadSubscriptionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/delete-thread-subscription"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -10095,7 +12477,16 @@ func (s *Server) handleActivityDeleteThreadSubscriptionRequest(args [1]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10107,8 +12498,27 @@ func (s *Server) handleActivityDeleteThreadSubscriptionRequest(args [1]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10200,6 +12610,8 @@ func (s *Server) handleActivityDeleteThreadSubscriptionRequest(args [1]string, a // // GET /feeds func (s *Server) handleActivityGetFeedsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/get-feeds"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10221,7 +12633,16 @@ func (s *Server) handleActivityGetFeedsRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10233,8 +12654,27 @@ func (s *Server) handleActivityGetFeedsRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -10293,6 +12733,8 @@ func (s *Server) handleActivityGetFeedsRequest(args [0]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/subscription func (s *Server) handleActivityGetRepoSubscriptionRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/get-repo-subscription"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10314,7 +12756,16 @@ func (s *Server) handleActivityGetRepoSubscriptionRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10326,8 +12777,27 @@ func (s *Server) handleActivityGetRepoSubscriptionRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10409,6 +12879,8 @@ func (s *Server) handleActivityGetRepoSubscriptionRequest(args [2]string, argsEs // // GET /notifications/threads/{thread_id} func (s *Server) handleActivityGetThreadRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/get-thread"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10430,7 +12902,16 @@ func (s *Server) handleActivityGetThreadRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10442,8 +12923,27 @@ func (s *Server) handleActivityGetThreadRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10524,6 +13024,8 @@ func (s *Server) handleActivityGetThreadRequest(args [1]string, argsEscaped bool // // GET /notifications/threads/{thread_id}/subscription func (s *Server) handleActivityGetThreadSubscriptionForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/get-thread-subscription-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10545,7 +13047,16 @@ func (s *Server) handleActivityGetThreadSubscriptionForAuthenticatedUserRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10557,8 +13068,27 @@ func (s *Server) handleActivityGetThreadSubscriptionForAuthenticatedUserRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10637,6 +13167,8 @@ func (s *Server) handleActivityGetThreadSubscriptionForAuthenticatedUserRequest( // // GET /users/{username}/events func (s *Server) handleActivityListEventsForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-events-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10658,7 +13190,16 @@ func (s *Server) handleActivityListEventsForAuthenticatedUserRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10670,8 +13211,27 @@ func (s *Server) handleActivityListEventsForAuthenticatedUserRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10757,6 +13317,8 @@ func (s *Server) handleActivityListEventsForAuthenticatedUserRequest(args [1]str // // GET /notifications func (s *Server) handleActivityListNotificationsForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-notifications-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10778,7 +13340,16 @@ func (s *Server) handleActivityListNotificationsForAuthenticatedUserRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10790,8 +13361,27 @@ func (s *Server) handleActivityListNotificationsForAuthenticatedUserRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10889,6 +13479,8 @@ func (s *Server) handleActivityListNotificationsForAuthenticatedUserRequest(args // // GET /users/{username}/events/orgs/{org} func (s *Server) handleActivityListOrgEventsForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-org-events-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10910,7 +13502,16 @@ func (s *Server) handleActivityListOrgEventsForAuthenticatedUserRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10922,8 +13523,27 @@ func (s *Server) handleActivityListOrgEventsForAuthenticatedUserRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11014,6 +13634,8 @@ func (s *Server) handleActivityListOrgEventsForAuthenticatedUserRequest(args [2] // // GET /events func (s *Server) handleActivityListPublicEventsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-public-events"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11035,7 +13657,16 @@ func (s *Server) handleActivityListPublicEventsRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11047,8 +13678,27 @@ func (s *Server) handleActivityListPublicEventsRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11130,6 +13780,8 @@ func (s *Server) handleActivityListPublicEventsRequest(args [0]string, argsEscap // // GET /networks/{owner}/{repo}/events func (s *Server) handleActivityListPublicEventsForRepoNetworkRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-public-events-for-repo-network"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11151,7 +13803,16 @@ func (s *Server) handleActivityListPublicEventsForRepoNetworkRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11163,8 +13824,27 @@ func (s *Server) handleActivityListPublicEventsForRepoNetworkRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11254,6 +13934,8 @@ func (s *Server) handleActivityListPublicEventsForRepoNetworkRequest(args [2]str // // GET /users/{username}/events/public func (s *Server) handleActivityListPublicEventsForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-public-events-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11275,7 +13957,16 @@ func (s *Server) handleActivityListPublicEventsForUserRequest(args [1]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11287,8 +13978,27 @@ func (s *Server) handleActivityListPublicEventsForUserRequest(args [1]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11374,6 +14084,8 @@ func (s *Server) handleActivityListPublicEventsForUserRequest(args [1]string, ar // // GET /orgs/{org}/events func (s *Server) handleActivityListPublicOrgEventsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-public-org-events"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11395,7 +14107,16 @@ func (s *Server) handleActivityListPublicOrgEventsRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11407,8 +14128,27 @@ func (s *Server) handleActivityListPublicOrgEventsRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11496,6 +14236,8 @@ func (s *Server) handleActivityListPublicOrgEventsRequest(args [1]string, argsEs // // GET /users/{username}/received_events func (s *Server) handleActivityListReceivedEventsForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-received-events-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11517,7 +14259,16 @@ func (s *Server) handleActivityListReceivedEventsForUserRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11529,8 +14280,27 @@ func (s *Server) handleActivityListReceivedEventsForUserRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11616,6 +14386,8 @@ func (s *Server) handleActivityListReceivedEventsForUserRequest(args [1]string, // // GET /users/{username}/received_events/public func (s *Server) handleActivityListReceivedPublicEventsForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-received-public-events-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11637,7 +14409,16 @@ func (s *Server) handleActivityListReceivedPublicEventsForUserRequest(args [1]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11649,8 +14430,27 @@ func (s *Server) handleActivityListReceivedPublicEventsForUserRequest(args [1]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11736,6 +14536,8 @@ func (s *Server) handleActivityListReceivedPublicEventsForUserRequest(args [1]st // // GET /repos/{owner}/{repo}/events func (s *Server) handleActivityListRepoEventsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-repo-events"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11757,7 +14559,16 @@ func (s *Server) handleActivityListRepoEventsRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11769,8 +14580,27 @@ func (s *Server) handleActivityListRepoEventsRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11860,6 +14690,8 @@ func (s *Server) handleActivityListRepoEventsRequest(args [2]string, argsEscaped // // GET /repos/{owner}/{repo}/notifications func (s *Server) handleActivityListRepoNotificationsForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-repo-notifications-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11881,7 +14713,16 @@ func (s *Server) handleActivityListRepoNotificationsForAuthenticatedUserRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11893,8 +14734,27 @@ func (s *Server) handleActivityListRepoNotificationsForAuthenticatedUserRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12002,6 +14862,8 @@ func (s *Server) handleActivityListRepoNotificationsForAuthenticatedUserRequest( // // GET /user/starred func (s *Server) handleActivityListReposStarredByAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-repos-starred-by-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12023,7 +14885,16 @@ func (s *Server) handleActivityListReposStarredByAuthenticatedUserRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12035,8 +14906,27 @@ func (s *Server) handleActivityListReposStarredByAuthenticatedUserRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12126,6 +15016,8 @@ func (s *Server) handleActivityListReposStarredByAuthenticatedUserRequest(args [ // // GET /users/{username}/subscriptions func (s *Server) handleActivityListReposWatchedByUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-repos-watched-by-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12147,7 +15039,16 @@ func (s *Server) handleActivityListReposWatchedByUserRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12159,8 +15060,27 @@ func (s *Server) handleActivityListReposWatchedByUserRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12246,6 +15166,8 @@ func (s *Server) handleActivityListReposWatchedByUserRequest(args [1]string, arg // // GET /user/subscriptions func (s *Server) handleActivityListWatchedReposForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-watched-repos-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12267,7 +15189,16 @@ func (s *Server) handleActivityListWatchedReposForAuthenticatedUserRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12279,8 +15210,27 @@ func (s *Server) handleActivityListWatchedReposForAuthenticatedUserRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12362,6 +15312,8 @@ func (s *Server) handleActivityListWatchedReposForAuthenticatedUserRequest(args // // GET /repos/{owner}/{repo}/subscribers func (s *Server) handleActivityListWatchersForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/list-watchers-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12383,7 +15335,16 @@ func (s *Server) handleActivityListWatchersForRepoRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12395,8 +15356,27 @@ func (s *Server) handleActivityListWatchersForRepoRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12492,6 +15472,8 @@ func (s *Server) handleActivityListWatchersForRepoRequest(args [2]string, argsEs // // PUT /notifications func (s *Server) handleActivityMarkNotificationsAsReadRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/mark-notifications-as-read"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -12513,7 +15495,16 @@ func (s *Server) handleActivityMarkNotificationsAsReadRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12525,8 +15516,27 @@ func (s *Server) handleActivityMarkNotificationsAsReadRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12610,6 +15620,8 @@ func (s *Server) handleActivityMarkNotificationsAsReadRequest(args [0]string, ar // // PUT /repos/{owner}/{repo}/notifications func (s *Server) handleActivityMarkRepoNotificationsAsReadRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/mark-repo-notifications-as-read"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -12631,7 +15643,16 @@ func (s *Server) handleActivityMarkRepoNotificationsAsReadRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12643,8 +15664,27 @@ func (s *Server) handleActivityMarkRepoNotificationsAsReadRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12741,6 +15781,8 @@ func (s *Server) handleActivityMarkRepoNotificationsAsReadRequest(args [2]string // // PATCH /notifications/threads/{thread_id} func (s *Server) handleActivityMarkThreadAsReadRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/mark-thread-as-read"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -12762,7 +15804,16 @@ func (s *Server) handleActivityMarkThreadAsReadRequest(args [1]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12774,8 +15825,27 @@ func (s *Server) handleActivityMarkThreadAsReadRequest(args [1]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12856,6 +15926,8 @@ func (s *Server) handleActivityMarkThreadAsReadRequest(args [1]string, argsEscap // // PUT /repos/{owner}/{repo}/subscription func (s *Server) handleActivitySetRepoSubscriptionRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/set-repo-subscription"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -12877,7 +15949,16 @@ func (s *Server) handleActivitySetRepoSubscriptionRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12889,8 +15970,27 @@ func (s *Server) handleActivitySetRepoSubscriptionRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12994,6 +16094,8 @@ func (s *Server) handleActivitySetRepoSubscriptionRequest(args [2]string, argsEs // // PUT /notifications/threads/{thread_id}/subscription func (s *Server) handleActivitySetThreadSubscriptionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/set-thread-subscription"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -13015,7 +16117,16 @@ func (s *Server) handleActivitySetThreadSubscriptionRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13027,8 +16138,27 @@ func (s *Server) handleActivitySetThreadSubscriptionRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13123,6 +16253,8 @@ func (s *Server) handleActivitySetThreadSubscriptionRequest(args [1]string, args // // PUT /user/starred/{owner}/{repo} func (s *Server) handleActivityStarRepoForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/star-repo-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -13144,7 +16276,16 @@ func (s *Server) handleActivityStarRepoForAuthenticatedUserRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13156,8 +16297,27 @@ func (s *Server) handleActivityStarRepoForAuthenticatedUserRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13239,6 +16399,8 @@ func (s *Server) handleActivityStarRepoForAuthenticatedUserRequest(args [2]strin // // DELETE /user/starred/{owner}/{repo} func (s *Server) handleActivityUnstarRepoForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("activity/unstar-repo-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -13260,7 +16422,16 @@ func (s *Server) handleActivityUnstarRepoForAuthenticatedUserRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13272,8 +16443,27 @@ func (s *Server) handleActivityUnstarRepoForAuthenticatedUserRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13360,6 +16550,8 @@ func (s *Server) handleActivityUnstarRepoForAuthenticatedUserRequest(args [2]str // // PUT /user/installations/{installation_id}/repositories/{repository_id} func (s *Server) handleAppsAddRepoToInstallationRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/add-repo-to-installation"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -13381,7 +16573,16 @@ func (s *Server) handleAppsAddRepoToInstallationRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13393,8 +16594,27 @@ func (s *Server) handleAppsAddRepoToInstallationRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13481,6 +16701,8 @@ func (s *Server) handleAppsAddRepoToInstallationRequest(args [2]string, argsEsca // // POST /applications/{client_id}/token func (s *Server) handleAppsCheckTokenRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/check-token"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13502,7 +16724,16 @@ func (s *Server) handleAppsCheckTokenRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13514,8 +16745,27 @@ func (s *Server) handleAppsCheckTokenRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13617,6 +16867,8 @@ func (s *Server) handleAppsCheckTokenRequest(args [1]string, argsEscaped bool, w // // POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments func (s *Server) handleAppsCreateContentAttachmentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/create-content-attachment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13638,7 +16890,16 @@ func (s *Server) handleAppsCreateContentAttachmentRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13650,8 +16911,27 @@ func (s *Server) handleAppsCreateContentAttachmentRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13755,6 +17035,8 @@ func (s *Server) handleAppsCreateContentAttachmentRequest(args [3]string, argsEs // // POST /app-manifests/{code}/conversions func (s *Server) handleAppsCreateFromManifestRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/create-from-manifest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13776,7 +17058,16 @@ func (s *Server) handleAppsCreateFromManifestRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13788,8 +17079,27 @@ func (s *Server) handleAppsCreateFromManifestRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13891,6 +17201,8 @@ func (s *Server) handleAppsCreateFromManifestRequest(args [1]string, argsEscaped // // POST /app/installations/{installation_id}/access_tokens func (s *Server) handleAppsCreateInstallationAccessTokenRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/create-installation-access-token"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13912,7 +17224,16 @@ func (s *Server) handleAppsCreateInstallationAccessTokenRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13924,8 +17245,27 @@ func (s *Server) handleAppsCreateInstallationAccessTokenRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14027,6 +17367,8 @@ func (s *Server) handleAppsCreateInstallationAccessTokenRequest(args [1]string, // // DELETE /applications/{client_id}/grant func (s *Server) handleAppsDeleteAuthorizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/delete-authorization"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -14048,7 +17390,16 @@ func (s *Server) handleAppsDeleteAuthorizationRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14060,8 +17411,27 @@ func (s *Server) handleAppsDeleteAuthorizationRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14159,6 +17529,8 @@ func (s *Server) handleAppsDeleteAuthorizationRequest(args [1]string, argsEscape // // DELETE /app/installations/{installation_id} func (s *Server) handleAppsDeleteInstallationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/delete-installation"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -14180,7 +17552,16 @@ func (s *Server) handleAppsDeleteInstallationRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14192,8 +17573,27 @@ func (s *Server) handleAppsDeleteInstallationRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14274,6 +17674,8 @@ func (s *Server) handleAppsDeleteInstallationRequest(args [1]string, argsEscaped // // DELETE /applications/{client_id}/token func (s *Server) handleAppsDeleteTokenRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/delete-token"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -14295,7 +17697,16 @@ func (s *Server) handleAppsDeleteTokenRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14307,8 +17718,27 @@ func (s *Server) handleAppsDeleteTokenRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14408,6 +17838,8 @@ func (s *Server) handleAppsDeleteTokenRequest(args [1]string, argsEscaped bool, // // GET /app func (s *Server) handleAppsGetAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/get-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14429,7 +17861,16 @@ func (s *Server) handleAppsGetAuthenticatedRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14441,8 +17882,27 @@ func (s *Server) handleAppsGetAuthenticatedRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -14508,6 +17968,8 @@ func (s *Server) handleAppsGetAuthenticatedRequest(args [0]string, argsEscaped b // // GET /apps/{app_slug} func (s *Server) handleAppsGetBySlugRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/get-by-slug"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14529,7 +17991,16 @@ func (s *Server) handleAppsGetBySlugRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14541,8 +18012,27 @@ func (s *Server) handleAppsGetBySlugRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14627,6 +18117,8 @@ func (s *Server) handleAppsGetBySlugRequest(args [1]string, argsEscaped bool, w // // GET /marketplace_listing/accounts/{account_id} func (s *Server) handleAppsGetSubscriptionPlanForAccountRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/get-subscription-plan-for-account"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14648,7 +18140,16 @@ func (s *Server) handleAppsGetSubscriptionPlanForAccountRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14660,8 +18161,27 @@ func (s *Server) handleAppsGetSubscriptionPlanForAccountRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14746,6 +18266,8 @@ func (s *Server) handleAppsGetSubscriptionPlanForAccountRequest(args [1]string, // // GET /marketplace_listing/stubbed/accounts/{account_id} func (s *Server) handleAppsGetSubscriptionPlanForAccountStubbedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/get-subscription-plan-for-account-stubbed"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14767,7 +18289,16 @@ func (s *Server) handleAppsGetSubscriptionPlanForAccountStubbedRequest(args [1]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14779,8 +18310,27 @@ func (s *Server) handleAppsGetSubscriptionPlanForAccountStubbedRequest(args [1]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14862,6 +18412,8 @@ func (s *Server) handleAppsGetSubscriptionPlanForAccountStubbedRequest(args [1]s // // GET /app/hook/config func (s *Server) handleAppsGetWebhookConfigForAppRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/get-webhook-config-for-app"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14883,7 +18435,16 @@ func (s *Server) handleAppsGetWebhookConfigForAppRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14895,8 +18456,27 @@ func (s *Server) handleAppsGetWebhookConfigForAppRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -14958,6 +18538,8 @@ func (s *Server) handleAppsGetWebhookConfigForAppRequest(args [0]string, argsEsc // // GET /app/hook/deliveries/{delivery_id} func (s *Server) handleAppsGetWebhookDeliveryRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/get-webhook-delivery"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14979,7 +18561,16 @@ func (s *Server) handleAppsGetWebhookDeliveryRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14991,8 +18582,27 @@ func (s *Server) handleAppsGetWebhookDeliveryRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15078,6 +18688,8 @@ func (s *Server) handleAppsGetWebhookDeliveryRequest(args [1]string, argsEscaped // // GET /marketplace_listing/plans/{plan_id}/accounts func (s *Server) handleAppsListAccountsForPlanRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-accounts-for-plan"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15099,7 +18711,16 @@ func (s *Server) handleAppsListAccountsForPlanRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15111,8 +18732,27 @@ func (s *Server) handleAppsListAccountsForPlanRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15214,6 +18854,8 @@ func (s *Server) handleAppsListAccountsForPlanRequest(args [1]string, argsEscape // // GET /marketplace_listing/stubbed/plans/{plan_id}/accounts func (s *Server) handleAppsListAccountsForPlanStubbedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-accounts-for-plan-stubbed"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15235,7 +18877,16 @@ func (s *Server) handleAppsListAccountsForPlanStubbedRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15247,8 +18898,27 @@ func (s *Server) handleAppsListAccountsForPlanStubbedRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15348,6 +19018,8 @@ func (s *Server) handleAppsListAccountsForPlanStubbedRequest(args [1]string, arg // // GET /user/installations/{installation_id}/repositories func (s *Server) handleAppsListInstallationReposForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-installation-repos-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15369,7 +19041,16 @@ func (s *Server) handleAppsListInstallationReposForAuthenticatedUserRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15381,8 +19062,27 @@ func (s *Server) handleAppsListInstallationReposForAuthenticatedUserRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15473,6 +19173,8 @@ func (s *Server) handleAppsListInstallationReposForAuthenticatedUserRequest(args // // GET /marketplace_listing/plans func (s *Server) handleAppsListPlansRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-plans"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15494,7 +19196,16 @@ func (s *Server) handleAppsListPlansRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15506,8 +19217,27 @@ func (s *Server) handleAppsListPlansRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15594,6 +19324,8 @@ func (s *Server) handleAppsListPlansRequest(args [0]string, argsEscaped bool, w // // GET /marketplace_listing/stubbed/plans func (s *Server) handleAppsListPlansStubbedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-plans-stubbed"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15615,7 +19347,16 @@ func (s *Server) handleAppsListPlansStubbedRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15627,8 +19368,27 @@ func (s *Server) handleAppsListPlansStubbedRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15713,6 +19473,8 @@ func (s *Server) handleAppsListPlansStubbedRequest(args [0]string, argsEscaped b // // GET /installation/repositories func (s *Server) handleAppsListReposAccessibleToInstallationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-repos-accessible-to-installation"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15734,7 +19496,16 @@ func (s *Server) handleAppsListReposAccessibleToInstallationRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15746,8 +19517,27 @@ func (s *Server) handleAppsListReposAccessibleToInstallationRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15831,6 +19621,8 @@ func (s *Server) handleAppsListReposAccessibleToInstallationRequest(args [0]stri // // GET /user/marketplace_purchases func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-subscriptions-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15852,7 +19644,16 @@ func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15864,8 +19665,27 @@ func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15949,6 +19769,8 @@ func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserRequest(args [0] // // GET /user/marketplace_purchases/stubbed func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserStubbedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-subscriptions-for-authenticated-user-stubbed"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15970,7 +19792,16 @@ func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserStubbedRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15982,8 +19813,27 @@ func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserStubbedRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16068,6 +19918,8 @@ func (s *Server) handleAppsListSubscriptionsForAuthenticatedUserStubbedRequest(a // // GET /app/hook/deliveries func (s *Server) handleAppsListWebhookDeliveriesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/list-webhook-deliveries"), semconv.HTTPRequestMethodKey.String("GET"), @@ -16089,7 +19941,16 @@ func (s *Server) handleAppsListWebhookDeliveriesRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16101,8 +19962,27 @@ func (s *Server) handleAppsListWebhookDeliveriesRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16187,6 +20067,8 @@ func (s *Server) handleAppsListWebhookDeliveriesRequest(args [0]string, argsEsca // // POST /app/hook/deliveries/{delivery_id}/attempts func (s *Server) handleAppsRedeliverWebhookDeliveryRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/redeliver-webhook-delivery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16208,7 +20090,16 @@ func (s *Server) handleAppsRedeliverWebhookDeliveryRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16220,8 +20111,27 @@ func (s *Server) handleAppsRedeliverWebhookDeliveryRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16304,6 +20214,8 @@ func (s *Server) handleAppsRedeliverWebhookDeliveryRequest(args [1]string, argsE // // DELETE /user/installations/{installation_id}/repositories/{repository_id} func (s *Server) handleAppsRemoveRepoFromInstallationRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/remove-repo-from-installation"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -16325,7 +20237,16 @@ func (s *Server) handleAppsRemoveRepoFromInstallationRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16337,8 +20258,27 @@ func (s *Server) handleAppsRemoveRepoFromInstallationRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16425,6 +20365,8 @@ func (s *Server) handleAppsRemoveRepoFromInstallationRequest(args [2]string, arg // // PATCH /applications/{client_id}/token func (s *Server) handleAppsResetTokenRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/reset-token"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -16446,7 +20388,16 @@ func (s *Server) handleAppsResetTokenRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16458,8 +20409,27 @@ func (s *Server) handleAppsResetTokenRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16561,6 +20531,8 @@ func (s *Server) handleAppsResetTokenRequest(args [1]string, argsEscaped bool, w // // DELETE /installation/token func (s *Server) handleAppsRevokeInstallationAccessTokenRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/revoke-installation-access-token"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -16582,7 +20554,16 @@ func (s *Server) handleAppsRevokeInstallationAccessTokenRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16594,8 +20575,27 @@ func (s *Server) handleAppsRevokeInstallationAccessTokenRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -16659,6 +20659,8 @@ func (s *Server) handleAppsRevokeInstallationAccessTokenRequest(args [0]string, // // POST /applications/{client_id}/token/scoped func (s *Server) handleAppsScopeTokenRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/scope-token"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16680,7 +20682,16 @@ func (s *Server) handleAppsScopeTokenRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16692,8 +20703,27 @@ func (s *Server) handleAppsScopeTokenRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16791,6 +20821,8 @@ func (s *Server) handleAppsScopeTokenRequest(args [1]string, argsEscaped bool, w // // PUT /app/installations/{installation_id}/suspended func (s *Server) handleAppsSuspendInstallationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/suspend-installation"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -16812,7 +20844,16 @@ func (s *Server) handleAppsSuspendInstallationRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16824,8 +20865,27 @@ func (s *Server) handleAppsSuspendInstallationRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16906,6 +20966,8 @@ func (s *Server) handleAppsSuspendInstallationRequest(args [1]string, argsEscape // // DELETE /app/installations/{installation_id}/suspended func (s *Server) handleAppsUnsuspendInstallationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/unsuspend-installation"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -16927,7 +20989,16 @@ func (s *Server) handleAppsUnsuspendInstallationRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16939,8 +21010,27 @@ func (s *Server) handleAppsUnsuspendInstallationRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17022,6 +21112,8 @@ func (s *Server) handleAppsUnsuspendInstallationRequest(args [1]string, argsEsca // // PATCH /app/hook/config func (s *Server) handleAppsUpdateWebhookConfigForAppRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("apps/update-webhook-config-for-app"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -17043,7 +21135,16 @@ func (s *Server) handleAppsUpdateWebhookConfigForAppRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17055,8 +21156,27 @@ func (s *Server) handleAppsUpdateWebhookConfigForAppRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17141,6 +21261,8 @@ func (s *Server) handleAppsUpdateWebhookConfigForAppRequest(args [0]string, args // // GET /enterprises/{enterprise}/settings/billing/actions func (s *Server) handleBillingGetGithubActionsBillingGheRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-github-actions-billing-ghe"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17162,7 +21284,16 @@ func (s *Server) handleBillingGetGithubActionsBillingGheRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17174,8 +21305,27 @@ func (s *Server) handleBillingGetGithubActionsBillingGheRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17260,6 +21410,8 @@ func (s *Server) handleBillingGetGithubActionsBillingGheRequest(args [1]string, // // GET /orgs/{org}/settings/billing/actions func (s *Server) handleBillingGetGithubActionsBillingOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-github-actions-billing-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17281,7 +21433,16 @@ func (s *Server) handleBillingGetGithubActionsBillingOrgRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17293,8 +21454,27 @@ func (s *Server) handleBillingGetGithubActionsBillingOrgRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17379,6 +21559,8 @@ func (s *Server) handleBillingGetGithubActionsBillingOrgRequest(args [1]string, // // GET /users/{username}/settings/billing/actions func (s *Server) handleBillingGetGithubActionsBillingUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-github-actions-billing-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17400,7 +21582,16 @@ func (s *Server) handleBillingGetGithubActionsBillingUserRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17412,8 +21603,27 @@ func (s *Server) handleBillingGetGithubActionsBillingUserRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17495,6 +21705,8 @@ func (s *Server) handleBillingGetGithubActionsBillingUserRequest(args [1]string, // // GET /enterprises/{enterprise}/settings/billing/packages func (s *Server) handleBillingGetGithubPackagesBillingGheRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-github-packages-billing-ghe"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17516,7 +21728,16 @@ func (s *Server) handleBillingGetGithubPackagesBillingGheRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17528,8 +21749,27 @@ func (s *Server) handleBillingGetGithubPackagesBillingGheRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17611,6 +21851,8 @@ func (s *Server) handleBillingGetGithubPackagesBillingGheRequest(args [1]string, // // GET /orgs/{org}/settings/billing/packages func (s *Server) handleBillingGetGithubPackagesBillingOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-github-packages-billing-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17632,7 +21874,16 @@ func (s *Server) handleBillingGetGithubPackagesBillingOrgRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17644,8 +21895,27 @@ func (s *Server) handleBillingGetGithubPackagesBillingOrgRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17727,6 +21997,8 @@ func (s *Server) handleBillingGetGithubPackagesBillingOrgRequest(args [1]string, // // GET /users/{username}/settings/billing/packages func (s *Server) handleBillingGetGithubPackagesBillingUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-github-packages-billing-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17748,7 +22020,16 @@ func (s *Server) handleBillingGetGithubPackagesBillingUserRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17760,8 +22041,27 @@ func (s *Server) handleBillingGetGithubPackagesBillingUserRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17843,6 +22143,8 @@ func (s *Server) handleBillingGetGithubPackagesBillingUserRequest(args [1]string // // GET /enterprises/{enterprise}/settings/billing/shared-storage func (s *Server) handleBillingGetSharedStorageBillingGheRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-shared-storage-billing-ghe"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17864,7 +22166,16 @@ func (s *Server) handleBillingGetSharedStorageBillingGheRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17876,8 +22187,27 @@ func (s *Server) handleBillingGetSharedStorageBillingGheRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17959,6 +22289,8 @@ func (s *Server) handleBillingGetSharedStorageBillingGheRequest(args [1]string, // // GET /orgs/{org}/settings/billing/shared-storage func (s *Server) handleBillingGetSharedStorageBillingOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-shared-storage-billing-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17980,7 +22312,16 @@ func (s *Server) handleBillingGetSharedStorageBillingOrgRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17992,8 +22333,27 @@ func (s *Server) handleBillingGetSharedStorageBillingOrgRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18075,6 +22435,8 @@ func (s *Server) handleBillingGetSharedStorageBillingOrgRequest(args [1]string, // // GET /users/{username}/settings/billing/shared-storage func (s *Server) handleBillingGetSharedStorageBillingUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("billing/get-shared-storage-billing-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18096,7 +22458,16 @@ func (s *Server) handleBillingGetSharedStorageBillingUserRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18108,8 +22479,27 @@ func (s *Server) handleBillingGetSharedStorageBillingUserRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18195,6 +22585,8 @@ func (s *Server) handleBillingGetSharedStorageBillingUserRequest(args [1]string, // // POST /repos/{owner}/{repo}/check-suites func (s *Server) handleChecksCreateSuiteRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/create-suite"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18216,7 +22608,16 @@ func (s *Server) handleChecksCreateSuiteRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18228,8 +22629,27 @@ func (s *Server) handleChecksCreateSuiteRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18331,6 +22751,8 @@ func (s *Server) handleChecksCreateSuiteRequest(args [2]string, argsEscaped bool // // GET /repos/{owner}/{repo}/check-runs/{check_run_id} func (s *Server) handleChecksGetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18352,7 +22774,16 @@ func (s *Server) handleChecksGetRequest(args [3]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18364,8 +22795,27 @@ func (s *Server) handleChecksGetRequest(args [3]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18456,6 +22906,8 @@ func (s *Server) handleChecksGetRequest(args [3]string, argsEscaped bool, w http // // GET /repos/{owner}/{repo}/check-suites/{check_suite_id} func (s *Server) handleChecksGetSuiteRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/get-suite"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18477,7 +22929,16 @@ func (s *Server) handleChecksGetSuiteRequest(args [3]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18489,8 +22950,27 @@ func (s *Server) handleChecksGetSuiteRequest(args [3]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18579,6 +23059,8 @@ func (s *Server) handleChecksGetSuiteRequest(args [3]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations func (s *Server) handleChecksListAnnotationsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/list-annotations"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18600,7 +23082,16 @@ func (s *Server) handleChecksListAnnotationsRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18612,8 +23103,27 @@ func (s *Server) handleChecksListAnnotationsRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18713,6 +23223,8 @@ func (s *Server) handleChecksListAnnotationsRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/commits/{ref}/check-runs func (s *Server) handleChecksListForRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/list-for-ref"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18734,7 +23246,16 @@ func (s *Server) handleChecksListForRefRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18746,8 +23267,27 @@ func (s *Server) handleChecksListForRefRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18862,6 +23402,8 @@ func (s *Server) handleChecksListForRefRequest(args [3]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs func (s *Server) handleChecksListForSuiteRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/list-for-suite"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18883,7 +23425,16 @@ func (s *Server) handleChecksListForSuiteRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18895,8 +23446,27 @@ func (s *Server) handleChecksListForSuiteRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19008,6 +23578,8 @@ func (s *Server) handleChecksListForSuiteRequest(args [3]string, argsEscaped boo // // GET /repos/{owner}/{repo}/commits/{ref}/check-suites func (s *Server) handleChecksListSuitesForRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/list-suites-for-ref"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19029,7 +23601,16 @@ func (s *Server) handleChecksListSuitesForRefRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19041,8 +23622,27 @@ func (s *Server) handleChecksListSuitesForRefRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19149,6 +23749,8 @@ func (s *Server) handleChecksListSuitesForRefRequest(args [3]string, argsEscaped // // POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest func (s *Server) handleChecksRerequestSuiteRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/rerequest-suite"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19170,7 +23772,16 @@ func (s *Server) handleChecksRerequestSuiteRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19182,8 +23793,27 @@ func (s *Server) handleChecksRerequestSuiteRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19273,6 +23903,8 @@ func (s *Server) handleChecksRerequestSuiteRequest(args [3]string, argsEscaped b // // PATCH /repos/{owner}/{repo}/check-suites/preferences func (s *Server) handleChecksSetSuitesPreferencesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("checks/set-suites-preferences"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -19294,7 +23926,16 @@ func (s *Server) handleChecksSetSuitesPreferencesRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19306,8 +23947,27 @@ func (s *Server) handleChecksSetSuitesPreferencesRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19462,6 +24122,8 @@ func (s *Server) handleChecksSetSuitesPreferencesRequest(args [2]string, argsEsc // // DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id} func (s *Server) handleCodeScanningDeleteAnalysisRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/delete-analysis"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -19483,7 +24145,16 @@ func (s *Server) handleCodeScanningDeleteAnalysisRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19495,8 +24166,27 @@ func (s *Server) handleCodeScanningDeleteAnalysisRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19592,6 +24282,8 @@ func (s *Server) handleCodeScanningDeleteAnalysisRequest(args [3]string, argsEsc // // GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number} func (s *Server) handleCodeScanningGetAlertRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/get-alert"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19613,7 +24305,16 @@ func (s *Server) handleCodeScanningGetAlertRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19625,8 +24326,27 @@ func (s *Server) handleCodeScanningGetAlertRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19730,6 +24450,8 @@ func (s *Server) handleCodeScanningGetAlertRequest(args [3]string, argsEscaped b // // GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id} func (s *Server) handleCodeScanningGetAnalysisRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/get-analysis"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19751,7 +24473,16 @@ func (s *Server) handleCodeScanningGetAnalysisRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19763,8 +24494,27 @@ func (s *Server) handleCodeScanningGetAnalysisRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19855,6 +24605,8 @@ func (s *Server) handleCodeScanningGetAnalysisRequest(args [3]string, argsEscape // // GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id} func (s *Server) handleCodeScanningGetSarifRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/get-sarif"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19876,7 +24628,16 @@ func (s *Server) handleCodeScanningGetSarifRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19888,8 +24649,27 @@ func (s *Server) handleCodeScanningGetSarifRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19977,6 +24757,8 @@ func (s *Server) handleCodeScanningGetSarifRequest(args [3]string, argsEscaped b // // GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances func (s *Server) handleCodeScanningListAlertInstancesRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/list-alert-instances"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19998,7 +24780,16 @@ func (s *Server) handleCodeScanningListAlertInstancesRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20010,8 +24801,27 @@ func (s *Server) handleCodeScanningListAlertInstancesRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20116,6 +24926,8 @@ func (s *Server) handleCodeScanningListAlertInstancesRequest(args [3]string, arg // // GET /repos/{owner}/{repo}/code-scanning/alerts func (s *Server) handleCodeScanningListAlertsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/list-alerts-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20137,7 +24949,16 @@ func (s *Server) handleCodeScanningListAlertsForRepoRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20149,8 +24970,27 @@ func (s *Server) handleCodeScanningListAlertsForRepoRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20270,6 +25110,8 @@ func (s *Server) handleCodeScanningListAlertsForRepoRequest(args [2]string, args // // GET /repos/{owner}/{repo}/code-scanning/analyses func (s *Server) handleCodeScanningListRecentAnalysesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/list-recent-analyses"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20291,7 +25133,16 @@ func (s *Server) handleCodeScanningListRecentAnalysesRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20303,8 +25154,27 @@ func (s *Server) handleCodeScanningListRecentAnalysesRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20412,6 +25282,8 @@ func (s *Server) handleCodeScanningListRecentAnalysesRequest(args [2]string, arg // // PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number} func (s *Server) handleCodeScanningUpdateAlertRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/update-alert"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -20433,7 +25305,16 @@ func (s *Server) handleCodeScanningUpdateAlertRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20445,8 +25326,27 @@ func (s *Server) handleCodeScanningUpdateAlertRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20573,6 +25473,8 @@ func (s *Server) handleCodeScanningUpdateAlertRequest(args [3]string, argsEscape // // POST /repos/{owner}/{repo}/code-scanning/sarifs func (s *Server) handleCodeScanningUploadSarifRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("code-scanning/upload-sarif"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20594,7 +25496,16 @@ func (s *Server) handleCodeScanningUploadSarifRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20606,8 +25517,27 @@ func (s *Server) handleCodeScanningUploadSarifRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20704,6 +25634,8 @@ func (s *Server) handleCodeScanningUploadSarifRequest(args [2]string, argsEscape // // GET /codes_of_conduct func (s *Server) handleCodesOfConductGetAllCodesOfConductRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("codes-of-conduct/get-all-codes-of-conduct"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20725,7 +25657,16 @@ func (s *Server) handleCodesOfConductGetAllCodesOfConductRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20737,8 +25678,27 @@ func (s *Server) handleCodesOfConductGetAllCodesOfConductRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -20797,6 +25757,8 @@ func (s *Server) handleCodesOfConductGetAllCodesOfConductRequest(args [0]string, // // GET /codes_of_conduct/{key} func (s *Server) handleCodesOfConductGetConductCodeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("codes-of-conduct/get-conduct-code"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20818,7 +25780,16 @@ func (s *Server) handleCodesOfConductGetConductCodeRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20830,8 +25801,27 @@ func (s *Server) handleCodesOfConductGetConductCodeRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20909,6 +25899,8 @@ func (s *Server) handleCodesOfConductGetConductCodeRequest(args [1]string, argsE // // GET /emojis func (s *Server) handleEmojisGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("emojis/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20930,7 +25922,16 @@ func (s *Server) handleEmojisGetRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20942,8 +25943,27 @@ func (s *Server) handleEmojisGetRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -21006,6 +26026,8 @@ func (s *Server) handleEmojisGetRequest(args [0]string, argsEscaped bool, w http // // PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations/{org_id} func (s *Server) handleEnterpriseAdminAddOrgAccessToSelfHostedRunnerGroupInEnterpriseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/add-org-access-to-self-hosted-runner-group-in-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -21027,7 +26049,16 @@ func (s *Server) handleEnterpriseAdminAddOrgAccessToSelfHostedRunnerGroupInEnter startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21039,8 +26070,27 @@ func (s *Server) handleEnterpriseAdminAddOrgAccessToSelfHostedRunnerGroupInEnter var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21128,6 +26178,8 @@ func (s *Server) handleEnterpriseAdminAddOrgAccessToSelfHostedRunnerGroupInEnter // // PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners/{runner_id} func (s *Server) handleEnterpriseAdminAddSelfHostedRunnerToGroupForEnterpriseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/add-self-hosted-runner-to-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -21149,7 +26201,16 @@ func (s *Server) handleEnterpriseAdminAddSelfHostedRunnerToGroupForEnterpriseReq startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21161,8 +26222,27 @@ func (s *Server) handleEnterpriseAdminAddSelfHostedRunnerToGroupForEnterpriseReq var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21255,6 +26335,8 @@ func (s *Server) handleEnterpriseAdminAddSelfHostedRunnerToGroupForEnterpriseReq // // POST /enterprises/{enterprise}/actions/runners/registration-token func (s *Server) handleEnterpriseAdminCreateRegistrationTokenForEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/create-registration-token-for-enterprise"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21276,7 +26358,16 @@ func (s *Server) handleEnterpriseAdminCreateRegistrationTokenForEnterpriseReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21288,8 +26379,27 @@ func (s *Server) handleEnterpriseAdminCreateRegistrationTokenForEnterpriseReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21376,6 +26486,8 @@ func (s *Server) handleEnterpriseAdminCreateRegistrationTokenForEnterpriseReques // // POST /enterprises/{enterprise}/actions/runners/remove-token func (s *Server) handleEnterpriseAdminCreateRemoveTokenForEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/create-remove-token-for-enterprise"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21397,7 +26509,16 @@ func (s *Server) handleEnterpriseAdminCreateRemoveTokenForEnterpriseRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21409,8 +26530,27 @@ func (s *Server) handleEnterpriseAdminCreateRemoveTokenForEnterpriseRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21489,6 +26629,8 @@ func (s *Server) handleEnterpriseAdminCreateRemoveTokenForEnterpriseRequest(args // // POST /enterprises/{enterprise}/actions/runner-groups func (s *Server) handleEnterpriseAdminCreateSelfHostedRunnerGroupForEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/create-self-hosted-runner-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21510,7 +26652,16 @@ func (s *Server) handleEnterpriseAdminCreateSelfHostedRunnerGroupForEnterpriseRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21522,8 +26673,27 @@ func (s *Server) handleEnterpriseAdminCreateSelfHostedRunnerGroupForEnterpriseRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21617,6 +26787,8 @@ func (s *Server) handleEnterpriseAdminCreateSelfHostedRunnerGroupForEnterpriseRe // // DELETE /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id} func (s *Server) handleEnterpriseAdminDeleteScimGroupFromEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/delete-scim-group-from-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -21638,7 +26810,16 @@ func (s *Server) handleEnterpriseAdminDeleteScimGroupFromEnterpriseRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21650,8 +26831,27 @@ func (s *Server) handleEnterpriseAdminDeleteScimGroupFromEnterpriseRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21735,6 +26935,8 @@ func (s *Server) handleEnterpriseAdminDeleteScimGroupFromEnterpriseRequest(args // // DELETE /enterprises/{enterprise}/actions/runners/{runner_id} func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerFromEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/delete-self-hosted-runner-from-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -21756,7 +26958,16 @@ func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerFromEnterpriseReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21768,8 +26979,27 @@ func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerFromEnterpriseReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21852,6 +27082,8 @@ func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerFromEnterpriseReques // // DELETE /enterprises/{enterprise}/actions/runner-groups/{runner_group_id} func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerGroupFromEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/delete-self-hosted-runner-group-from-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -21873,7 +27105,16 @@ func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerGroupFromEnterpriseR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21885,8 +27126,27 @@ func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerGroupFromEnterpriseR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21969,6 +27229,8 @@ func (s *Server) handleEnterpriseAdminDeleteSelfHostedRunnerGroupFromEnterpriseR // // DELETE /scim/v2/enterprises/{enterprise}/Users/{scim_user_id} func (s *Server) handleEnterpriseAdminDeleteUserFromEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/delete-user-from-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -21990,7 +27252,16 @@ func (s *Server) handleEnterpriseAdminDeleteUserFromEnterpriseRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22002,8 +27273,27 @@ func (s *Server) handleEnterpriseAdminDeleteUserFromEnterpriseRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22089,6 +27379,8 @@ func (s *Server) handleEnterpriseAdminDeleteUserFromEnterpriseRequest(args [2]st // // DELETE /enterprises/{enterprise}/actions/permissions/organizations/{org_id} func (s *Server) handleEnterpriseAdminDisableSelectedOrganizationGithubActionsEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/disable-selected-organization-github-actions-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -22110,7 +27402,16 @@ func (s *Server) handleEnterpriseAdminDisableSelectedOrganizationGithubActionsEn startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22122,8 +27423,27 @@ func (s *Server) handleEnterpriseAdminDisableSelectedOrganizationGithubActionsEn var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22209,6 +27529,8 @@ func (s *Server) handleEnterpriseAdminDisableSelectedOrganizationGithubActionsEn // // PUT /enterprises/{enterprise}/actions/permissions/organizations/{org_id} func (s *Server) handleEnterpriseAdminEnableSelectedOrganizationGithubActionsEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/enable-selected-organization-github-actions-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -22230,7 +27552,16 @@ func (s *Server) handleEnterpriseAdminEnableSelectedOrganizationGithubActionsEnt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22242,8 +27573,27 @@ func (s *Server) handleEnterpriseAdminEnableSelectedOrganizationGithubActionsEnt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22329,6 +27679,8 @@ func (s *Server) handleEnterpriseAdminEnableSelectedOrganizationGithubActionsEnt // // GET /enterprises/{enterprise}/actions/permissions/selected-actions func (s *Server) handleEnterpriseAdminGetAllowedActionsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-allowed-actions-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22350,7 +27702,16 @@ func (s *Server) handleEnterpriseAdminGetAllowedActionsEnterpriseRequest(args [1 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22362,8 +27723,27 @@ func (s *Server) handleEnterpriseAdminGetAllowedActionsEnterpriseRequest(args [1 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22442,6 +27822,8 @@ func (s *Server) handleEnterpriseAdminGetAllowedActionsEnterpriseRequest(args [1 // // GET /enterprises/{enterprise}/audit-log func (s *Server) handleEnterpriseAdminGetAuditLogRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-audit-log"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22463,7 +27845,16 @@ func (s *Server) handleEnterpriseAdminGetAuditLogRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22475,8 +27866,27 @@ func (s *Server) handleEnterpriseAdminGetAuditLogRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22583,6 +27993,8 @@ func (s *Server) handleEnterpriseAdminGetAuditLogRequest(args [1]string, argsEsc // // GET /enterprises/{enterprise}/actions/permissions func (s *Server) handleEnterpriseAdminGetGithubActionsPermissionsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-github-actions-permissions-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22604,7 +28016,16 @@ func (s *Server) handleEnterpriseAdminGetGithubActionsPermissionsEnterpriseReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22616,8 +28037,27 @@ func (s *Server) handleEnterpriseAdminGetGithubActionsPermissionsEnterpriseReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22696,6 +28136,8 @@ func (s *Server) handleEnterpriseAdminGetGithubActionsPermissionsEnterpriseReque // // GET /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id} func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseGroupRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-provisioning-information-for-enterprise-group"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22717,7 +28159,16 @@ func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseGro startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22729,8 +28180,27 @@ func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseGro var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22817,6 +28287,8 @@ func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseGro // // GET /scim/v2/enterprises/{enterprise}/Users/{scim_user_id} func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-provisioning-information-for-enterprise-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22838,7 +28310,16 @@ func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseUse startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22850,8 +28331,27 @@ func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseUse var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22934,6 +28434,8 @@ func (s *Server) handleEnterpriseAdminGetProvisioningInformationForEnterpriseUse // // GET /enterprises/{enterprise}/actions/runners/{runner_id} func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerForEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-self-hosted-runner-for-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22955,7 +28457,16 @@ func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerForEnterpriseRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22967,8 +28478,27 @@ func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerForEnterpriseRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23051,6 +28581,8 @@ func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerForEnterpriseRequest(ar // // GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id} func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerGroupForEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/get-self-hosted-runner-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23072,7 +28604,16 @@ func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerGroupForEnterpriseReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23084,8 +28625,27 @@ func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerGroupForEnterpriseReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23168,6 +28728,8 @@ func (s *Server) handleEnterpriseAdminGetSelfHostedRunnerGroupForEnterpriseReque // // GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations func (s *Server) handleEnterpriseAdminListOrgAccessToSelfHostedRunnerGroupInEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-org-access-to-self-hosted-runner-group-in-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23189,7 +28751,16 @@ func (s *Server) handleEnterpriseAdminListOrgAccessToSelfHostedRunnerGroupInEnte startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23201,8 +28772,27 @@ func (s *Server) handleEnterpriseAdminListOrgAccessToSelfHostedRunnerGroupInEnte var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23293,6 +28883,8 @@ func (s *Server) handleEnterpriseAdminListOrgAccessToSelfHostedRunnerGroupInEnte // // GET /scim/v2/enterprises/{enterprise}/Groups func (s *Server) handleEnterpriseAdminListProvisionedGroupsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-provisioned-groups-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23314,7 +28906,16 @@ func (s *Server) handleEnterpriseAdminListProvisionedGroupsEnterpriseRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23326,8 +28927,27 @@ func (s *Server) handleEnterpriseAdminListProvisionedGroupsEnterpriseRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23447,6 +29067,8 @@ func (s *Server) handleEnterpriseAdminListProvisionedGroupsEnterpriseRequest(arg // // GET /scim/v2/enterprises/{enterprise}/Users func (s *Server) handleEnterpriseAdminListProvisionedIdentitiesEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-provisioned-identities-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23468,7 +29090,16 @@ func (s *Server) handleEnterpriseAdminListProvisionedIdentitiesEnterpriseRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23480,8 +29111,27 @@ func (s *Server) handleEnterpriseAdminListProvisionedIdentitiesEnterpriseRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23572,6 +29222,8 @@ func (s *Server) handleEnterpriseAdminListProvisionedIdentitiesEnterpriseRequest // // GET /enterprises/{enterprise}/actions/runners/downloads func (s *Server) handleEnterpriseAdminListRunnerApplicationsForEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-runner-applications-for-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23593,7 +29245,16 @@ func (s *Server) handleEnterpriseAdminListRunnerApplicationsForEnterpriseRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23605,8 +29266,27 @@ func (s *Server) handleEnterpriseAdminListRunnerApplicationsForEnterpriseRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23688,6 +29368,8 @@ func (s *Server) handleEnterpriseAdminListRunnerApplicationsForEnterpriseRequest // // GET /enterprises/{enterprise}/actions/permissions/organizations func (s *Server) handleEnterpriseAdminListSelectedOrganizationsEnabledGithubActionsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-selected-organizations-enabled-github-actions-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23709,7 +29391,16 @@ func (s *Server) handleEnterpriseAdminListSelectedOrganizationsEnabledGithubActi startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23721,8 +29412,27 @@ func (s *Server) handleEnterpriseAdminListSelectedOrganizationsEnabledGithubActi var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23809,6 +29519,8 @@ func (s *Server) handleEnterpriseAdminListSelectedOrganizationsEnabledGithubActi // // GET /enterprises/{enterprise}/actions/runner-groups func (s *Server) handleEnterpriseAdminListSelfHostedRunnerGroupsForEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-self-hosted-runner-groups-for-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23830,7 +29542,16 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnerGroupsForEnterpriseReq startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23842,8 +29563,27 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnerGroupsForEnterpriseReq var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23930,6 +29670,8 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnerGroupsForEnterpriseReq // // GET /enterprises/{enterprise}/actions/runners func (s *Server) handleEnterpriseAdminListSelfHostedRunnersForEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-self-hosted-runners-for-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23951,7 +29693,16 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnersForEnterpriseRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23963,8 +29714,27 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnersForEnterpriseRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24051,6 +29821,8 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnersForEnterpriseRequest( // // GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners func (s *Server) handleEnterpriseAdminListSelfHostedRunnersInGroupForEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/list-self-hosted-runners-in-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24072,7 +29844,16 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnersInGroupForEnterpriseR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24084,8 +29865,27 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnersInGroupForEnterpriseR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24179,6 +29979,8 @@ func (s *Server) handleEnterpriseAdminListSelfHostedRunnersInGroupForEnterpriseR // // POST /scim/v2/enterprises/{enterprise}/Groups func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseGroupRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/provision-and-invite-enterprise-group"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24200,7 +30002,16 @@ func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseGroupRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24212,8 +30023,27 @@ func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseGroupRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24312,6 +30142,8 @@ func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseGroupRequest(a // // POST /scim/v2/enterprises/{enterprise}/Users func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/provision-and-invite-enterprise-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24333,7 +30165,16 @@ func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseUserRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24345,8 +30186,27 @@ func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseUserRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24443,6 +30303,8 @@ func (s *Server) handleEnterpriseAdminProvisionAndInviteEnterpriseUserRequest(ar // // DELETE /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations/{org_id} func (s *Server) handleEnterpriseAdminRemoveOrgAccessToSelfHostedRunnerGroupInEnterpriseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/remove-org-access-to-self-hosted-runner-group-in-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -24464,7 +30326,16 @@ func (s *Server) handleEnterpriseAdminRemoveOrgAccessToSelfHostedRunnerGroupInEn startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24476,8 +30347,27 @@ func (s *Server) handleEnterpriseAdminRemoveOrgAccessToSelfHostedRunnerGroupInEn var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24565,6 +30455,8 @@ func (s *Server) handleEnterpriseAdminRemoveOrgAccessToSelfHostedRunnerGroupInEn // // DELETE /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners/{runner_id} func (s *Server) handleEnterpriseAdminRemoveSelfHostedRunnerFromGroupForEnterpriseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/remove-self-hosted-runner-from-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -24586,7 +30478,16 @@ func (s *Server) handleEnterpriseAdminRemoveSelfHostedRunnerFromGroupForEnterpri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24598,8 +30499,27 @@ func (s *Server) handleEnterpriseAdminRemoveSelfHostedRunnerFromGroupForEnterpri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24689,6 +30609,8 @@ func (s *Server) handleEnterpriseAdminRemoveSelfHostedRunnerFromGroupForEnterpri // // PUT /enterprises/{enterprise}/actions/permissions/selected-actions func (s *Server) handleEnterpriseAdminSetAllowedActionsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-allowed-actions-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -24710,7 +30632,16 @@ func (s *Server) handleEnterpriseAdminSetAllowedActionsEnterpriseRequest(args [1 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24722,8 +30653,27 @@ func (s *Server) handleEnterpriseAdminSetAllowedActionsEnterpriseRequest(args [1 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24817,6 +30767,8 @@ func (s *Server) handleEnterpriseAdminSetAllowedActionsEnterpriseRequest(args [1 // // PUT /enterprises/{enterprise}/actions/permissions func (s *Server) handleEnterpriseAdminSetGithubActionsPermissionsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-github-actions-permissions-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -24838,7 +30790,16 @@ func (s *Server) handleEnterpriseAdminSetGithubActionsPermissionsEnterpriseReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24850,8 +30811,27 @@ func (s *Server) handleEnterpriseAdminSetGithubActionsPermissionsEnterpriseReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24950,6 +30930,8 @@ func (s *Server) handleEnterpriseAdminSetGithubActionsPermissionsEnterpriseReque // // PUT /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id} func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseGroupRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-information-for-provisioned-enterprise-group"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -24971,7 +30953,16 @@ func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseGrou startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24983,8 +30974,27 @@ func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseGrou var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25090,6 +31100,8 @@ func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseGrou // // PUT /scim/v2/enterprises/{enterprise}/Users/{scim_user_id} func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-information-for-provisioned-enterprise-user"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -25111,7 +31123,16 @@ func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseUser startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25123,8 +31144,27 @@ func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseUser var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25223,6 +31263,8 @@ func (s *Server) handleEnterpriseAdminSetInformationForProvisionedEnterpriseUser // // PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations func (s *Server) handleEnterpriseAdminSetOrgAccessToSelfHostedRunnerGroupInEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-org-access-to-self-hosted-runner-group-in-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -25244,7 +31286,16 @@ func (s *Server) handleEnterpriseAdminSetOrgAccessToSelfHostedRunnerGroupInEnter startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25256,8 +31307,27 @@ func (s *Server) handleEnterpriseAdminSetOrgAccessToSelfHostedRunnerGroupInEnter var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25358,6 +31428,8 @@ func (s *Server) handleEnterpriseAdminSetOrgAccessToSelfHostedRunnerGroupInEnter // // PUT /enterprises/{enterprise}/actions/permissions/organizations func (s *Server) handleEnterpriseAdminSetSelectedOrganizationsEnabledGithubActionsEnterpriseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-selected-organizations-enabled-github-actions-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -25379,7 +31451,16 @@ func (s *Server) handleEnterpriseAdminSetSelectedOrganizationsEnabledGithubActio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25391,8 +31472,27 @@ func (s *Server) handleEnterpriseAdminSetSelectedOrganizationsEnabledGithubActio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25486,6 +31586,8 @@ func (s *Server) handleEnterpriseAdminSetSelectedOrganizationsEnabledGithubActio // // PUT /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners func (s *Server) handleEnterpriseAdminSetSelfHostedRunnersInGroupForEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/set-self-hosted-runners-in-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -25507,7 +31609,16 @@ func (s *Server) handleEnterpriseAdminSetSelfHostedRunnersInGroupForEnterpriseRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25519,8 +31630,27 @@ func (s *Server) handleEnterpriseAdminSetSelfHostedRunnersInGroupForEnterpriseRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25622,6 +31752,8 @@ func (s *Server) handleEnterpriseAdminSetSelfHostedRunnersInGroupForEnterpriseRe // // PATCH /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id} func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseGroupRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/update-attribute-for-enterprise-group"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -25643,7 +31775,16 @@ func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseGroupRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25655,8 +31796,27 @@ func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseGroupRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25775,6 +31935,8 @@ func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseGroupRequest(a // // PATCH /scim/v2/enterprises/{enterprise}/Users/{scim_user_id} func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/update-attribute-for-enterprise-user"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -25796,7 +31958,16 @@ func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseUserRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25808,8 +31979,27 @@ func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseUserRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25907,6 +32097,8 @@ func (s *Server) handleEnterpriseAdminUpdateAttributeForEnterpriseUserRequest(ar // // PATCH /enterprises/{enterprise}/actions/runner-groups/{runner_group_id} func (s *Server) handleEnterpriseAdminUpdateSelfHostedRunnerGroupForEnterpriseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("enterprise-admin/update-self-hosted-runner-group-for-enterprise"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -25928,7 +32120,16 @@ func (s *Server) handleEnterpriseAdminUpdateSelfHostedRunnerGroupForEnterpriseRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25940,8 +32141,27 @@ func (s *Server) handleEnterpriseAdminUpdateSelfHostedRunnerGroupForEnterpriseRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26038,6 +32258,8 @@ func (s *Server) handleEnterpriseAdminUpdateSelfHostedRunnerGroupForEnterpriseRe // // GET /gists/{gist_id}/star func (s *Server) handleGistsCheckIsStarredRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/check-is-starred"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26059,7 +32281,16 @@ func (s *Server) handleGistsCheckIsStarredRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26071,8 +32302,27 @@ func (s *Server) handleGistsCheckIsStarredRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26152,6 +32402,8 @@ func (s *Server) handleGistsCheckIsStarredRequest(args [1]string, argsEscaped bo // // POST /gists func (s *Server) handleGistsCreateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/create"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26173,7 +32425,16 @@ func (s *Server) handleGistsCreateRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26185,8 +32446,27 @@ func (s *Server) handleGistsCreateRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26264,6 +32544,8 @@ func (s *Server) handleGistsCreateRequest(args [0]string, argsEscaped bool, w ht // // POST /gists/{gist_id}/comments func (s *Server) handleGistsCreateCommentRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/create-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26285,7 +32567,16 @@ func (s *Server) handleGistsCreateCommentRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26297,8 +32588,27 @@ func (s *Server) handleGistsCreateCommentRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26391,6 +32701,8 @@ func (s *Server) handleGistsCreateCommentRequest(args [1]string, argsEscaped boo // // DELETE /gists/{gist_id} func (s *Server) handleGistsDeleteRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/delete"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -26412,7 +32724,16 @@ func (s *Server) handleGistsDeleteRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26424,8 +32745,27 @@ func (s *Server) handleGistsDeleteRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26503,6 +32843,8 @@ func (s *Server) handleGistsDeleteRequest(args [1]string, argsEscaped bool, w ht // // DELETE /gists/{gist_id}/comments/{comment_id} func (s *Server) handleGistsDeleteCommentRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/delete-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -26524,7 +32866,16 @@ func (s *Server) handleGistsDeleteCommentRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26536,8 +32887,27 @@ func (s *Server) handleGistsDeleteCommentRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26619,6 +32989,8 @@ func (s *Server) handleGistsDeleteCommentRequest(args [2]string, argsEscaped boo // // POST /gists/{gist_id}/forks func (s *Server) handleGistsForkRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/fork"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26640,7 +33012,16 @@ func (s *Server) handleGistsForkRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26652,8 +33033,27 @@ func (s *Server) handleGistsForkRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26731,6 +33131,8 @@ func (s *Server) handleGistsForkRequest(args [1]string, argsEscaped bool, w http // // GET /gists/{gist_id} func (s *Server) handleGistsGetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26752,7 +33154,16 @@ func (s *Server) handleGistsGetRequest(args [1]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26764,8 +33175,27 @@ func (s *Server) handleGistsGetRequest(args [1]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26843,6 +33273,8 @@ func (s *Server) handleGistsGetRequest(args [1]string, argsEscaped bool, w http. // // GET /gists/{gist_id}/comments/{comment_id} func (s *Server) handleGistsGetCommentRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/get-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26864,7 +33296,16 @@ func (s *Server) handleGistsGetCommentRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26876,8 +33317,27 @@ func (s *Server) handleGistsGetCommentRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26959,6 +33419,8 @@ func (s *Server) handleGistsGetCommentRequest(args [2]string, argsEscaped bool, // // GET /gists/{gist_id}/{sha} func (s *Server) handleGistsGetRevisionRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/get-revision"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26980,7 +33442,16 @@ func (s *Server) handleGistsGetRevisionRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26992,8 +33463,27 @@ func (s *Server) handleGistsGetRevisionRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27076,6 +33566,8 @@ func (s *Server) handleGistsGetRevisionRequest(args [2]string, argsEscaped bool, // // GET /gists func (s *Server) handleGistsListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27097,7 +33589,16 @@ func (s *Server) handleGistsListRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27109,8 +33610,27 @@ func (s *Server) handleGistsListRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27196,6 +33716,8 @@ func (s *Server) handleGistsListRequest(args [0]string, argsEscaped bool, w http // // GET /gists/{gist_id}/comments func (s *Server) handleGistsListCommentsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list-comments"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27217,7 +33739,16 @@ func (s *Server) handleGistsListCommentsRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27229,8 +33760,27 @@ func (s *Server) handleGistsListCommentsRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27316,6 +33866,8 @@ func (s *Server) handleGistsListCommentsRequest(args [1]string, argsEscaped bool // // GET /gists/{gist_id}/commits func (s *Server) handleGistsListCommitsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list-commits"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27337,7 +33889,16 @@ func (s *Server) handleGistsListCommitsRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27349,8 +33910,27 @@ func (s *Server) handleGistsListCommitsRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27436,6 +34016,8 @@ func (s *Server) handleGistsListCommitsRequest(args [1]string, argsEscaped bool, // // GET /users/{username}/gists func (s *Server) handleGistsListForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27457,7 +34039,16 @@ func (s *Server) handleGistsListForUserRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27469,8 +34060,27 @@ func (s *Server) handleGistsListForUserRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27560,6 +34170,8 @@ func (s *Server) handleGistsListForUserRequest(args [1]string, argsEscaped bool, // // GET /gists/{gist_id}/forks func (s *Server) handleGistsListForksRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list-forks"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27581,7 +34193,16 @@ func (s *Server) handleGistsListForksRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27593,8 +34214,27 @@ func (s *Server) handleGistsListForksRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27683,6 +34323,8 @@ func (s *Server) handleGistsListForksRequest(args [1]string, argsEscaped bool, w // // GET /gists/public func (s *Server) handleGistsListPublicRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list-public"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27704,7 +34346,16 @@ func (s *Server) handleGistsListPublicRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27716,8 +34367,27 @@ func (s *Server) handleGistsListPublicRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27803,6 +34473,8 @@ func (s *Server) handleGistsListPublicRequest(args [0]string, argsEscaped bool, // // GET /gists/starred func (s *Server) handleGistsListStarredRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/list-starred"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27824,7 +34496,16 @@ func (s *Server) handleGistsListStarredRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27836,8 +34517,27 @@ func (s *Server) handleGistsListStarredRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27925,6 +34625,8 @@ func (s *Server) handleGistsListStarredRequest(args [0]string, argsEscaped bool, // // PUT /gists/{gist_id}/star func (s *Server) handleGistsStarRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/star"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -27946,7 +34648,16 @@ func (s *Server) handleGistsStarRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27958,8 +34669,27 @@ func (s *Server) handleGistsStarRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28037,6 +34767,8 @@ func (s *Server) handleGistsStarRequest(args [1]string, argsEscaped bool, w http // // DELETE /gists/{gist_id}/star func (s *Server) handleGistsUnstarRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/unstar"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -28058,7 +34790,16 @@ func (s *Server) handleGistsUnstarRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28070,8 +34811,27 @@ func (s *Server) handleGistsUnstarRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28149,6 +34909,8 @@ func (s *Server) handleGistsUnstarRequest(args [1]string, argsEscaped bool, w ht // // PATCH /gists/{gist_id}/comments/{comment_id} func (s *Server) handleGistsUpdateCommentRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gists/update-comment"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -28170,7 +34932,16 @@ func (s *Server) handleGistsUpdateCommentRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28182,8 +34953,27 @@ func (s *Server) handleGistsUpdateCommentRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28280,6 +35070,8 @@ func (s *Server) handleGistsUpdateCommentRequest(args [2]string, argsEscaped boo // // POST /repos/{owner}/{repo}/git/blobs func (s *Server) handleGitCreateBlobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/create-blob"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28301,7 +35093,16 @@ func (s *Server) handleGitCreateBlobRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28313,8 +35114,27 @@ func (s *Server) handleGitCreateBlobRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28444,6 +35264,8 @@ func (s *Server) handleGitCreateBlobRequest(args [2]string, argsEscaped bool, w // // POST /repos/{owner}/{repo}/git/commits func (s *Server) handleGitCreateCommitRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/create-commit"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28465,7 +35287,16 @@ func (s *Server) handleGitCreateCommitRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28477,8 +35308,27 @@ func (s *Server) handleGitCreateCommitRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28577,6 +35427,8 @@ func (s *Server) handleGitCreateCommitRequest(args [2]string, argsEscaped bool, // // POST /repos/{owner}/{repo}/git/refs func (s *Server) handleGitCreateRefRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/create-ref"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28598,7 +35450,16 @@ func (s *Server) handleGitCreateRefRequest(args [2]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28610,8 +35471,27 @@ func (s *Server) handleGitCreateRefRequest(args [2]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28744,6 +35624,8 @@ func (s *Server) handleGitCreateRefRequest(args [2]string, argsEscaped bool, w h // // POST /repos/{owner}/{repo}/git/tags func (s *Server) handleGitCreateTagRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/create-tag"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28765,7 +35647,16 @@ func (s *Server) handleGitCreateTagRequest(args [2]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28777,8 +35668,27 @@ func (s *Server) handleGitCreateTagRequest(args [2]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28881,6 +35791,8 @@ func (s *Server) handleGitCreateTagRequest(args [2]string, argsEscaped bool, w h // // POST /repos/{owner}/{repo}/git/trees func (s *Server) handleGitCreateTreeRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/create-tree"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28902,7 +35814,16 @@ func (s *Server) handleGitCreateTreeRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28914,8 +35835,27 @@ func (s *Server) handleGitCreateTreeRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29012,6 +35952,8 @@ func (s *Server) handleGitCreateTreeRequest(args [2]string, argsEscaped bool, w // // DELETE /repos/{owner}/{repo}/git/refs/{ref} func (s *Server) handleGitDeleteRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/delete-ref"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -29033,7 +35975,16 @@ func (s *Server) handleGitDeleteRefRequest(args [3]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29045,8 +35996,27 @@ func (s *Server) handleGitDeleteRefRequest(args [3]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29133,6 +36103,8 @@ func (s *Server) handleGitDeleteRefRequest(args [3]string, argsEscaped bool, w h // // GET /repos/{owner}/{repo}/git/blobs/{file_sha} func (s *Server) handleGitGetBlobRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/get-blob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29154,7 +36126,16 @@ func (s *Server) handleGitGetBlobRequest(args [3]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29166,8 +36147,27 @@ func (s *Server) handleGitGetBlobRequest(args [3]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29286,6 +36286,8 @@ func (s *Server) handleGitGetBlobRequest(args [3]string, argsEscaped bool, w htt // // GET /repos/{owner}/{repo}/git/commits/{commit_sha} func (s *Server) handleGitGetCommitRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/get-commit"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29307,7 +36309,16 @@ func (s *Server) handleGitGetCommitRequest(args [3]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29319,8 +36330,27 @@ func (s *Server) handleGitGetCommitRequest(args [3]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29413,6 +36443,8 @@ func (s *Server) handleGitGetCommitRequest(args [3]string, argsEscaped bool, w h // // GET /repos/{owner}/{repo}/git/ref/{ref} func (s *Server) handleGitGetRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/get-ref"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29434,7 +36466,16 @@ func (s *Server) handleGitGetRefRequest(args [3]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29446,8 +36487,27 @@ func (s *Server) handleGitGetRefRequest(args [3]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29564,6 +36624,8 @@ func (s *Server) handleGitGetRefRequest(args [3]string, argsEscaped bool, w http // // GET /repos/{owner}/{repo}/git/tags/{tag_sha} func (s *Server) handleGitGetTagRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/get-tag"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29585,7 +36647,16 @@ func (s *Server) handleGitGetTagRequest(args [3]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29597,8 +36668,27 @@ func (s *Server) handleGitGetTagRequest(args [3]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29687,6 +36777,8 @@ func (s *Server) handleGitGetTagRequest(args [3]string, argsEscaped bool, w http // // GET /repos/{owner}/{repo}/git/trees/{tree_sha} func (s *Server) handleGitGetTreeRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/get-tree"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29708,7 +36800,16 @@ func (s *Server) handleGitGetTreeRequest(args [3]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29720,8 +36821,27 @@ func (s *Server) handleGitGetTreeRequest(args [3]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29825,6 +36945,8 @@ func (s *Server) handleGitGetTreeRequest(args [3]string, argsEscaped bool, w htt // // GET /repos/{owner}/{repo}/git/matching-refs/{ref} func (s *Server) handleGitListMatchingRefsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/list-matching-refs"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29846,7 +36968,16 @@ func (s *Server) handleGitListMatchingRefsRequest(args [3]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29858,8 +36989,27 @@ func (s *Server) handleGitListMatchingRefsRequest(args [3]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29953,6 +37103,8 @@ func (s *Server) handleGitListMatchingRefsRequest(args [3]string, argsEscaped bo // // PATCH /repos/{owner}/{repo}/git/refs/{ref} func (s *Server) handleGitUpdateRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("git/update-ref"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -29974,7 +37126,16 @@ func (s *Server) handleGitUpdateRefRequest(args [3]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29986,8 +37147,27 @@ func (s *Server) handleGitUpdateRefRequest(args [3]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30089,6 +37269,8 @@ func (s *Server) handleGitUpdateRefRequest(args [3]string, argsEscaped bool, w h // // GET /gitignore/templates func (s *Server) handleGitignoreGetAllTemplatesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gitignore/get-all-templates"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30110,7 +37292,16 @@ func (s *Server) handleGitignoreGetAllTemplatesRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30122,8 +37313,27 @@ func (s *Server) handleGitignoreGetAllTemplatesRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -30184,6 +37394,8 @@ func (s *Server) handleGitignoreGetAllTemplatesRequest(args [0]string, argsEscap // // GET /gitignore/templates/{name} func (s *Server) handleGitignoreGetTemplateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("gitignore/get-template"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30205,7 +37417,16 @@ func (s *Server) handleGitignoreGetTemplateRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30217,8 +37438,27 @@ func (s *Server) handleGitignoreGetTemplateRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30296,6 +37536,8 @@ func (s *Server) handleGitignoreGetTemplateRequest(args [1]string, argsEscaped b // // DELETE /user/interaction-limits func (s *Server) handleInteractionsRemoveRestrictionsForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("interactions/remove-restrictions-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -30317,7 +37559,16 @@ func (s *Server) handleInteractionsRemoveRestrictionsForAuthenticatedUserRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30329,8 +37580,27 @@ func (s *Server) handleInteractionsRemoveRestrictionsForAuthenticatedUserRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -30390,6 +37660,8 @@ func (s *Server) handleInteractionsRemoveRestrictionsForAuthenticatedUserRequest // // DELETE /orgs/{org}/interaction-limits func (s *Server) handleInteractionsRemoveRestrictionsForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("interactions/remove-restrictions-for-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -30411,7 +37683,16 @@ func (s *Server) handleInteractionsRemoveRestrictionsForOrgRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30423,8 +37704,27 @@ func (s *Server) handleInteractionsRemoveRestrictionsForOrgRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30505,6 +37805,8 @@ func (s *Server) handleInteractionsRemoveRestrictionsForOrgRequest(args [1]strin // // DELETE /repos/{owner}/{repo}/interaction-limits func (s *Server) handleInteractionsRemoveRestrictionsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("interactions/remove-restrictions-for-repo"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -30526,7 +37828,16 @@ func (s *Server) handleInteractionsRemoveRestrictionsForRepoRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30538,8 +37849,27 @@ func (s *Server) handleInteractionsRemoveRestrictionsForRepoRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30623,6 +37953,8 @@ func (s *Server) handleInteractionsRemoveRestrictionsForRepoRequest(args [2]stri // // PUT /user/interaction-limits func (s *Server) handleInteractionsSetRestrictionsForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("interactions/set-restrictions-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -30644,7 +37976,16 @@ func (s *Server) handleInteractionsSetRestrictionsForAuthenticatedUserRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30656,8 +37997,27 @@ func (s *Server) handleInteractionsSetRestrictionsForAuthenticatedUserRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30738,6 +38098,8 @@ func (s *Server) handleInteractionsSetRestrictionsForAuthenticatedUserRequest(ar // // PUT /orgs/{org}/interaction-limits func (s *Server) handleInteractionsSetRestrictionsForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("interactions/set-restrictions-for-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -30759,7 +38121,16 @@ func (s *Server) handleInteractionsSetRestrictionsForOrgRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30771,8 +38142,27 @@ func (s *Server) handleInteractionsSetRestrictionsForOrgRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30868,6 +38258,8 @@ func (s *Server) handleInteractionsSetRestrictionsForOrgRequest(args [1]string, // // PUT /repos/{owner}/{repo}/interaction-limits func (s *Server) handleInteractionsSetRestrictionsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("interactions/set-restrictions-for-repo"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -30889,7 +38281,16 @@ func (s *Server) handleInteractionsSetRestrictionsForRepoRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30901,8 +38302,27 @@ func (s *Server) handleInteractionsSetRestrictionsForRepoRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30999,6 +38419,8 @@ func (s *Server) handleInteractionsSetRestrictionsForRepoRequest(args [2]string, // // POST /repos/{owner}/{repo}/issues/{issue_number}/assignees func (s *Server) handleIssuesAddAssigneesRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/add-assignees"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31020,7 +38442,16 @@ func (s *Server) handleIssuesAddAssigneesRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31032,8 +38463,27 @@ func (s *Server) handleIssuesAddAssigneesRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31137,6 +38587,8 @@ func (s *Server) handleIssuesAddAssigneesRequest(args [3]string, argsEscaped boo // // GET /repos/{owner}/{repo}/assignees/{assignee} func (s *Server) handleIssuesCheckUserCanBeAssignedRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/check-user-can-be-assigned"), semconv.HTTPRequestMethodKey.String("GET"), @@ -31158,7 +38610,16 @@ func (s *Server) handleIssuesCheckUserCanBeAssignedRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31170,8 +38631,27 @@ func (s *Server) handleIssuesCheckUserCanBeAssignedRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31266,6 +38746,8 @@ func (s *Server) handleIssuesCheckUserCanBeAssignedRequest(args [3]string, argsE // // POST /repos/{owner}/{repo}/issues func (s *Server) handleIssuesCreateRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/create"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31287,7 +38769,16 @@ func (s *Server) handleIssuesCreateRequest(args [2]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31299,8 +38790,27 @@ func (s *Server) handleIssuesCreateRequest(args [2]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31403,6 +38913,8 @@ func (s *Server) handleIssuesCreateRequest(args [2]string, argsEscaped bool, w h // // POST /repos/{owner}/{repo}/issues/{issue_number}/comments func (s *Server) handleIssuesCreateCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/create-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31424,7 +38936,16 @@ func (s *Server) handleIssuesCreateCommentRequest(args [3]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31436,8 +38957,27 @@ func (s *Server) handleIssuesCreateCommentRequest(args [3]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31538,6 +39078,8 @@ func (s *Server) handleIssuesCreateCommentRequest(args [3]string, argsEscaped bo // // POST /repos/{owner}/{repo}/labels func (s *Server) handleIssuesCreateLabelRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/create-label"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31559,7 +39101,16 @@ func (s *Server) handleIssuesCreateLabelRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31571,8 +39122,27 @@ func (s *Server) handleIssuesCreateLabelRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31669,6 +39239,8 @@ func (s *Server) handleIssuesCreateLabelRequest(args [2]string, argsEscaped bool // // POST /repos/{owner}/{repo}/milestones func (s *Server) handleIssuesCreateMilestoneRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/create-milestone"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31690,7 +39262,16 @@ func (s *Server) handleIssuesCreateMilestoneRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31702,8 +39283,27 @@ func (s *Server) handleIssuesCreateMilestoneRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31800,6 +39400,8 @@ func (s *Server) handleIssuesCreateMilestoneRequest(args [2]string, argsEscaped // // DELETE /repos/{owner}/{repo}/issues/comments/{comment_id} func (s *Server) handleIssuesDeleteCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/delete-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -31821,7 +39423,16 @@ func (s *Server) handleIssuesDeleteCommentRequest(args [3]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31833,8 +39444,27 @@ func (s *Server) handleIssuesDeleteCommentRequest(args [3]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31920,6 +39550,8 @@ func (s *Server) handleIssuesDeleteCommentRequest(args [3]string, argsEscaped bo // // DELETE /repos/{owner}/{repo}/labels/{name} func (s *Server) handleIssuesDeleteLabelRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/delete-label"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -31941,7 +39573,16 @@ func (s *Server) handleIssuesDeleteLabelRequest(args [3]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31953,8 +39594,27 @@ func (s *Server) handleIssuesDeleteLabelRequest(args [3]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32040,6 +39700,8 @@ func (s *Server) handleIssuesDeleteLabelRequest(args [3]string, argsEscaped bool // // DELETE /repos/{owner}/{repo}/milestones/{milestone_number} func (s *Server) handleIssuesDeleteMilestoneRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/delete-milestone"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -32061,7 +39723,16 @@ func (s *Server) handleIssuesDeleteMilestoneRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32073,8 +39744,27 @@ func (s *Server) handleIssuesDeleteMilestoneRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32178,6 +39868,8 @@ func (s *Server) handleIssuesDeleteMilestoneRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/issues/{issue_number} func (s *Server) handleIssuesGetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32199,7 +39891,16 @@ func (s *Server) handleIssuesGetRequest(args [3]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32211,8 +39912,27 @@ func (s *Server) handleIssuesGetRequest(args [3]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32298,6 +40018,8 @@ func (s *Server) handleIssuesGetRequest(args [3]string, argsEscaped bool, w http // // GET /repos/{owner}/{repo}/issues/comments/{comment_id} func (s *Server) handleIssuesGetCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/get-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32319,7 +40041,16 @@ func (s *Server) handleIssuesGetCommentRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32331,8 +40062,27 @@ func (s *Server) handleIssuesGetCommentRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32418,6 +40168,8 @@ func (s *Server) handleIssuesGetCommentRequest(args [3]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/issues/events/{event_id} func (s *Server) handleIssuesGetEventRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/get-event"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32439,7 +40191,16 @@ func (s *Server) handleIssuesGetEventRequest(args [3]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32451,8 +40212,27 @@ func (s *Server) handleIssuesGetEventRequest(args [3]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32538,6 +40318,8 @@ func (s *Server) handleIssuesGetEventRequest(args [3]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/labels/{name} func (s *Server) handleIssuesGetLabelRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/get-label"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32559,7 +40341,16 @@ func (s *Server) handleIssuesGetLabelRequest(args [3]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32571,8 +40362,27 @@ func (s *Server) handleIssuesGetLabelRequest(args [3]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32658,6 +40468,8 @@ func (s *Server) handleIssuesGetLabelRequest(args [3]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/milestones/{milestone_number} func (s *Server) handleIssuesGetMilestoneRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/get-milestone"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32679,7 +40491,16 @@ func (s *Server) handleIssuesGetMilestoneRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32691,8 +40512,27 @@ func (s *Server) handleIssuesGetMilestoneRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32790,6 +40630,8 @@ func (s *Server) handleIssuesGetMilestoneRequest(args [3]string, argsEscaped boo // // GET /issues func (s *Server) handleIssuesListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32811,7 +40653,16 @@ func (s *Server) handleIssuesListRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32823,8 +40674,27 @@ func (s *Server) handleIssuesListRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32947,6 +40817,8 @@ func (s *Server) handleIssuesListRequest(args [0]string, argsEscaped bool, w htt // // GET /repos/{owner}/{repo}/assignees func (s *Server) handleIssuesListAssigneesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-assignees"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32968,7 +40840,16 @@ func (s *Server) handleIssuesListAssigneesRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32980,8 +40861,27 @@ func (s *Server) handleIssuesListAssigneesRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33071,6 +40971,8 @@ func (s *Server) handleIssuesListAssigneesRequest(args [2]string, argsEscaped bo // // GET /repos/{owner}/{repo}/issues/{issue_number}/comments func (s *Server) handleIssuesListCommentsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-comments"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33092,7 +40994,16 @@ func (s *Server) handleIssuesListCommentsRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33104,8 +41015,27 @@ func (s *Server) handleIssuesListCommentsRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33203,6 +41133,8 @@ func (s *Server) handleIssuesListCommentsRequest(args [3]string, argsEscaped boo // // GET /repos/{owner}/{repo}/issues/comments func (s *Server) handleIssuesListCommentsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-comments-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33224,7 +41156,16 @@ func (s *Server) handleIssuesListCommentsForRepoRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33236,8 +41177,27 @@ func (s *Server) handleIssuesListCommentsForRepoRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33339,6 +41299,8 @@ func (s *Server) handleIssuesListCommentsForRepoRequest(args [2]string, argsEsca // // GET /repos/{owner}/{repo}/issues/events func (s *Server) handleIssuesListEventsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-events-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33360,7 +41322,16 @@ func (s *Server) handleIssuesListEventsForRepoRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33372,8 +41343,27 @@ func (s *Server) handleIssuesListEventsForRepoRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33471,6 +41461,8 @@ func (s *Server) handleIssuesListEventsForRepoRequest(args [2]string, argsEscape // // GET /user/issues func (s *Server) handleIssuesListForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33492,7 +41484,16 @@ func (s *Server) handleIssuesListForAuthenticatedUserRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33504,8 +41505,27 @@ func (s *Server) handleIssuesListForAuthenticatedUserRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33619,6 +41639,8 @@ func (s *Server) handleIssuesListForAuthenticatedUserRequest(args [0]string, arg // // GET /orgs/{org}/issues func (s *Server) handleIssuesListForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33640,7 +41662,16 @@ func (s *Server) handleIssuesListForOrgRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33652,8 +41683,27 @@ func (s *Server) handleIssuesListForOrgRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33771,6 +41821,8 @@ func (s *Server) handleIssuesListForOrgRequest(args [1]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/issues func (s *Server) handleIssuesListForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33792,7 +41844,16 @@ func (s *Server) handleIssuesListForRepoRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33804,8 +41865,27 @@ func (s *Server) handleIssuesListForRepoRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33931,6 +42011,8 @@ func (s *Server) handleIssuesListForRepoRequest(args [2]string, argsEscaped bool // // GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels func (s *Server) handleIssuesListLabelsForMilestoneRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-labels-for-milestone"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33952,7 +42034,16 @@ func (s *Server) handleIssuesListLabelsForMilestoneRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33964,8 +42055,27 @@ func (s *Server) handleIssuesListLabelsForMilestoneRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34059,6 +42169,8 @@ func (s *Server) handleIssuesListLabelsForMilestoneRequest(args [3]string, argsE // // GET /repos/{owner}/{repo}/labels func (s *Server) handleIssuesListLabelsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-labels-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34080,7 +42192,16 @@ func (s *Server) handleIssuesListLabelsForRepoRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34092,8 +42213,27 @@ func (s *Server) handleIssuesListLabelsForRepoRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34183,6 +42323,8 @@ func (s *Server) handleIssuesListLabelsForRepoRequest(args [2]string, argsEscape // // GET /repos/{owner}/{repo}/issues/{issue_number}/labels func (s *Server) handleIssuesListLabelsOnIssueRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-labels-on-issue"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34204,7 +42346,16 @@ func (s *Server) handleIssuesListLabelsOnIssueRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34216,8 +42367,27 @@ func (s *Server) handleIssuesListLabelsOnIssueRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34311,6 +42481,8 @@ func (s *Server) handleIssuesListLabelsOnIssueRequest(args [3]string, argsEscape // // GET /repos/{owner}/{repo}/milestones func (s *Server) handleIssuesListMilestonesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/list-milestones"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34332,7 +42504,16 @@ func (s *Server) handleIssuesListMilestonesRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34344,8 +42525,27 @@ func (s *Server) handleIssuesListMilestonesRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34450,6 +42650,8 @@ func (s *Server) handleIssuesListMilestonesRequest(args [2]string, argsEscaped b // // PUT /repos/{owner}/{repo}/issues/{issue_number}/lock func (s *Server) handleIssuesLockRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/lock"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -34471,7 +42673,16 @@ func (s *Server) handleIssuesLockRequest(args [3]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34483,8 +42694,27 @@ func (s *Server) handleIssuesLockRequest(args [3]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34585,6 +42815,8 @@ func (s *Server) handleIssuesLockRequest(args [3]string, argsEscaped bool, w htt // // DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels func (s *Server) handleIssuesRemoveAllLabelsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/remove-all-labels"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -34606,7 +42838,16 @@ func (s *Server) handleIssuesRemoveAllLabelsRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34618,8 +42859,27 @@ func (s *Server) handleIssuesRemoveAllLabelsRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34705,6 +42965,8 @@ func (s *Server) handleIssuesRemoveAllLabelsRequest(args [3]string, argsEscaped // // DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees func (s *Server) handleIssuesRemoveAssigneesRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/remove-assignees"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -34726,7 +42988,16 @@ func (s *Server) handleIssuesRemoveAssigneesRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34738,8 +43009,27 @@ func (s *Server) handleIssuesRemoveAssigneesRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34841,6 +43131,8 @@ func (s *Server) handleIssuesRemoveAssigneesRequest(args [3]string, argsEscaped // // DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name} func (s *Server) handleIssuesRemoveLabelRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/remove-label"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -34862,7 +43154,16 @@ func (s *Server) handleIssuesRemoveLabelRequest(args [4]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34874,8 +43175,27 @@ func (s *Server) handleIssuesRemoveLabelRequest(args [4]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34965,6 +43285,8 @@ func (s *Server) handleIssuesRemoveLabelRequest(args [4]string, argsEscaped bool // // DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock func (s *Server) handleIssuesUnlockRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/unlock"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -34986,7 +43308,16 @@ func (s *Server) handleIssuesUnlockRequest(args [3]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34998,8 +43329,27 @@ func (s *Server) handleIssuesUnlockRequest(args [3]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35085,6 +43435,8 @@ func (s *Server) handleIssuesUnlockRequest(args [3]string, argsEscaped bool, w h // // PATCH /repos/{owner}/{repo}/issues/{issue_number} func (s *Server) handleIssuesUpdateRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/update"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -35106,7 +43458,16 @@ func (s *Server) handleIssuesUpdateRequest(args [3]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35118,8 +43479,27 @@ func (s *Server) handleIssuesUpdateRequest(args [3]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35220,6 +43600,8 @@ func (s *Server) handleIssuesUpdateRequest(args [3]string, argsEscaped bool, w h // // PATCH /repos/{owner}/{repo}/issues/comments/{comment_id} func (s *Server) handleIssuesUpdateCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/update-comment"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -35241,7 +43623,16 @@ func (s *Server) handleIssuesUpdateCommentRequest(args [3]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35253,8 +43644,27 @@ func (s *Server) handleIssuesUpdateCommentRequest(args [3]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35355,6 +43765,8 @@ func (s *Server) handleIssuesUpdateCommentRequest(args [3]string, argsEscaped bo // // PATCH /repos/{owner}/{repo}/labels/{name} func (s *Server) handleIssuesUpdateLabelRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/update-label"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -35376,7 +43788,16 @@ func (s *Server) handleIssuesUpdateLabelRequest(args [3]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35388,8 +43809,27 @@ func (s *Server) handleIssuesUpdateLabelRequest(args [3]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35490,6 +43930,8 @@ func (s *Server) handleIssuesUpdateLabelRequest(args [3]string, argsEscaped bool // // PATCH /repos/{owner}/{repo}/milestones/{milestone_number} func (s *Server) handleIssuesUpdateMilestoneRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("issues/update-milestone"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -35511,7 +43953,16 @@ func (s *Server) handleIssuesUpdateMilestoneRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35523,8 +43974,27 @@ func (s *Server) handleIssuesUpdateMilestoneRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35625,6 +44095,8 @@ func (s *Server) handleIssuesUpdateMilestoneRequest(args [3]string, argsEscaped // // GET /licenses/{license} func (s *Server) handleLicensesGetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("licenses/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35646,7 +44118,16 @@ func (s *Server) handleLicensesGetRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35658,8 +44139,27 @@ func (s *Server) handleLicensesGetRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35737,6 +44237,8 @@ func (s *Server) handleLicensesGetRequest(args [1]string, argsEscaped bool, w ht // // GET /licenses func (s *Server) handleLicensesGetAllCommonlyUsedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("licenses/get-all-commonly-used"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35758,7 +44260,16 @@ func (s *Server) handleLicensesGetAllCommonlyUsedRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35770,8 +44281,27 @@ func (s *Server) handleLicensesGetAllCommonlyUsedRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35861,6 +44391,8 @@ func (s *Server) handleLicensesGetAllCommonlyUsedRequest(args [0]string, argsEsc // // GET /repos/{owner}/{repo}/license func (s *Server) handleLicensesGetForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("licenses/get-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35882,7 +44414,16 @@ func (s *Server) handleLicensesGetForRepoRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35894,8 +44435,27 @@ func (s *Server) handleLicensesGetForRepoRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35977,6 +44537,8 @@ func (s *Server) handleLicensesGetForRepoRequest(args [2]string, argsEscaped boo // // POST /markdown func (s *Server) handleMarkdownRenderRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("markdown/render"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35998,7 +44560,16 @@ func (s *Server) handleMarkdownRenderRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36010,8 +44581,27 @@ func (s *Server) handleMarkdownRenderRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36092,6 +44682,8 @@ func (s *Server) handleMarkdownRenderRequest(args [0]string, argsEscaped bool, w // // POST /markdown/raw func (s *Server) handleMarkdownRenderRawRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("markdown/render-raw"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36113,7 +44705,16 @@ func (s *Server) handleMarkdownRenderRawRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36125,8 +44726,27 @@ func (s *Server) handleMarkdownRenderRawRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36208,6 +44828,8 @@ func (s *Server) handleMarkdownRenderRawRequest(args [0]string, argsEscaped bool // // GET /meta func (s *Server) handleMetaGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("meta/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36229,7 +44851,16 @@ func (s *Server) handleMetaGetRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36241,8 +44872,27 @@ func (s *Server) handleMetaGetRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -36301,6 +44951,8 @@ func (s *Server) handleMetaGetRequest(args [0]string, argsEscaped bool, w http.R // // GET /octocat func (s *Server) handleMetaGetOctocatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("meta/get-octocat"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36322,7 +44974,16 @@ func (s *Server) handleMetaGetOctocatRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36334,8 +44995,27 @@ func (s *Server) handleMetaGetOctocatRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36413,6 +45093,8 @@ func (s *Server) handleMetaGetOctocatRequest(args [0]string, argsEscaped bool, w // // GET /zen func (s *Server) handleMetaGetZenRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("meta/get-zen"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36434,7 +45116,16 @@ func (s *Server) handleMetaGetZenRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36446,8 +45137,27 @@ func (s *Server) handleMetaGetZenRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -36506,6 +45216,8 @@ func (s *Server) handleMetaGetZenRequest(args [0]string, argsEscaped bool, w htt // // GET / func (s *Server) handleMetaRootRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("meta/root"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36527,7 +45239,16 @@ func (s *Server) handleMetaRootRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36539,8 +45260,27 @@ func (s *Server) handleMetaRootRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -36599,6 +45339,8 @@ func (s *Server) handleMetaRootRequest(args [0]string, argsEscaped bool, w http. // // DELETE /repos/{owner}/{repo}/import func (s *Server) handleMigrationsCancelImportRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/cancel-import"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -36620,7 +45362,16 @@ func (s *Server) handleMigrationsCancelImportRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36632,8 +45383,27 @@ func (s *Server) handleMigrationsCancelImportRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36719,6 +45489,8 @@ func (s *Server) handleMigrationsCancelImportRequest(args [2]string, argsEscaped // // DELETE /user/migrations/{migration_id}/archive func (s *Server) handleMigrationsDeleteArchiveForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/delete-archive-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -36740,7 +45512,16 @@ func (s *Server) handleMigrationsDeleteArchiveForAuthenticatedUserRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36752,8 +45533,27 @@ func (s *Server) handleMigrationsDeleteArchiveForAuthenticatedUserRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36832,6 +45632,8 @@ func (s *Server) handleMigrationsDeleteArchiveForAuthenticatedUserRequest(args [ // // DELETE /orgs/{org}/migrations/{migration_id}/archive func (s *Server) handleMigrationsDeleteArchiveForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/delete-archive-for-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -36853,7 +45655,16 @@ func (s *Server) handleMigrationsDeleteArchiveForOrgRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36865,8 +45676,27 @@ func (s *Server) handleMigrationsDeleteArchiveForOrgRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36948,6 +45778,8 @@ func (s *Server) handleMigrationsDeleteArchiveForOrgRequest(args [2]string, args // // GET /orgs/{org}/migrations/{migration_id}/archive func (s *Server) handleMigrationsDownloadArchiveForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/download-archive-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36969,7 +45801,16 @@ func (s *Server) handleMigrationsDownloadArchiveForOrgRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36981,8 +45822,27 @@ func (s *Server) handleMigrationsDownloadArchiveForOrgRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37084,6 +45944,8 @@ func (s *Server) handleMigrationsDownloadArchiveForOrgRequest(args [2]string, ar // // GET /user/migrations/{migration_id}/archive func (s *Server) handleMigrationsGetArchiveForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/get-archive-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37105,7 +45967,16 @@ func (s *Server) handleMigrationsGetArchiveForAuthenticatedUserRequest(args [1]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37117,8 +45988,27 @@ func (s *Server) handleMigrationsGetArchiveForAuthenticatedUserRequest(args [1]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37203,6 +46093,8 @@ func (s *Server) handleMigrationsGetArchiveForAuthenticatedUserRequest(args [1]s // // GET /repos/{owner}/{repo}/import/authors func (s *Server) handleMigrationsGetCommitAuthorsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/get-commit-authors"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37224,7 +46116,16 @@ func (s *Server) handleMigrationsGetCommitAuthorsRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37236,8 +46137,27 @@ func (s *Server) handleMigrationsGetCommitAuthorsRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37375,6 +46295,8 @@ func (s *Server) handleMigrationsGetCommitAuthorsRequest(args [2]string, argsEsc // // GET /repos/{owner}/{repo}/import func (s *Server) handleMigrationsGetImportStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/get-import-status"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37396,7 +46318,16 @@ func (s *Server) handleMigrationsGetImportStatusRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37408,8 +46339,27 @@ func (s *Server) handleMigrationsGetImportStatusRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37491,6 +46441,8 @@ func (s *Server) handleMigrationsGetImportStatusRequest(args [2]string, argsEsca // // GET /repos/{owner}/{repo}/import/large_files func (s *Server) handleMigrationsGetLargeFilesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/get-large-files"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37512,7 +46464,16 @@ func (s *Server) handleMigrationsGetLargeFilesRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37524,8 +46485,27 @@ func (s *Server) handleMigrationsGetLargeFilesRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37614,6 +46594,8 @@ func (s *Server) handleMigrationsGetLargeFilesRequest(args [2]string, argsEscape // // GET /user/migrations/{migration_id} func (s *Server) handleMigrationsGetStatusForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/get-status-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37635,7 +46617,16 @@ func (s *Server) handleMigrationsGetStatusForAuthenticatedUserRequest(args [1]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37647,8 +46638,27 @@ func (s *Server) handleMigrationsGetStatusForAuthenticatedUserRequest(args [1]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37735,6 +46745,8 @@ func (s *Server) handleMigrationsGetStatusForAuthenticatedUserRequest(args [1]st // // GET /orgs/{org}/migrations/{migration_id} func (s *Server) handleMigrationsGetStatusForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/get-status-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37756,7 +46768,16 @@ func (s *Server) handleMigrationsGetStatusForOrgRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37768,8 +46789,27 @@ func (s *Server) handleMigrationsGetStatusForOrgRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37855,6 +46895,8 @@ func (s *Server) handleMigrationsGetStatusForOrgRequest(args [2]string, argsEsca // // GET /user/migrations func (s *Server) handleMigrationsListForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/list-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37876,7 +46918,16 @@ func (s *Server) handleMigrationsListForAuthenticatedUserRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37888,8 +46939,27 @@ func (s *Server) handleMigrationsListForAuthenticatedUserRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37971,6 +47041,8 @@ func (s *Server) handleMigrationsListForAuthenticatedUserRequest(args [0]string, // // GET /orgs/{org}/migrations func (s *Server) handleMigrationsListForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/list-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37992,7 +47064,16 @@ func (s *Server) handleMigrationsListForOrgRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38004,8 +47085,27 @@ func (s *Server) handleMigrationsListForOrgRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38095,6 +47195,8 @@ func (s *Server) handleMigrationsListForOrgRequest(args [1]string, argsEscaped b // // GET /orgs/{org}/migrations/{migration_id}/repositories func (s *Server) handleMigrationsListReposForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/list-repos-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38116,7 +47218,16 @@ func (s *Server) handleMigrationsListReposForOrgRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38128,8 +47239,27 @@ func (s *Server) handleMigrationsListReposForOrgRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38219,6 +47349,8 @@ func (s *Server) handleMigrationsListReposForOrgRequest(args [2]string, argsEsca // // GET /user/migrations/{migration_id}/repositories func (s *Server) handleMigrationsListReposForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/list-repos-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38240,7 +47372,16 @@ func (s *Server) handleMigrationsListReposForUserRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38252,8 +47393,27 @@ func (s *Server) handleMigrationsListReposForUserRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38340,6 +47500,8 @@ func (s *Server) handleMigrationsListReposForUserRequest(args [1]string, argsEsc // // PATCH /repos/{owner}/{repo}/import/authors/{author_id} func (s *Server) handleMigrationsMapCommitAuthorRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/map-commit-author"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -38361,7 +47523,16 @@ func (s *Server) handleMigrationsMapCommitAuthorRequest(args [3]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38373,8 +47544,27 @@ func (s *Server) handleMigrationsMapCommitAuthorRequest(args [3]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38478,6 +47668,8 @@ func (s *Server) handleMigrationsMapCommitAuthorRequest(args [3]string, argsEsca // // PATCH /repos/{owner}/{repo}/import/lfs func (s *Server) handleMigrationsSetLfsPreferenceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/set-lfs-preference"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -38499,7 +47691,16 @@ func (s *Server) handleMigrationsSetLfsPreferenceRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38511,8 +47712,27 @@ func (s *Server) handleMigrationsSetLfsPreferenceRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38609,6 +47829,8 @@ func (s *Server) handleMigrationsSetLfsPreferenceRequest(args [2]string, argsEsc // // POST /user/migrations func (s *Server) handleMigrationsStartForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/start-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38630,7 +47852,16 @@ func (s *Server) handleMigrationsStartForAuthenticatedUserRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38642,8 +47873,27 @@ func (s *Server) handleMigrationsStartForAuthenticatedUserRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38721,6 +47971,8 @@ func (s *Server) handleMigrationsStartForAuthenticatedUserRequest(args [0]string // // POST /orgs/{org}/migrations func (s *Server) handleMigrationsStartForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/start-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38742,7 +47994,16 @@ func (s *Server) handleMigrationsStartForOrgRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38754,8 +48015,27 @@ func (s *Server) handleMigrationsStartForOrgRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38848,6 +48128,8 @@ func (s *Server) handleMigrationsStartForOrgRequest(args [1]string, argsEscaped // // PUT /repos/{owner}/{repo}/import func (s *Server) handleMigrationsStartImportRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/start-import"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -38869,7 +48151,16 @@ func (s *Server) handleMigrationsStartImportRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38881,8 +48172,27 @@ func (s *Server) handleMigrationsStartImportRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38983,6 +48293,8 @@ func (s *Server) handleMigrationsStartImportRequest(args [2]string, argsEscaped // // DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock func (s *Server) handleMigrationsUnlockRepoForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/unlock-repo-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -39004,7 +48316,16 @@ func (s *Server) handleMigrationsUnlockRepoForAuthenticatedUserRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39016,8 +48337,27 @@ func (s *Server) handleMigrationsUnlockRepoForAuthenticatedUserRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39101,6 +48441,8 @@ func (s *Server) handleMigrationsUnlockRepoForAuthenticatedUserRequest(args [2]s // // DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock func (s *Server) handleMigrationsUnlockRepoForOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/unlock-repo-for-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -39122,7 +48464,16 @@ func (s *Server) handleMigrationsUnlockRepoForOrgRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39134,8 +48485,27 @@ func (s *Server) handleMigrationsUnlockRepoForOrgRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39223,6 +48593,8 @@ func (s *Server) handleMigrationsUnlockRepoForOrgRequest(args [3]string, argsEsc // // PATCH /repos/{owner}/{repo}/import func (s *Server) handleMigrationsUpdateImportRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("migrations/update-import"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -39244,7 +48616,16 @@ func (s *Server) handleMigrationsUpdateImportRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39256,8 +48637,27 @@ func (s *Server) handleMigrationsUpdateImportRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39383,6 +48783,8 @@ func (s *Server) handleMigrationsUpdateImportRequest(args [2]string, argsEscaped // // POST /authorizations func (s *Server) handleOAuthAuthorizationsCreateAuthorizationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/create-authorization"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39404,7 +48806,16 @@ func (s *Server) handleOAuthAuthorizationsCreateAuthorizationRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39416,8 +48827,27 @@ func (s *Server) handleOAuthAuthorizationsCreateAuthorizationRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39504,6 +48934,8 @@ func (s *Server) handleOAuthAuthorizationsCreateAuthorizationRequest(args [0]str // // DELETE /authorizations/{authorization_id} func (s *Server) handleOAuthAuthorizationsDeleteAuthorizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/delete-authorization"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -39525,7 +48957,16 @@ func (s *Server) handleOAuthAuthorizationsDeleteAuthorizationRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39537,8 +48978,27 @@ func (s *Server) handleOAuthAuthorizationsDeleteAuthorizationRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39628,6 +49088,8 @@ func (s *Server) handleOAuthAuthorizationsDeleteAuthorizationRequest(args [1]str // // DELETE /applications/grants/{grant_id} func (s *Server) handleOAuthAuthorizationsDeleteGrantRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/delete-grant"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -39649,7 +49111,16 @@ func (s *Server) handleOAuthAuthorizationsDeleteGrantRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39661,8 +49132,27 @@ func (s *Server) handleOAuthAuthorizationsDeleteGrantRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39749,6 +49239,8 @@ func (s *Server) handleOAuthAuthorizationsDeleteGrantRequest(args [1]string, arg // // GET /authorizations/{authorization_id} func (s *Server) handleOAuthAuthorizationsGetAuthorizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/get-authorization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39770,7 +49262,16 @@ func (s *Server) handleOAuthAuthorizationsGetAuthorizationRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39782,8 +49283,27 @@ func (s *Server) handleOAuthAuthorizationsGetAuthorizationRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39870,6 +49390,8 @@ func (s *Server) handleOAuthAuthorizationsGetAuthorizationRequest(args [1]string // // GET /applications/grants/{grant_id} func (s *Server) handleOAuthAuthorizationsGetGrantRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/get-grant"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39891,7 +49413,16 @@ func (s *Server) handleOAuthAuthorizationsGetGrantRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39903,8 +49434,27 @@ func (s *Server) handleOAuthAuthorizationsGetGrantRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40010,6 +49560,8 @@ func (s *Server) handleOAuthAuthorizationsGetGrantRequest(args [1]string, argsEs // // PUT /authorizations/clients/{client_id} func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/get-or-create-authorization-for-app"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -40031,7 +49583,16 @@ func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40043,8 +49604,27 @@ func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40160,6 +49740,8 @@ func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppRequest( // // PUT /authorizations/clients/{client_id}/{fingerprint} func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppAndFingerprintRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/get-or-create-authorization-for-app-and-fingerprint"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -40181,7 +49763,16 @@ func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppAndFinge startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40193,8 +49784,27 @@ func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppAndFinge var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40300,6 +49910,8 @@ func (s *Server) handleOAuthAuthorizationsGetOrCreateAuthorizationForAppAndFinge // // GET /authorizations func (s *Server) handleOAuthAuthorizationsListAuthorizationsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/list-authorizations"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40321,7 +49933,16 @@ func (s *Server) handleOAuthAuthorizationsListAuthorizationsRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40333,8 +49954,27 @@ func (s *Server) handleOAuthAuthorizationsListAuthorizationsRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40440,6 +50080,8 @@ func (s *Server) handleOAuthAuthorizationsListAuthorizationsRequest(args [0]stri // // GET /applications/grants func (s *Server) handleOAuthAuthorizationsListGrantsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/list-grants"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40461,7 +50103,16 @@ func (s *Server) handleOAuthAuthorizationsListGrantsRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40473,8 +50124,27 @@ func (s *Server) handleOAuthAuthorizationsListGrantsRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40573,6 +50243,8 @@ func (s *Server) handleOAuthAuthorizationsListGrantsRequest(args [0]string, args // // PATCH /authorizations/{authorization_id} func (s *Server) handleOAuthAuthorizationsUpdateAuthorizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oauth-authorizations/update-authorization"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -40594,7 +50266,16 @@ func (s *Server) handleOAuthAuthorizationsUpdateAuthorizationRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40606,8 +50287,27 @@ func (s *Server) handleOAuthAuthorizationsUpdateAuthorizationRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40700,6 +50400,8 @@ func (s *Server) handleOAuthAuthorizationsUpdateAuthorizationRequest(args [1]str // // PUT /orgs/{org}/blocks/{username} func (s *Server) handleOrgsBlockUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/block-user"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -40721,7 +50423,16 @@ func (s *Server) handleOrgsBlockUserRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40733,8 +50444,27 @@ func (s *Server) handleOrgsBlockUserRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40819,6 +50549,8 @@ func (s *Server) handleOrgsBlockUserRequest(args [2]string, argsEscaped bool, w // // DELETE /orgs/{org}/invitations/{invitation_id} func (s *Server) handleOrgsCancelInvitationRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/cancel-invitation"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -40840,7 +50572,16 @@ func (s *Server) handleOrgsCancelInvitationRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40852,8 +50593,27 @@ func (s *Server) handleOrgsCancelInvitationRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40935,6 +50695,8 @@ func (s *Server) handleOrgsCancelInvitationRequest(args [2]string, argsEscaped b // // GET /orgs/{org}/blocks/{username} func (s *Server) handleOrgsCheckBlockedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/check-blocked-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40956,7 +50718,16 @@ func (s *Server) handleOrgsCheckBlockedUserRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40968,8 +50739,27 @@ func (s *Server) handleOrgsCheckBlockedUserRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41051,6 +50841,8 @@ func (s *Server) handleOrgsCheckBlockedUserRequest(args [2]string, argsEscaped b // // GET /orgs/{org}/members/{username} func (s *Server) handleOrgsCheckMembershipForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/check-membership-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41072,7 +50864,16 @@ func (s *Server) handleOrgsCheckMembershipForUserRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41084,8 +50885,27 @@ func (s *Server) handleOrgsCheckMembershipForUserRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41167,6 +50987,8 @@ func (s *Server) handleOrgsCheckMembershipForUserRequest(args [2]string, argsEsc // // GET /orgs/{org}/public_members/{username} func (s *Server) handleOrgsCheckPublicMembershipForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/check-public-membership-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41188,7 +51010,16 @@ func (s *Server) handleOrgsCheckPublicMembershipForUserRequest(args [2]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41200,8 +51031,27 @@ func (s *Server) handleOrgsCheckPublicMembershipForUserRequest(args [2]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41287,6 +51137,8 @@ func (s *Server) handleOrgsCheckPublicMembershipForUserRequest(args [2]string, a // // PUT /orgs/{org}/outside_collaborators/{username} func (s *Server) handleOrgsConvertMemberToOutsideCollaboratorRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/convert-member-to-outside-collaborator"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -41308,7 +51160,16 @@ func (s *Server) handleOrgsConvertMemberToOutsideCollaboratorRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41320,8 +51181,27 @@ func (s *Server) handleOrgsConvertMemberToOutsideCollaboratorRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41411,6 +51291,8 @@ func (s *Server) handleOrgsConvertMemberToOutsideCollaboratorRequest(args [2]str // // POST /orgs/{org}/invitations func (s *Server) handleOrgsCreateInvitationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/create-invitation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41432,7 +51314,16 @@ func (s *Server) handleOrgsCreateInvitationRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41444,8 +51335,27 @@ func (s *Server) handleOrgsCreateInvitationRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41538,6 +51448,8 @@ func (s *Server) handleOrgsCreateInvitationRequest(args [1]string, argsEscaped b // // POST /orgs/{org}/hooks func (s *Server) handleOrgsCreateWebhookRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/create-webhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41559,7 +51471,16 @@ func (s *Server) handleOrgsCreateWebhookRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41571,8 +51492,27 @@ func (s *Server) handleOrgsCreateWebhookRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41665,6 +51605,8 @@ func (s *Server) handleOrgsCreateWebhookRequest(args [1]string, argsEscaped bool // // DELETE /orgs/{org}/hooks/{hook_id} func (s *Server) handleOrgsDeleteWebhookRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/delete-webhook"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -41686,7 +51628,16 @@ func (s *Server) handleOrgsDeleteWebhookRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41698,8 +51649,27 @@ func (s *Server) handleOrgsDeleteWebhookRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41789,6 +51759,8 @@ func (s *Server) handleOrgsDeleteWebhookRequest(args [2]string, argsEscaped bool // // GET /orgs/{org} func (s *Server) handleOrgsGetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41810,7 +51782,16 @@ func (s *Server) handleOrgsGetRequest(args [1]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41822,8 +51803,27 @@ func (s *Server) handleOrgsGetRequest(args [1]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41906,6 +51906,8 @@ func (s *Server) handleOrgsGetRequest(args [1]string, argsEscaped bool, w http.R // // GET /orgs/{org}/audit-log func (s *Server) handleOrgsGetAuditLogRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get-audit-log"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41927,7 +51929,16 @@ func (s *Server) handleOrgsGetAuditLogRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41939,8 +51950,27 @@ func (s *Server) handleOrgsGetAuditLogRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42046,6 +52076,8 @@ func (s *Server) handleOrgsGetAuditLogRequest(args [1]string, argsEscaped bool, // // GET /user/memberships/orgs/{org} func (s *Server) handleOrgsGetMembershipForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get-membership-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42067,7 +52099,16 @@ func (s *Server) handleOrgsGetMembershipForAuthenticatedUserRequest(args [1]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42079,8 +52120,27 @@ func (s *Server) handleOrgsGetMembershipForAuthenticatedUserRequest(args [1]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42160,6 +52220,8 @@ func (s *Server) handleOrgsGetMembershipForAuthenticatedUserRequest(args [1]stri // // GET /orgs/{org}/memberships/{username} func (s *Server) handleOrgsGetMembershipForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get-membership-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42181,7 +52243,16 @@ func (s *Server) handleOrgsGetMembershipForUserRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42193,8 +52264,27 @@ func (s *Server) handleOrgsGetMembershipForUserRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42278,6 +52368,8 @@ func (s *Server) handleOrgsGetMembershipForUserRequest(args [2]string, argsEscap // // GET /orgs/{org}/hooks/{hook_id} func (s *Server) handleOrgsGetWebhookRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get-webhook"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42299,7 +52391,16 @@ func (s *Server) handleOrgsGetWebhookRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42311,8 +52412,27 @@ func (s *Server) handleOrgsGetWebhookRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42398,6 +52518,8 @@ func (s *Server) handleOrgsGetWebhookRequest(args [2]string, argsEscaped bool, w // // GET /orgs/{org}/hooks/{hook_id}/config func (s *Server) handleOrgsGetWebhookConfigForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get-webhook-config-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42419,7 +52541,16 @@ func (s *Server) handleOrgsGetWebhookConfigForOrgRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42431,8 +52562,27 @@ func (s *Server) handleOrgsGetWebhookConfigForOrgRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42514,6 +52664,8 @@ func (s *Server) handleOrgsGetWebhookConfigForOrgRequest(args [2]string, argsEsc // // GET /orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id} func (s *Server) handleOrgsGetWebhookDeliveryRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/get-webhook-delivery"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42535,7 +52687,16 @@ func (s *Server) handleOrgsGetWebhookDeliveryRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42547,8 +52708,27 @@ func (s *Server) handleOrgsGetWebhookDeliveryRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42637,6 +52817,8 @@ func (s *Server) handleOrgsGetWebhookDeliveryRequest(args [3]string, argsEscaped // // GET /organizations func (s *Server) handleOrgsListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42658,7 +52840,16 @@ func (s *Server) handleOrgsListRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42670,8 +52861,27 @@ func (s *Server) handleOrgsListRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42753,6 +52963,8 @@ func (s *Server) handleOrgsListRequest(args [0]string, argsEscaped bool, w http. // // GET /orgs/{org}/blocks func (s *Server) handleOrgsListBlockedUsersRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-blocked-users"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42774,7 +52986,16 @@ func (s *Server) handleOrgsListBlockedUsersRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42786,8 +53007,27 @@ func (s *Server) handleOrgsListBlockedUsersRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42866,6 +53106,8 @@ func (s *Server) handleOrgsListBlockedUsersRequest(args [1]string, argsEscaped b // // GET /orgs/{org}/failed_invitations func (s *Server) handleOrgsListFailedInvitationsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-failed-invitations"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42887,7 +53129,16 @@ func (s *Server) handleOrgsListFailedInvitationsRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42899,8 +53150,27 @@ func (s *Server) handleOrgsListFailedInvitationsRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42991,6 +53261,8 @@ func (s *Server) handleOrgsListFailedInvitationsRequest(args [1]string, argsEsca // // GET /user/orgs func (s *Server) handleOrgsListForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43012,7 +53284,16 @@ func (s *Server) handleOrgsListForAuthenticatedUserRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43024,8 +53305,27 @@ func (s *Server) handleOrgsListForAuthenticatedUserRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43112,6 +53412,8 @@ func (s *Server) handleOrgsListForAuthenticatedUserRequest(args [0]string, argsE // // GET /users/{username}/orgs func (s *Server) handleOrgsListForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43133,7 +53435,16 @@ func (s *Server) handleOrgsListForUserRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43145,8 +53456,27 @@ func (s *Server) handleOrgsListForUserRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43233,6 +53563,8 @@ func (s *Server) handleOrgsListForUserRequest(args [1]string, argsEscaped bool, // // GET /orgs/{org}/invitations/{invitation_id}/teams func (s *Server) handleOrgsListInvitationTeamsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-invitation-teams"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43254,7 +53586,16 @@ func (s *Server) handleOrgsListInvitationTeamsRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43266,8 +53607,27 @@ func (s *Server) handleOrgsListInvitationTeamsRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43358,6 +53718,8 @@ func (s *Server) handleOrgsListInvitationTeamsRequest(args [2]string, argsEscape // // GET /orgs/{org}/members func (s *Server) handleOrgsListMembersRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-members"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43379,7 +53741,16 @@ func (s *Server) handleOrgsListMembersRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43391,8 +53762,27 @@ func (s *Server) handleOrgsListMembersRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43486,6 +53876,8 @@ func (s *Server) handleOrgsListMembersRequest(args [1]string, argsEscaped bool, // // GET /user/memberships/orgs func (s *Server) handleOrgsListMembershipsForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-memberships-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43507,7 +53899,16 @@ func (s *Server) handleOrgsListMembershipsForAuthenticatedUserRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43519,8 +53920,27 @@ func (s *Server) handleOrgsListMembershipsForAuthenticatedUserRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43606,6 +54026,8 @@ func (s *Server) handleOrgsListMembershipsForAuthenticatedUserRequest(args [0]st // // GET /orgs/{org}/outside_collaborators func (s *Server) handleOrgsListOutsideCollaboratorsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-outside-collaborators"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43627,7 +54049,16 @@ func (s *Server) handleOrgsListOutsideCollaboratorsRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43639,8 +54070,27 @@ func (s *Server) handleOrgsListOutsideCollaboratorsRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43733,6 +54183,8 @@ func (s *Server) handleOrgsListOutsideCollaboratorsRequest(args [1]string, argsE // // GET /orgs/{org}/invitations func (s *Server) handleOrgsListPendingInvitationsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-pending-invitations"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43754,7 +54206,16 @@ func (s *Server) handleOrgsListPendingInvitationsRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43766,8 +54227,27 @@ func (s *Server) handleOrgsListPendingInvitationsRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43853,6 +54333,8 @@ func (s *Server) handleOrgsListPendingInvitationsRequest(args [1]string, argsEsc // // GET /orgs/{org}/public_members func (s *Server) handleOrgsListPublicMembersRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-public-members"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43874,7 +54356,16 @@ func (s *Server) handleOrgsListPublicMembersRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43886,8 +54377,27 @@ func (s *Server) handleOrgsListPublicMembersRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43980,6 +54490,8 @@ func (s *Server) handleOrgsListPublicMembersRequest(args [1]string, argsEscaped // // GET /orgs/{org}/credential-authorizations func (s *Server) handleOrgsListSamlSSOAuthorizationsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-saml-sso-authorizations"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44001,7 +54513,16 @@ func (s *Server) handleOrgsListSamlSSOAuthorizationsRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44013,8 +54534,27 @@ func (s *Server) handleOrgsListSamlSSOAuthorizationsRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44092,6 +54632,8 @@ func (s *Server) handleOrgsListSamlSSOAuthorizationsRequest(args [1]string, args // // GET /orgs/{org}/hooks/{hook_id}/deliveries func (s *Server) handleOrgsListWebhookDeliveriesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-webhook-deliveries"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44113,7 +54655,16 @@ func (s *Server) handleOrgsListWebhookDeliveriesRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44125,8 +54676,27 @@ func (s *Server) handleOrgsListWebhookDeliveriesRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44216,6 +54786,8 @@ func (s *Server) handleOrgsListWebhookDeliveriesRequest(args [2]string, argsEsca // // GET /orgs/{org}/hooks func (s *Server) handleOrgsListWebhooksRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/list-webhooks"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44237,7 +54809,16 @@ func (s *Server) handleOrgsListWebhooksRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44249,8 +54830,27 @@ func (s *Server) handleOrgsListWebhooksRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44337,6 +54937,8 @@ func (s *Server) handleOrgsListWebhooksRequest(args [1]string, argsEscaped bool, // // POST /orgs/{org}/hooks/{hook_id}/pings func (s *Server) handleOrgsPingWebhookRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/ping-webhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44358,7 +54960,16 @@ func (s *Server) handleOrgsPingWebhookRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44370,8 +54981,27 @@ func (s *Server) handleOrgsPingWebhookRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44453,6 +55083,8 @@ func (s *Server) handleOrgsPingWebhookRequest(args [2]string, argsEscaped bool, // // POST /orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}/attempts func (s *Server) handleOrgsRedeliverWebhookDeliveryRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/redeliver-webhook-delivery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44474,7 +55106,16 @@ func (s *Server) handleOrgsRedeliverWebhookDeliveryRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44486,8 +55127,27 @@ func (s *Server) handleOrgsRedeliverWebhookDeliveryRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44574,6 +55234,8 @@ func (s *Server) handleOrgsRedeliverWebhookDeliveryRequest(args [3]string, argsE // // DELETE /orgs/{org}/members/{username} func (s *Server) handleOrgsRemoveMemberRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/remove-member"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -44595,7 +55257,16 @@ func (s *Server) handleOrgsRemoveMemberRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44607,8 +55278,27 @@ func (s *Server) handleOrgsRemoveMemberRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44694,6 +55384,8 @@ func (s *Server) handleOrgsRemoveMemberRequest(args [2]string, argsEscaped bool, // // DELETE /orgs/{org}/memberships/{username} func (s *Server) handleOrgsRemoveMembershipForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/remove-membership-for-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -44715,7 +55407,16 @@ func (s *Server) handleOrgsRemoveMembershipForUserRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44727,8 +55428,27 @@ func (s *Server) handleOrgsRemoveMembershipForUserRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44810,6 +55530,8 @@ func (s *Server) handleOrgsRemoveMembershipForUserRequest(args [2]string, argsEs // // DELETE /orgs/{org}/outside_collaborators/{username} func (s *Server) handleOrgsRemoveOutsideCollaboratorRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/remove-outside-collaborator"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -44831,7 +55553,16 @@ func (s *Server) handleOrgsRemoveOutsideCollaboratorRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44843,8 +55574,27 @@ func (s *Server) handleOrgsRemoveOutsideCollaboratorRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44926,6 +55676,8 @@ func (s *Server) handleOrgsRemoveOutsideCollaboratorRequest(args [2]string, args // // DELETE /orgs/{org}/public_members/{username} func (s *Server) handleOrgsRemovePublicMembershipForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/remove-public-membership-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -44947,7 +55699,16 @@ func (s *Server) handleOrgsRemovePublicMembershipForAuthenticatedUserRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44959,8 +55720,27 @@ func (s *Server) handleOrgsRemovePublicMembershipForAuthenticatedUserRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45048,6 +55828,8 @@ func (s *Server) handleOrgsRemovePublicMembershipForAuthenticatedUserRequest(arg // // DELETE /orgs/{org}/credential-authorizations/{credential_id} func (s *Server) handleOrgsRemoveSamlSSOAuthorizationRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/remove-saml-sso-authorization"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -45069,7 +55851,16 @@ func (s *Server) handleOrgsRemoveSamlSSOAuthorizationRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45081,8 +55872,27 @@ func (s *Server) handleOrgsRemoveSamlSSOAuthorizationRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45177,6 +55987,8 @@ func (s *Server) handleOrgsRemoveSamlSSOAuthorizationRequest(args [2]string, arg // // PUT /orgs/{org}/memberships/{username} func (s *Server) handleOrgsSetMembershipForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/set-membership-for-user"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -45198,7 +56010,16 @@ func (s *Server) handleOrgsSetMembershipForUserRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45210,8 +56031,27 @@ func (s *Server) handleOrgsSetMembershipForUserRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45312,6 +56152,8 @@ func (s *Server) handleOrgsSetMembershipForUserRequest(args [2]string, argsEscap // // PUT /orgs/{org}/public_members/{username} func (s *Server) handleOrgsSetPublicMembershipForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/set-public-membership-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -45333,7 +56175,16 @@ func (s *Server) handleOrgsSetPublicMembershipForAuthenticatedUserRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45345,8 +56196,27 @@ func (s *Server) handleOrgsSetPublicMembershipForAuthenticatedUserRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45428,6 +56298,8 @@ func (s *Server) handleOrgsSetPublicMembershipForAuthenticatedUserRequest(args [ // // DELETE /orgs/{org}/blocks/{username} func (s *Server) handleOrgsUnblockUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/unblock-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -45449,7 +56321,16 @@ func (s *Server) handleOrgsUnblockUserRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45461,8 +56342,27 @@ func (s *Server) handleOrgsUnblockUserRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45544,6 +56444,8 @@ func (s *Server) handleOrgsUnblockUserRequest(args [2]string, argsEscaped bool, // // PATCH /user/memberships/orgs/{org} func (s *Server) handleOrgsUpdateMembershipForAuthenticatedUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/update-membership-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -45565,7 +56467,16 @@ func (s *Server) handleOrgsUpdateMembershipForAuthenticatedUserRequest(args [1]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45577,8 +56488,27 @@ func (s *Server) handleOrgsUpdateMembershipForAuthenticatedUserRequest(args [1]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45675,6 +56605,8 @@ func (s *Server) handleOrgsUpdateMembershipForAuthenticatedUserRequest(args [1]s // // PATCH /orgs/{org}/hooks/{hook_id} func (s *Server) handleOrgsUpdateWebhookRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/update-webhook"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -45696,7 +56628,16 @@ func (s *Server) handleOrgsUpdateWebhookRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45708,8 +56649,27 @@ func (s *Server) handleOrgsUpdateWebhookRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45810,6 +56770,8 @@ func (s *Server) handleOrgsUpdateWebhookRequest(args [2]string, argsEscaped bool // // PATCH /orgs/{org}/hooks/{hook_id}/config func (s *Server) handleOrgsUpdateWebhookConfigForOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("orgs/update-webhook-config-for-org"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -45831,7 +56793,16 @@ func (s *Server) handleOrgsUpdateWebhookConfigForOrgRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45843,8 +56814,27 @@ func (s *Server) handleOrgsUpdateWebhookConfigForOrgRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45946,6 +56936,8 @@ func (s *Server) handleOrgsUpdateWebhookConfigForOrgRequest(args [2]string, args // // DELETE /user/packages/{package_type}/{package_name} func (s *Server) handlePackagesDeletePackageForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/delete-package-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -45967,7 +56959,16 @@ func (s *Server) handlePackagesDeletePackageForAuthenticatedUserRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45979,8 +56980,27 @@ func (s *Server) handlePackagesDeletePackageForAuthenticatedUserRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46069,6 +57089,8 @@ func (s *Server) handlePackagesDeletePackageForAuthenticatedUserRequest(args [2] // // DELETE /orgs/{org}/packages/{package_type}/{package_name} func (s *Server) handlePackagesDeletePackageForOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/delete-package-for-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -46090,7 +57112,16 @@ func (s *Server) handlePackagesDeletePackageForOrgRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46102,8 +57133,27 @@ func (s *Server) handlePackagesDeletePackageForOrgRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46196,6 +57246,8 @@ func (s *Server) handlePackagesDeletePackageForOrgRequest(args [3]string, argsEs // // DELETE /users/{username}/packages/{package_type}/{package_name} func (s *Server) handlePackagesDeletePackageForUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/delete-package-for-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -46217,7 +57269,16 @@ func (s *Server) handlePackagesDeletePackageForUserRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46229,8 +57290,27 @@ func (s *Server) handlePackagesDeletePackageForUserRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46321,6 +57401,8 @@ func (s *Server) handlePackagesDeletePackageForUserRequest(args [3]string, argsE // // DELETE /user/packages/{package_type}/{package_name}/versions/{package_version_id} func (s *Server) handlePackagesDeletePackageVersionForAuthenticatedUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/delete-package-version-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -46342,7 +57424,16 @@ func (s *Server) handlePackagesDeletePackageVersionForAuthenticatedUserRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46354,8 +57445,27 @@ func (s *Server) handlePackagesDeletePackageVersionForAuthenticatedUserRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46448,6 +57558,8 @@ func (s *Server) handlePackagesDeletePackageVersionForAuthenticatedUserRequest(a // // DELETE /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id} func (s *Server) handlePackagesDeletePackageVersionForOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/delete-package-version-for-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -46469,7 +57581,16 @@ func (s *Server) handlePackagesDeletePackageVersionForOrgRequest(args [4]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46481,8 +57602,27 @@ func (s *Server) handlePackagesDeletePackageVersionForOrgRequest(args [4]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46579,6 +57719,8 @@ func (s *Server) handlePackagesDeletePackageVersionForOrgRequest(args [4]string, // // DELETE /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id} func (s *Server) handlePackagesDeletePackageVersionForUserRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/delete-package-version-for-user"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -46600,7 +57742,16 @@ func (s *Server) handlePackagesDeletePackageVersionForUserRequest(args [4]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46612,8 +57763,27 @@ func (s *Server) handlePackagesDeletePackageVersionForUserRequest(args [4]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46705,6 +57875,8 @@ func (s *Server) handlePackagesDeletePackageVersionForUserRequest(args [4]string // // GET /user/packages/{package_type}/{package_name}/versions func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-all-package-versions-for-package-owned-by-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46726,7 +57898,16 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByAuthenticat startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46738,8 +57919,27 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByAuthenticat var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46835,6 +58035,8 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByAuthenticat // // GET /orgs/{org}/packages/{package_type}/{package_name}/versions func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-all-package-versions-for-package-owned-by-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46856,7 +58058,16 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByOrgRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46868,8 +58079,27 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByOrgRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46969,6 +58199,8 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByOrgRequest( // // GET /users/{username}/packages/{package_type}/{package_name}/versions func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-all-package-versions-for-package-owned-by-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46990,7 +58222,16 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByUserRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47002,8 +58243,27 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByUserRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47091,6 +58351,8 @@ func (s *Server) handlePackagesGetAllPackageVersionsForPackageOwnedByUserRequest // // GET /user/packages/{package_type}/{package_name} func (s *Server) handlePackagesGetPackageForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-package-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47112,7 +58374,16 @@ func (s *Server) handlePackagesGetPackageForAuthenticatedUserRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47124,8 +58395,27 @@ func (s *Server) handlePackagesGetPackageForAuthenticatedUserRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47209,6 +58499,8 @@ func (s *Server) handlePackagesGetPackageForAuthenticatedUserRequest(args [2]str // // GET /orgs/{org}/packages/{package_type}/{package_name} func (s *Server) handlePackagesGetPackageForOrganizationRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-package-for-organization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47230,7 +58522,16 @@ func (s *Server) handlePackagesGetPackageForOrganizationRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47242,8 +58543,27 @@ func (s *Server) handlePackagesGetPackageForOrganizationRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47331,6 +58651,8 @@ func (s *Server) handlePackagesGetPackageForOrganizationRequest(args [3]string, // // GET /users/{username}/packages/{package_type}/{package_name} func (s *Server) handlePackagesGetPackageForUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-package-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47352,7 +58674,16 @@ func (s *Server) handlePackagesGetPackageForUserRequest(args [3]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47364,8 +58695,27 @@ func (s *Server) handlePackagesGetPackageForUserRequest(args [3]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47453,6 +58803,8 @@ func (s *Server) handlePackagesGetPackageForUserRequest(args [3]string, argsEsca // // GET /user/packages/{package_type}/{package_name}/versions/{package_version_id} func (s *Server) handlePackagesGetPackageVersionForAuthenticatedUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-package-version-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47474,7 +58826,16 @@ func (s *Server) handlePackagesGetPackageVersionForAuthenticatedUserRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47486,8 +58847,27 @@ func (s *Server) handlePackagesGetPackageVersionForAuthenticatedUserRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47575,6 +58955,8 @@ func (s *Server) handlePackagesGetPackageVersionForAuthenticatedUserRequest(args // // GET /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id} func (s *Server) handlePackagesGetPackageVersionForOrganizationRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-package-version-for-organization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47596,7 +58978,16 @@ func (s *Server) handlePackagesGetPackageVersionForOrganizationRequest(args [4]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47608,8 +58999,27 @@ func (s *Server) handlePackagesGetPackageVersionForOrganizationRequest(args [4]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47702,6 +59112,8 @@ func (s *Server) handlePackagesGetPackageVersionForOrganizationRequest(args [4]s // // GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id} func (s *Server) handlePackagesGetPackageVersionForUserRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/get-package-version-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47723,7 +59135,16 @@ func (s *Server) handlePackagesGetPackageVersionForUserRequest(args [4]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47735,8 +59156,27 @@ func (s *Server) handlePackagesGetPackageVersionForUserRequest(args [4]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47828,6 +59268,8 @@ func (s *Server) handlePackagesGetPackageVersionForUserRequest(args [4]string, a // // GET /user/packages func (s *Server) handlePackagesListPackagesForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/list-packages-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47849,7 +59291,16 @@ func (s *Server) handlePackagesListPackagesForAuthenticatedUserRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47861,8 +59312,27 @@ func (s *Server) handlePackagesListPackagesForAuthenticatedUserRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47946,6 +59416,8 @@ func (s *Server) handlePackagesListPackagesForAuthenticatedUserRequest(args [0]s // // GET /orgs/{org}/packages func (s *Server) handlePackagesListPackagesForOrganizationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/list-packages-for-organization"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47967,7 +59439,16 @@ func (s *Server) handlePackagesListPackagesForOrganizationRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47979,8 +59460,27 @@ func (s *Server) handlePackagesListPackagesForOrganizationRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48068,6 +59568,8 @@ func (s *Server) handlePackagesListPackagesForOrganizationRequest(args [1]string // // GET /users/{username}/packages func (s *Server) handlePackagesListPackagesForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/list-packages-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48089,7 +59591,16 @@ func (s *Server) handlePackagesListPackagesForUserRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48101,8 +59612,27 @@ func (s *Server) handlePackagesListPackagesForUserRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48197,6 +59727,8 @@ func (s *Server) handlePackagesListPackagesForUserRequest(args [1]string, argsEs // // POST /user/packages/{package_type}/{package_name}/restore func (s *Server) handlePackagesRestorePackageForAuthenticatedUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/restore-package-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48218,7 +59750,16 @@ func (s *Server) handlePackagesRestorePackageForAuthenticatedUserRequest(args [2 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48230,8 +59771,27 @@ func (s *Server) handlePackagesRestorePackageForAuthenticatedUserRequest(args [2 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48328,6 +59888,8 @@ func (s *Server) handlePackagesRestorePackageForAuthenticatedUserRequest(args [2 // // POST /orgs/{org}/packages/{package_type}/{package_name}/restore func (s *Server) handlePackagesRestorePackageForOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/restore-package-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48349,7 +59911,16 @@ func (s *Server) handlePackagesRestorePackageForOrgRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48361,8 +59932,27 @@ func (s *Server) handlePackagesRestorePackageForOrgRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48463,6 +60053,8 @@ func (s *Server) handlePackagesRestorePackageForOrgRequest(args [3]string, argsE // // POST /users/{username}/packages/{package_type}/{package_name}/restore func (s *Server) handlePackagesRestorePackageForUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/restore-package-for-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48484,7 +60076,16 @@ func (s *Server) handlePackagesRestorePackageForUserRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48496,8 +60097,27 @@ func (s *Server) handlePackagesRestorePackageForUserRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48596,6 +60216,8 @@ func (s *Server) handlePackagesRestorePackageForUserRequest(args [3]string, args // // POST /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore func (s *Server) handlePackagesRestorePackageVersionForAuthenticatedUserRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/restore-package-version-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48617,7 +60239,16 @@ func (s *Server) handlePackagesRestorePackageVersionForAuthenticatedUserRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48629,8 +60260,27 @@ func (s *Server) handlePackagesRestorePackageVersionForAuthenticatedUserRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48727,6 +60377,8 @@ func (s *Server) handlePackagesRestorePackageVersionForAuthenticatedUserRequest( // // POST /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore func (s *Server) handlePackagesRestorePackageVersionForOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/restore-package-version-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48748,7 +60400,16 @@ func (s *Server) handlePackagesRestorePackageVersionForOrgRequest(args [4]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48760,8 +60421,27 @@ func (s *Server) handlePackagesRestorePackageVersionForOrgRequest(args [4]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48862,6 +60542,8 @@ func (s *Server) handlePackagesRestorePackageVersionForOrgRequest(args [4]string // // POST /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore func (s *Server) handlePackagesRestorePackageVersionForUserRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("packages/restore-package-version-for-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48883,7 +60565,16 @@ func (s *Server) handlePackagesRestorePackageVersionForUserRequest(args [4]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48895,8 +60586,27 @@ func (s *Server) handlePackagesRestorePackageVersionForUserRequest(args [4]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48987,6 +60697,8 @@ func (s *Server) handlePackagesRestorePackageVersionForUserRequest(args [4]strin // // PUT /projects/{project_id}/collaborators/{username} func (s *Server) handleProjectsAddCollaboratorRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/add-collaborator"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -49008,7 +60720,16 @@ func (s *Server) handleProjectsAddCollaboratorRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49020,8 +60741,27 @@ func (s *Server) handleProjectsAddCollaboratorRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49118,6 +60858,8 @@ func (s *Server) handleProjectsAddCollaboratorRequest(args [2]string, argsEscape // // POST /projects/{project_id}/columns func (s *Server) handleProjectsCreateColumnRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/create-column"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49139,7 +60881,16 @@ func (s *Server) handleProjectsCreateColumnRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49151,8 +60902,27 @@ func (s *Server) handleProjectsCreateColumnRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49245,6 +61015,8 @@ func (s *Server) handleProjectsCreateColumnRequest(args [1]string, argsEscaped b // // POST /user/projects func (s *Server) handleProjectsCreateForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/create-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49266,7 +61038,16 @@ func (s *Server) handleProjectsCreateForAuthenticatedUserRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49278,8 +61059,27 @@ func (s *Server) handleProjectsCreateForAuthenticatedUserRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49359,6 +61159,8 @@ func (s *Server) handleProjectsCreateForAuthenticatedUserRequest(args [0]string, // // POST /orgs/{org}/projects func (s *Server) handleProjectsCreateForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/create-for-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49380,7 +61182,16 @@ func (s *Server) handleProjectsCreateForOrgRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49392,8 +61203,27 @@ func (s *Server) handleProjectsCreateForOrgRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49488,6 +61318,8 @@ func (s *Server) handleProjectsCreateForOrgRequest(args [1]string, argsEscaped b // // POST /repos/{owner}/{repo}/projects func (s *Server) handleProjectsCreateForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/create-for-repo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49509,7 +61341,16 @@ func (s *Server) handleProjectsCreateForRepoRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49521,8 +61362,27 @@ func (s *Server) handleProjectsCreateForRepoRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49619,6 +61479,8 @@ func (s *Server) handleProjectsCreateForRepoRequest(args [2]string, argsEscaped // // DELETE /projects/{project_id} func (s *Server) handleProjectsDeleteRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/delete"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -49640,7 +61502,16 @@ func (s *Server) handleProjectsDeleteRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49652,8 +61523,27 @@ func (s *Server) handleProjectsDeleteRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49731,6 +61621,8 @@ func (s *Server) handleProjectsDeleteRequest(args [1]string, argsEscaped bool, w // // DELETE /projects/columns/cards/{card_id} func (s *Server) handleProjectsDeleteCardRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/delete-card"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -49752,7 +61644,16 @@ func (s *Server) handleProjectsDeleteCardRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49764,8 +61665,27 @@ func (s *Server) handleProjectsDeleteCardRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49843,6 +61763,8 @@ func (s *Server) handleProjectsDeleteCardRequest(args [1]string, argsEscaped boo // // DELETE /projects/columns/{column_id} func (s *Server) handleProjectsDeleteColumnRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/delete-column"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -49864,7 +61786,16 @@ func (s *Server) handleProjectsDeleteColumnRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49876,8 +61807,27 @@ func (s *Server) handleProjectsDeleteColumnRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49957,6 +61907,8 @@ func (s *Server) handleProjectsDeleteColumnRequest(args [1]string, argsEscaped b // // GET /projects/{project_id} func (s *Server) handleProjectsGetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49978,7 +61930,16 @@ func (s *Server) handleProjectsGetRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49990,8 +61951,27 @@ func (s *Server) handleProjectsGetRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50069,6 +62049,8 @@ func (s *Server) handleProjectsGetRequest(args [1]string, argsEscaped bool, w ht // // GET /projects/columns/cards/{card_id} func (s *Server) handleProjectsGetCardRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/get-card"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50090,7 +62072,16 @@ func (s *Server) handleProjectsGetCardRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50102,8 +62093,27 @@ func (s *Server) handleProjectsGetCardRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50181,6 +62191,8 @@ func (s *Server) handleProjectsGetCardRequest(args [1]string, argsEscaped bool, // // GET /projects/columns/{column_id} func (s *Server) handleProjectsGetColumnRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/get-column"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50202,7 +62214,16 @@ func (s *Server) handleProjectsGetColumnRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50214,8 +62235,27 @@ func (s *Server) handleProjectsGetColumnRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50295,6 +62335,8 @@ func (s *Server) handleProjectsGetColumnRequest(args [1]string, argsEscaped bool // // GET /projects/{project_id}/collaborators/{username}/permission func (s *Server) handleProjectsGetPermissionForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/get-permission-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50316,7 +62358,16 @@ func (s *Server) handleProjectsGetPermissionForUserRequest(args [2]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50328,8 +62379,27 @@ func (s *Server) handleProjectsGetPermissionForUserRequest(args [2]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50411,6 +62481,8 @@ func (s *Server) handleProjectsGetPermissionForUserRequest(args [2]string, argsE // // GET /projects/columns/{column_id}/cards func (s *Server) handleProjectsListCardsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/list-cards"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50432,7 +62504,16 @@ func (s *Server) handleProjectsListCardsRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50444,8 +62525,27 @@ func (s *Server) handleProjectsListCardsRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50539,6 +62639,8 @@ func (s *Server) handleProjectsListCardsRequest(args [1]string, argsEscaped bool // // GET /projects/{project_id}/collaborators func (s *Server) handleProjectsListCollaboratorsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/list-collaborators"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50560,7 +62662,16 @@ func (s *Server) handleProjectsListCollaboratorsRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50572,8 +62683,27 @@ func (s *Server) handleProjectsListCollaboratorsRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50663,6 +62793,8 @@ func (s *Server) handleProjectsListCollaboratorsRequest(args [1]string, argsEsca // // GET /projects/{project_id}/columns func (s *Server) handleProjectsListColumnsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/list-columns"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50684,7 +62816,16 @@ func (s *Server) handleProjectsListColumnsRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50696,8 +62837,27 @@ func (s *Server) handleProjectsListColumnsRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50785,6 +62945,8 @@ func (s *Server) handleProjectsListColumnsRequest(args [1]string, argsEscaped bo // // GET /orgs/{org}/projects func (s *Server) handleProjectsListForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/list-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50806,7 +62968,16 @@ func (s *Server) handleProjectsListForOrgRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50818,8 +62989,27 @@ func (s *Server) handleProjectsListForOrgRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50911,6 +63101,8 @@ func (s *Server) handleProjectsListForOrgRequest(args [1]string, argsEscaped boo // // GET /repos/{owner}/{repo}/projects func (s *Server) handleProjectsListForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/list-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50932,7 +63124,16 @@ func (s *Server) handleProjectsListForRepoRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50944,8 +63145,27 @@ func (s *Server) handleProjectsListForRepoRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51039,6 +63259,8 @@ func (s *Server) handleProjectsListForRepoRequest(args [2]string, argsEscaped bo // // GET /users/{username}/projects func (s *Server) handleProjectsListForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/list-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51060,7 +63282,16 @@ func (s *Server) handleProjectsListForUserRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51072,8 +63303,27 @@ func (s *Server) handleProjectsListForUserRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51163,6 +63413,8 @@ func (s *Server) handleProjectsListForUserRequest(args [1]string, argsEscaped bo // // POST /projects/columns/cards/{card_id}/moves func (s *Server) handleProjectsMoveCardRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/move-card"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51184,7 +63436,16 @@ func (s *Server) handleProjectsMoveCardRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51196,8 +63457,27 @@ func (s *Server) handleProjectsMoveCardRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51290,6 +63570,8 @@ func (s *Server) handleProjectsMoveCardRequest(args [1]string, argsEscaped bool, // // POST /projects/columns/{column_id}/moves func (s *Server) handleProjectsMoveColumnRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/move-column"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51311,7 +63593,16 @@ func (s *Server) handleProjectsMoveColumnRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51323,8 +63614,27 @@ func (s *Server) handleProjectsMoveColumnRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51418,6 +63728,8 @@ func (s *Server) handleProjectsMoveColumnRequest(args [1]string, argsEscaped boo // // DELETE /projects/{project_id}/collaborators/{username} func (s *Server) handleProjectsRemoveCollaboratorRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/remove-collaborator"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -51439,7 +63751,16 @@ func (s *Server) handleProjectsRemoveCollaboratorRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51451,8 +63772,27 @@ func (s *Server) handleProjectsRemoveCollaboratorRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51536,6 +63876,8 @@ func (s *Server) handleProjectsRemoveCollaboratorRequest(args [2]string, argsEsc // // PATCH /projects/{project_id} func (s *Server) handleProjectsUpdateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/update"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -51557,7 +63899,16 @@ func (s *Server) handleProjectsUpdateRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51569,8 +63920,27 @@ func (s *Server) handleProjectsUpdateRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51663,6 +64033,8 @@ func (s *Server) handleProjectsUpdateRequest(args [1]string, argsEscaped bool, w // // PATCH /projects/columns/cards/{card_id} func (s *Server) handleProjectsUpdateCardRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/update-card"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -51684,7 +64056,16 @@ func (s *Server) handleProjectsUpdateCardRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51696,8 +64077,27 @@ func (s *Server) handleProjectsUpdateCardRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51790,6 +64190,8 @@ func (s *Server) handleProjectsUpdateCardRequest(args [1]string, argsEscaped boo // // PATCH /projects/columns/{column_id} func (s *Server) handleProjectsUpdateColumnRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("projects/update-column"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -51811,7 +64213,16 @@ func (s *Server) handleProjectsUpdateColumnRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51823,8 +64234,27 @@ func (s *Server) handleProjectsUpdateColumnRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51917,6 +64347,8 @@ func (s *Server) handleProjectsUpdateColumnRequest(args [1]string, argsEscaped b // // GET /repos/{owner}/{repo}/pulls/{pull_number}/merge func (s *Server) handlePullsCheckIfMergedRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/check-if-merged"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51938,7 +64370,16 @@ func (s *Server) handlePullsCheckIfMergedRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51950,8 +64391,27 @@ func (s *Server) handlePullsCheckIfMergedRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52052,6 +64512,8 @@ func (s *Server) handlePullsCheckIfMergedRequest(args [3]string, argsEscaped boo // // POST /repos/{owner}/{repo}/pulls func (s *Server) handlePullsCreateRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/create"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52073,7 +64535,16 @@ func (s *Server) handlePullsCreateRequest(args [2]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52085,8 +64556,27 @@ func (s *Server) handlePullsCreateRequest(args [2]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52192,6 +64682,8 @@ func (s *Server) handlePullsCreateRequest(args [2]string, argsEscaped bool, w ht // // POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies func (s *Server) handlePullsCreateReplyForReviewCommentRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/create-reply-for-review-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52213,7 +64705,16 @@ func (s *Server) handlePullsCreateReplyForReviewCommentRequest(args [4]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52225,8 +64726,27 @@ func (s *Server) handlePullsCreateReplyForReviewCommentRequest(args [4]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52349,6 +64869,8 @@ func (s *Server) handlePullsCreateReplyForReviewCommentRequest(args [4]string, a // // POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews func (s *Server) handlePullsCreateReviewRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/create-review"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52370,7 +64892,16 @@ func (s *Server) handlePullsCreateReviewRequest(args [3]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52382,8 +64913,27 @@ func (s *Server) handlePullsCreateReviewRequest(args [3]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52503,6 +65053,8 @@ func (s *Server) handlePullsCreateReviewRequest(args [3]string, argsEscaped bool // // POST /repos/{owner}/{repo}/pulls/{pull_number}/comments func (s *Server) handlePullsCreateReviewCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/create-review-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52524,7 +65076,16 @@ func (s *Server) handlePullsCreateReviewCommentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52536,8 +65097,27 @@ func (s *Server) handlePullsCreateReviewCommentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52638,6 +65218,8 @@ func (s *Server) handlePullsCreateReviewCommentRequest(args [3]string, argsEscap // // DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} func (s *Server) handlePullsDeletePendingReviewRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/delete-pending-review"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -52659,7 +65241,16 @@ func (s *Server) handlePullsDeletePendingReviewRequest(args [4]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52671,8 +65262,27 @@ func (s *Server) handlePullsDeletePendingReviewRequest(args [4]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52762,6 +65372,8 @@ func (s *Server) handlePullsDeletePendingReviewRequest(args [4]string, argsEscap // // DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id} func (s *Server) handlePullsDeleteReviewCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/delete-review-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -52783,7 +65395,16 @@ func (s *Server) handlePullsDeleteReviewCommentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52795,8 +65416,27 @@ func (s *Server) handlePullsDeleteReviewCommentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52884,6 +65524,8 @@ func (s *Server) handlePullsDeleteReviewCommentRequest(args [3]string, argsEscap // // PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals func (s *Server) handlePullsDismissReviewRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/dismiss-review"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -52905,7 +65547,16 @@ func (s *Server) handlePullsDismissReviewRequest(args [4]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52917,8 +65568,27 @@ func (s *Server) handlePullsDismissReviewRequest(args [4]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53056,6 +65726,8 @@ func (s *Server) handlePullsDismissReviewRequest(args [4]string, argsEscaped boo // // GET /repos/{owner}/{repo}/pulls/{pull_number} func (s *Server) handlePullsGetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53077,7 +65749,16 @@ func (s *Server) handlePullsGetRequest(args [3]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53089,8 +65770,27 @@ func (s *Server) handlePullsGetRequest(args [3]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53176,6 +65876,8 @@ func (s *Server) handlePullsGetRequest(args [3]string, argsEscaped bool, w http. // // GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} func (s *Server) handlePullsGetReviewRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/get-review"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53197,7 +65899,16 @@ func (s *Server) handlePullsGetReviewRequest(args [4]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53209,8 +65920,27 @@ func (s *Server) handlePullsGetReviewRequest(args [4]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53300,6 +66030,8 @@ func (s *Server) handlePullsGetReviewRequest(args [4]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/pulls/comments/{comment_id} func (s *Server) handlePullsGetReviewCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/get-review-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53321,7 +66053,16 @@ func (s *Server) handlePullsGetReviewCommentRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53333,8 +66074,27 @@ func (s *Server) handlePullsGetReviewCommentRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53424,6 +66184,8 @@ func (s *Server) handlePullsGetReviewCommentRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/pulls func (s *Server) handlePullsListRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53445,7 +66207,16 @@ func (s *Server) handlePullsListRequest(args [2]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53457,8 +66228,27 @@ func (s *Server) handlePullsListRequest(args [2]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53568,6 +66358,8 @@ func (s *Server) handlePullsListRequest(args [2]string, argsEscaped bool, w http // // GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments func (s *Server) handlePullsListCommentsForReviewRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-comments-for-review"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53589,7 +66381,16 @@ func (s *Server) handlePullsListCommentsForReviewRequest(args [4]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53601,8 +66402,27 @@ func (s *Server) handlePullsListCommentsForReviewRequest(args [4]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53702,6 +66522,8 @@ func (s *Server) handlePullsListCommentsForReviewRequest(args [4]string, argsEsc // // GET /repos/{owner}/{repo}/pulls/{pull_number}/commits func (s *Server) handlePullsListCommitsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-commits"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53723,7 +66545,16 @@ func (s *Server) handlePullsListCommitsRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53735,8 +66566,27 @@ func (s *Server) handlePullsListCommitsRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53831,6 +66681,8 @@ func (s *Server) handlePullsListCommitsRequest(args [3]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/pulls/{pull_number}/files func (s *Server) handlePullsListFilesRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-files"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53852,7 +66704,16 @@ func (s *Server) handlePullsListFilesRequest(args [3]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53864,8 +66725,27 @@ func (s *Server) handlePullsListFilesRequest(args [3]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53959,6 +66839,8 @@ func (s *Server) handlePullsListFilesRequest(args [3]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers func (s *Server) handlePullsListRequestedReviewersRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-requested-reviewers"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53980,7 +66862,16 @@ func (s *Server) handlePullsListRequestedReviewersRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53992,8 +66883,27 @@ func (s *Server) handlePullsListRequestedReviewersRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54088,6 +66998,8 @@ func (s *Server) handlePullsListRequestedReviewersRequest(args [3]string, argsEs // // GET /repos/{owner}/{repo}/pulls/{pull_number}/comments func (s *Server) handlePullsListReviewCommentsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-review-comments"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54109,7 +67021,16 @@ func (s *Server) handlePullsListReviewCommentsRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54121,8 +67042,27 @@ func (s *Server) handlePullsListReviewCommentsRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54229,6 +67169,8 @@ func (s *Server) handlePullsListReviewCommentsRequest(args [3]string, argsEscape // // GET /repos/{owner}/{repo}/pulls/comments func (s *Server) handlePullsListReviewCommentsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-review-comments-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54250,7 +67192,16 @@ func (s *Server) handlePullsListReviewCommentsForRepoRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54262,8 +67213,27 @@ func (s *Server) handlePullsListReviewCommentsForRepoRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54365,6 +67335,8 @@ func (s *Server) handlePullsListReviewCommentsForRepoRequest(args [2]string, arg // // GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews func (s *Server) handlePullsListReviewsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/list-reviews"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54386,7 +67358,16 @@ func (s *Server) handlePullsListReviewsRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54398,8 +67379,27 @@ func (s *Server) handlePullsListReviewsRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54499,6 +67499,8 @@ func (s *Server) handlePullsListReviewsRequest(args [3]string, argsEscaped bool, // // PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge func (s *Server) handlePullsMergeRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/merge"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -54520,7 +67522,16 @@ func (s *Server) handlePullsMergeRequest(args [3]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54532,8 +67543,27 @@ func (s *Server) handlePullsMergeRequest(args [3]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54634,6 +67664,8 @@ func (s *Server) handlePullsMergeRequest(args [3]string, argsEscaped bool, w htt // // DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers func (s *Server) handlePullsRemoveRequestedReviewersRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/remove-requested-reviewers"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -54655,7 +67687,16 @@ func (s *Server) handlePullsRemoveRequestedReviewersRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54667,8 +67708,27 @@ func (s *Server) handlePullsRemoveRequestedReviewersRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54769,6 +67829,8 @@ func (s *Server) handlePullsRemoveRequestedReviewersRequest(args [3]string, args // // POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events func (s *Server) handlePullsSubmitReviewRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/submit-review"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54790,7 +67852,16 @@ func (s *Server) handlePullsSubmitReviewRequest(args [4]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54802,8 +67873,27 @@ func (s *Server) handlePullsSubmitReviewRequest(args [4]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54915,6 +68005,8 @@ func (s *Server) handlePullsSubmitReviewRequest(args [4]string, argsEscaped bool // // PATCH /repos/{owner}/{repo}/pulls/{pull_number} func (s *Server) handlePullsUpdateRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/update"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -54936,7 +68028,16 @@ func (s *Server) handlePullsUpdateRequest(args [3]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54948,8 +68049,27 @@ func (s *Server) handlePullsUpdateRequest(args [3]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55051,6 +68171,8 @@ func (s *Server) handlePullsUpdateRequest(args [3]string, argsEscaped bool, w ht // // PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch func (s *Server) handlePullsUpdateBranchRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/update-branch"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -55072,7 +68194,16 @@ func (s *Server) handlePullsUpdateBranchRequest(args [3]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55084,8 +68215,27 @@ func (s *Server) handlePullsUpdateBranchRequest(args [3]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55186,6 +68336,8 @@ func (s *Server) handlePullsUpdateBranchRequest(args [3]string, argsEscaped bool // // PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} func (s *Server) handlePullsUpdateReviewRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/update-review"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -55207,7 +68359,16 @@ func (s *Server) handlePullsUpdateReviewRequest(args [4]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55219,8 +68380,27 @@ func (s *Server) handlePullsUpdateReviewRequest(args [4]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55325,6 +68505,8 @@ func (s *Server) handlePullsUpdateReviewRequest(args [4]string, argsEscaped bool // // PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id} func (s *Server) handlePullsUpdateReviewCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pulls/update-review-comment"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -55346,7 +68528,16 @@ func (s *Server) handlePullsUpdateReviewCommentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55358,8 +68549,27 @@ func (s *Server) handlePullsUpdateReviewCommentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55463,6 +68673,8 @@ func (s *Server) handlePullsUpdateReviewCommentRequest(args [3]string, argsEscap // // GET /rate_limit func (s *Server) handleRateLimitGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("rate-limit/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -55484,7 +68696,16 @@ func (s *Server) handleRateLimitGetRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55496,8 +68717,27 @@ func (s *Server) handleRateLimitGetRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -55558,6 +68798,8 @@ func (s *Server) handleRateLimitGetRequest(args [0]string, argsEscaped bool, w h // // POST /repos/{owner}/{repo}/comments/{comment_id}/reactions func (s *Server) handleReactionsCreateForCommitCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-commit-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55579,7 +68821,16 @@ func (s *Server) handleReactionsCreateForCommitCommentRequest(args [3]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55591,8 +68842,27 @@ func (s *Server) handleReactionsCreateForCommitCommentRequest(args [3]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55694,6 +68964,8 @@ func (s *Server) handleReactionsCreateForCommitCommentRequest(args [3]string, ar // // POST /repos/{owner}/{repo}/issues/{issue_number}/reactions func (s *Server) handleReactionsCreateForIssueRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-issue"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55715,7 +68987,16 @@ func (s *Server) handleReactionsCreateForIssueRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55727,8 +69008,27 @@ func (s *Server) handleReactionsCreateForIssueRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55831,6 +69131,8 @@ func (s *Server) handleReactionsCreateForIssueRequest(args [3]string, argsEscape // // POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions func (s *Server) handleReactionsCreateForIssueCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-issue-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55852,7 +69154,16 @@ func (s *Server) handleReactionsCreateForIssueCommentRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55864,8 +69175,27 @@ func (s *Server) handleReactionsCreateForIssueCommentRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55968,6 +69298,8 @@ func (s *Server) handleReactionsCreateForIssueCommentRequest(args [3]string, arg // // POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions func (s *Server) handleReactionsCreateForPullRequestReviewCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-pull-request-review-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55989,7 +69321,16 @@ func (s *Server) handleReactionsCreateForPullRequestReviewCommentRequest(args [3 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56001,8 +69342,27 @@ func (s *Server) handleReactionsCreateForPullRequestReviewCommentRequest(args [3 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56104,6 +69464,8 @@ func (s *Server) handleReactionsCreateForPullRequestReviewCommentRequest(args [3 // // POST /repos/{owner}/{repo}/releases/{release_id}/reactions func (s *Server) handleReactionsCreateForReleaseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-release"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56125,7 +69487,16 @@ func (s *Server) handleReactionsCreateForReleaseRequest(args [3]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56137,8 +69508,27 @@ func (s *Server) handleReactionsCreateForReleaseRequest(args [3]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56245,6 +69635,8 @@ func (s *Server) handleReactionsCreateForReleaseRequest(args [3]string, argsEsca // // POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions func (s *Server) handleReactionsCreateForTeamDiscussionCommentInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-team-discussion-comment-in-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56266,7 +69658,16 @@ func (s *Server) handleReactionsCreateForTeamDiscussionCommentInOrgRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56278,8 +69679,27 @@ func (s *Server) handleReactionsCreateForTeamDiscussionCommentInOrgRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56394,6 +69814,8 @@ func (s *Server) handleReactionsCreateForTeamDiscussionCommentInOrgRequest(args // // POST /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions func (s *Server) handleReactionsCreateForTeamDiscussionCommentLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-team-discussion-comment-legacy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56415,7 +69837,16 @@ func (s *Server) handleReactionsCreateForTeamDiscussionCommentLegacyRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56427,8 +69858,27 @@ func (s *Server) handleReactionsCreateForTeamDiscussionCommentLegacyRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56536,6 +69986,8 @@ func (s *Server) handleReactionsCreateForTeamDiscussionCommentLegacyRequest(args // // POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions func (s *Server) handleReactionsCreateForTeamDiscussionInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-team-discussion-in-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56557,7 +70009,16 @@ func (s *Server) handleReactionsCreateForTeamDiscussionInOrgRequest(args [3]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56569,8 +70030,27 @@ func (s *Server) handleReactionsCreateForTeamDiscussionInOrgRequest(args [3]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56682,6 +70162,8 @@ func (s *Server) handleReactionsCreateForTeamDiscussionInOrgRequest(args [3]stri // // POST /teams/{team_id}/discussions/{discussion_number}/reactions func (s *Server) handleReactionsCreateForTeamDiscussionLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/create-for-team-discussion-legacy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56703,7 +70185,16 @@ func (s *Server) handleReactionsCreateForTeamDiscussionLegacyRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56715,8 +70206,27 @@ func (s *Server) handleReactionsCreateForTeamDiscussionLegacyRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56815,6 +70325,8 @@ func (s *Server) handleReactionsCreateForTeamDiscussionLegacyRequest(args [2]str // // DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id} func (s *Server) handleReactionsDeleteForCommitCommentRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-for-commit-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -56836,7 +70348,16 @@ func (s *Server) handleReactionsDeleteForCommitCommentRequest(args [4]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56848,8 +70369,27 @@ func (s *Server) handleReactionsDeleteForCommitCommentRequest(args [4]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56941,6 +70481,8 @@ func (s *Server) handleReactionsDeleteForCommitCommentRequest(args [4]string, ar // // DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id} func (s *Server) handleReactionsDeleteForIssueRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-for-issue"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -56962,7 +70504,16 @@ func (s *Server) handleReactionsDeleteForIssueRequest(args [4]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56974,8 +70525,27 @@ func (s *Server) handleReactionsDeleteForIssueRequest(args [4]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57067,6 +70637,8 @@ func (s *Server) handleReactionsDeleteForIssueRequest(args [4]string, argsEscape // // DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id} func (s *Server) handleReactionsDeleteForIssueCommentRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-for-issue-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -57088,7 +70660,16 @@ func (s *Server) handleReactionsDeleteForIssueCommentRequest(args [4]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57100,8 +70681,27 @@ func (s *Server) handleReactionsDeleteForIssueCommentRequest(args [4]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57194,6 +70794,8 @@ func (s *Server) handleReactionsDeleteForIssueCommentRequest(args [4]string, arg // // DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id} func (s *Server) handleReactionsDeleteForPullRequestCommentRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-for-pull-request-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -57215,7 +70817,16 @@ func (s *Server) handleReactionsDeleteForPullRequestCommentRequest(args [4]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57227,8 +70838,27 @@ func (s *Server) handleReactionsDeleteForPullRequestCommentRequest(args [4]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57325,6 +70955,8 @@ func (s *Server) handleReactionsDeleteForPullRequestCommentRequest(args [4]strin // // DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id} func (s *Server) handleReactionsDeleteForTeamDiscussionRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-for-team-discussion"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -57346,7 +70978,16 @@ func (s *Server) handleReactionsDeleteForTeamDiscussionRequest(args [4]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57358,8 +70999,27 @@ func (s *Server) handleReactionsDeleteForTeamDiscussionRequest(args [4]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57454,6 +71114,8 @@ func (s *Server) handleReactionsDeleteForTeamDiscussionRequest(args [4]string, a // // DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id} func (s *Server) handleReactionsDeleteForTeamDiscussionCommentRequest(args [5]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-for-team-discussion-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -57475,7 +71137,16 @@ func (s *Server) handleReactionsDeleteForTeamDiscussionCommentRequest(args [5]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57487,8 +71158,27 @@ func (s *Server) handleReactionsDeleteForTeamDiscussionCommentRequest(args [5]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57591,6 +71281,8 @@ func (s *Server) handleReactionsDeleteForTeamDiscussionCommentRequest(args [5]st // // DELETE /reactions/{reaction_id} func (s *Server) handleReactionsDeleteLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/delete-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -57612,7 +71304,16 @@ func (s *Server) handleReactionsDeleteLegacyRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57624,8 +71325,27 @@ func (s *Server) handleReactionsDeleteLegacyRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57703,6 +71423,8 @@ func (s *Server) handleReactionsDeleteLegacyRequest(args [1]string, argsEscaped // // GET /repos/{owner}/{repo}/comments/{comment_id}/reactions func (s *Server) handleReactionsListForCommitCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-commit-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57724,7 +71446,16 @@ func (s *Server) handleReactionsListForCommitCommentRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57736,8 +71467,27 @@ func (s *Server) handleReactionsListForCommitCommentRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57835,6 +71585,8 @@ func (s *Server) handleReactionsListForCommitCommentRequest(args [3]string, args // // GET /repos/{owner}/{repo}/issues/{issue_number}/reactions func (s *Server) handleReactionsListForIssueRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-issue"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57856,7 +71608,16 @@ func (s *Server) handleReactionsListForIssueRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57868,8 +71629,27 @@ func (s *Server) handleReactionsListForIssueRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57967,6 +71747,8 @@ func (s *Server) handleReactionsListForIssueRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions func (s *Server) handleReactionsListForIssueCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-issue-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57988,7 +71770,16 @@ func (s *Server) handleReactionsListForIssueCommentRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58000,8 +71791,27 @@ func (s *Server) handleReactionsListForIssueCommentRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58100,6 +71910,8 @@ func (s *Server) handleReactionsListForIssueCommentRequest(args [3]string, argsE // // GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions func (s *Server) handleReactionsListForPullRequestReviewCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-pull-request-review-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58121,7 +71933,16 @@ func (s *Server) handleReactionsListForPullRequestReviewCommentRequest(args [3]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58133,8 +71954,27 @@ func (s *Server) handleReactionsListForPullRequestReviewCommentRequest(args [3]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58236,6 +72076,8 @@ func (s *Server) handleReactionsListForPullRequestReviewCommentRequest(args [3]s // // GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions func (s *Server) handleReactionsListForTeamDiscussionCommentInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-team-discussion-comment-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58257,7 +72099,16 @@ func (s *Server) handleReactionsListForTeamDiscussionCommentInOrgRequest(args [4 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58269,8 +72120,27 @@ func (s *Server) handleReactionsListForTeamDiscussionCommentInOrgRequest(args [4 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58380,6 +72250,8 @@ func (s *Server) handleReactionsListForTeamDiscussionCommentInOrgRequest(args [4 // // GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions func (s *Server) handleReactionsListForTeamDiscussionCommentLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-team-discussion-comment-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58401,7 +72273,16 @@ func (s *Server) handleReactionsListForTeamDiscussionCommentLegacyRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58413,8 +72294,27 @@ func (s *Server) handleReactionsListForTeamDiscussionCommentLegacyRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58516,6 +72416,8 @@ func (s *Server) handleReactionsListForTeamDiscussionCommentLegacyRequest(args [ // // GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions func (s *Server) handleReactionsListForTeamDiscussionInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-team-discussion-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58537,7 +72439,16 @@ func (s *Server) handleReactionsListForTeamDiscussionInOrgRequest(args [3]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58549,8 +72460,27 @@ func (s *Server) handleReactionsListForTeamDiscussionInOrgRequest(args [3]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58656,6 +72586,8 @@ func (s *Server) handleReactionsListForTeamDiscussionInOrgRequest(args [3]string // // GET /teams/{team_id}/discussions/{discussion_number}/reactions func (s *Server) handleReactionsListForTeamDiscussionLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("reactions/list-for-team-discussion-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58677,7 +72609,16 @@ func (s *Server) handleReactionsListForTeamDiscussionLegacyRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58689,8 +72630,27 @@ func (s *Server) handleReactionsListForTeamDiscussionLegacyRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58784,6 +72744,8 @@ func (s *Server) handleReactionsListForTeamDiscussionLegacyRequest(args [2]strin // // PATCH /user/repository_invitations/{invitation_id} func (s *Server) handleReposAcceptInvitationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/accept-invitation"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -58805,7 +72767,16 @@ func (s *Server) handleReposAcceptInvitationRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58817,8 +72788,27 @@ func (s *Server) handleReposAcceptInvitationRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58910,6 +72900,8 @@ func (s *Server) handleReposAcceptInvitationRequest(args [1]string, argsEscaped // // POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps func (s *Server) handleReposAddAppAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/add-app-access-restrictions"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58931,7 +72923,16 @@ func (s *Server) handleReposAddAppAccessRestrictionsRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58943,8 +72944,27 @@ func (s *Server) handleReposAddAppAccessRestrictionsRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59064,6 +73084,8 @@ func (s *Server) handleReposAddAppAccessRestrictionsRequest(args [3]string, args // // PUT /repos/{owner}/{repo}/collaborators/{username} func (s *Server) handleReposAddCollaboratorRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/add-collaborator"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -59085,7 +73107,16 @@ func (s *Server) handleReposAddCollaboratorRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59097,8 +73128,27 @@ func (s *Server) handleReposAddCollaboratorRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59203,6 +73253,8 @@ func (s *Server) handleReposAddCollaboratorRequest(args [3]string, argsEscaped b // // POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts func (s *Server) handleReposAddStatusCheckContextsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/add-status-check-contexts"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59224,7 +73276,16 @@ func (s *Server) handleReposAddStatusCheckContextsRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59236,8 +73297,27 @@ func (s *Server) handleReposAddStatusCheckContextsRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59352,6 +73432,8 @@ func (s *Server) handleReposAddStatusCheckContextsRequest(args [3]string, argsEs // // POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams func (s *Server) handleReposAddTeamAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/add-team-access-restrictions"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59373,7 +73455,16 @@ func (s *Server) handleReposAddTeamAccessRestrictionsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59385,8 +73476,27 @@ func (s *Server) handleReposAddTeamAccessRestrictionsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59500,6 +73610,8 @@ func (s *Server) handleReposAddTeamAccessRestrictionsRequest(args [3]string, arg // // POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users func (s *Server) handleReposAddUserAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/add-user-access-restrictions"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59521,7 +73633,16 @@ func (s *Server) handleReposAddUserAccessRestrictionsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59533,8 +73654,27 @@ func (s *Server) handleReposAddUserAccessRestrictionsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59639,6 +73779,8 @@ func (s *Server) handleReposAddUserAccessRestrictionsRequest(args [3]string, arg // // GET /repos/{owner}/{repo}/collaborators/{username} func (s *Server) handleReposCheckCollaboratorRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/check-collaborator"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59660,7 +73802,16 @@ func (s *Server) handleReposCheckCollaboratorRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59672,8 +73823,27 @@ func (s *Server) handleReposCheckCollaboratorRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59762,6 +73932,8 @@ func (s *Server) handleReposCheckCollaboratorRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/vulnerability-alerts func (s *Server) handleReposCheckVulnerabilityAlertsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/check-vulnerability-alerts"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59783,7 +73955,16 @@ func (s *Server) handleReposCheckVulnerabilityAlertsRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59795,8 +73976,27 @@ func (s *Server) handleReposCheckVulnerabilityAlertsRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59932,6 +74132,8 @@ func (s *Server) handleReposCheckVulnerabilityAlertsRequest(args [2]string, args // // GET /repos/{owner}/{repo}/compare/{basehead} func (s *Server) handleReposCompareCommitsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/compare-commits"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59953,7 +74155,16 @@ func (s *Server) handleReposCompareCommitsRequest(args [3]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59965,8 +74176,27 @@ func (s *Server) handleReposCompareCommitsRequest(args [3]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60060,6 +74290,8 @@ func (s *Server) handleReposCompareCommitsRequest(args [3]string, argsEscaped bo // // POST /repos/{owner}/{repo}/autolinks func (s *Server) handleReposCreateAutolinkRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-autolink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60081,7 +74313,16 @@ func (s *Server) handleReposCreateAutolinkRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60093,8 +74334,27 @@ func (s *Server) handleReposCreateAutolinkRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60198,6 +74458,8 @@ func (s *Server) handleReposCreateAutolinkRequest(args [2]string, argsEscaped bo // // POST /repos/{owner}/{repo}/commits/{commit_sha}/comments func (s *Server) handleReposCreateCommitCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-commit-comment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60219,7 +74481,16 @@ func (s *Server) handleReposCreateCommitCommentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60231,8 +74502,27 @@ func (s *Server) handleReposCreateCommitCommentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60339,6 +74629,8 @@ func (s *Server) handleReposCreateCommitCommentRequest(args [3]string, argsEscap // // POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures func (s *Server) handleReposCreateCommitSignatureProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-commit-signature-protection"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60360,7 +74652,16 @@ func (s *Server) handleReposCreateCommitSignatureProtectionRequest(args [3]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60372,8 +74673,27 @@ func (s *Server) handleReposCreateCommitSignatureProtectionRequest(args [3]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60461,6 +74781,8 @@ func (s *Server) handleReposCreateCommitSignatureProtectionRequest(args [3]strin // // POST /repos/{owner}/{repo}/statuses/{sha} func (s *Server) handleReposCreateCommitStatusRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-commit-status"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60482,7 +74804,16 @@ func (s *Server) handleReposCreateCommitStatusRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60494,8 +74825,27 @@ func (s *Server) handleReposCreateCommitStatusRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60596,6 +74946,8 @@ func (s *Server) handleReposCreateCommitStatusRequest(args [3]string, argsEscape // // POST /repos/{owner}/{repo}/keys func (s *Server) handleReposCreateDeployKeyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-deploy-key"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60617,7 +74969,16 @@ func (s *Server) handleReposCreateDeployKeyRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60629,8 +74990,27 @@ func (s *Server) handleReposCreateDeployKeyRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60782,6 +75162,8 @@ func (s *Server) handleReposCreateDeployKeyRequest(args [2]string, argsEscaped b // // POST /repos/{owner}/{repo}/deployments func (s *Server) handleReposCreateDeploymentRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-deployment"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60803,7 +75185,16 @@ func (s *Server) handleReposCreateDeploymentRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60815,8 +75206,27 @@ func (s *Server) handleReposCreateDeploymentRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60915,6 +75325,8 @@ func (s *Server) handleReposCreateDeploymentRequest(args [2]string, argsEscaped // // POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses func (s *Server) handleReposCreateDeploymentStatusRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-deployment-status"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60936,7 +75348,16 @@ func (s *Server) handleReposCreateDeploymentStatusRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60948,8 +75369,27 @@ func (s *Server) handleReposCreateDeploymentStatusRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61069,6 +75509,8 @@ func (s *Server) handleReposCreateDeploymentStatusRequest(args [3]string, argsEs // // POST /repos/{owner}/{repo}/dispatches func (s *Server) handleReposCreateDispatchEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-dispatch-event"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61090,7 +75532,16 @@ func (s *Server) handleReposCreateDispatchEventRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61102,8 +75553,27 @@ func (s *Server) handleReposCreateDispatchEventRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61206,6 +75676,8 @@ func (s *Server) handleReposCreateDispatchEventRequest(args [2]string, argsEscap // // POST /user/repos func (s *Server) handleReposCreateForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61227,7 +75699,16 @@ func (s *Server) handleReposCreateForAuthenticatedUserRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61239,8 +75720,27 @@ func (s *Server) handleReposCreateForAuthenticatedUserRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61321,6 +75821,8 @@ func (s *Server) handleReposCreateForAuthenticatedUserRequest(args [0]string, ar // // POST /repos/{owner}/{repo}/forks func (s *Server) handleReposCreateForkRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-fork"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61342,7 +75844,16 @@ func (s *Server) handleReposCreateForkRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61354,8 +75865,27 @@ func (s *Server) handleReposCreateForkRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61459,6 +75989,8 @@ func (s *Server) handleReposCreateForkRequest(args [2]string, argsEscaped bool, // // POST /orgs/{org}/repos func (s *Server) handleReposCreateInOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-in-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61480,7 +76012,16 @@ func (s *Server) handleReposCreateInOrgRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61492,8 +76033,27 @@ func (s *Server) handleReposCreateInOrgRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61586,6 +76146,8 @@ func (s *Server) handleReposCreateInOrgRequest(args [1]string, argsEscaped bool, // // PUT /repos/{owner}/{repo}/contents/{path} func (s *Server) handleReposCreateOrUpdateFileContentsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-or-update-file-contents"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -61607,7 +76169,16 @@ func (s *Server) handleReposCreateOrUpdateFileContentsRequest(args [3]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61619,8 +76190,27 @@ func (s *Server) handleReposCreateOrUpdateFileContentsRequest(args [3]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61722,6 +76312,8 @@ func (s *Server) handleReposCreateOrUpdateFileContentsRequest(args [3]string, ar // // POST /repos/{owner}/{repo}/pages func (s *Server) handleReposCreatePagesSiteRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-pages-site"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61743,7 +76335,16 @@ func (s *Server) handleReposCreatePagesSiteRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61755,8 +76356,27 @@ func (s *Server) handleReposCreatePagesSiteRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61860,6 +76480,8 @@ func (s *Server) handleReposCreatePagesSiteRequest(args [2]string, argsEscaped b // // POST /repos/{owner}/{repo}/releases func (s *Server) handleReposCreateReleaseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-release"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61881,7 +76503,16 @@ func (s *Server) handleReposCreateReleaseRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61893,8 +76524,27 @@ func (s *Server) handleReposCreateReleaseRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62002,6 +76652,8 @@ func (s *Server) handleReposCreateReleaseRequest(args [2]string, argsEscaped boo // // POST /repos/{template_owner}/{template_repo}/generate func (s *Server) handleReposCreateUsingTemplateRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-using-template"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62023,7 +76675,16 @@ func (s *Server) handleReposCreateUsingTemplateRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62035,8 +76696,27 @@ func (s *Server) handleReposCreateUsingTemplateRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62135,6 +76815,8 @@ func (s *Server) handleReposCreateUsingTemplateRequest(args [2]string, argsEscap // // POST /repos/{owner}/{repo}/hooks func (s *Server) handleReposCreateWebhookRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/create-webhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62156,7 +76838,16 @@ func (s *Server) handleReposCreateWebhookRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62168,8 +76859,27 @@ func (s *Server) handleReposCreateWebhookRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62266,6 +76976,8 @@ func (s *Server) handleReposCreateWebhookRequest(args [2]string, argsEscaped boo // // DELETE /user/repository_invitations/{invitation_id} func (s *Server) handleReposDeclineInvitationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/decline-invitation"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -62287,7 +76999,16 @@ func (s *Server) handleReposDeclineInvitationRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62299,8 +77020,27 @@ func (s *Server) handleReposDeclineInvitationRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62381,6 +77121,8 @@ func (s *Server) handleReposDeclineInvitationRequest(args [1]string, argsEscaped // // DELETE /repos/{owner}/{repo} func (s *Server) handleReposDeleteRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -62402,7 +77144,16 @@ func (s *Server) handleReposDeleteRequest(args [2]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62414,8 +77165,27 @@ func (s *Server) handleReposDeleteRequest(args [2]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62502,6 +77272,8 @@ func (s *Server) handleReposDeleteRequest(args [2]string, argsEscaped bool, w ht // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions func (s *Server) handleReposDeleteAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-access-restrictions"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -62523,7 +77295,16 @@ func (s *Server) handleReposDeleteAccessRestrictionsRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62535,8 +77316,27 @@ func (s *Server) handleReposDeleteAccessRestrictionsRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62628,6 +77428,8 @@ func (s *Server) handleReposDeleteAccessRestrictionsRequest(args [3]string, args // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins func (s *Server) handleReposDeleteAdminBranchProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-admin-branch-protection"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -62649,7 +77451,16 @@ func (s *Server) handleReposDeleteAdminBranchProtectionRequest(args [3]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62661,8 +77472,27 @@ func (s *Server) handleReposDeleteAdminBranchProtectionRequest(args [3]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62748,6 +77578,8 @@ func (s *Server) handleReposDeleteAdminBranchProtectionRequest(args [3]string, a // // DELETE /repos/{owner}/{repo}/environments/{environment_name} func (s *Server) handleReposDeleteAnEnvironmentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-an-environment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -62769,7 +77601,16 @@ func (s *Server) handleReposDeleteAnEnvironmentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62781,8 +77622,27 @@ func (s *Server) handleReposDeleteAnEnvironmentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62869,6 +77729,8 @@ func (s *Server) handleReposDeleteAnEnvironmentRequest(args [3]string, argsEscap // // DELETE /repos/{owner}/{repo}/autolinks/{autolink_id} func (s *Server) handleReposDeleteAutolinkRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-autolink"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -62890,7 +77752,16 @@ func (s *Server) handleReposDeleteAutolinkRequest(args [3]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62902,8 +77773,27 @@ func (s *Server) handleReposDeleteAutolinkRequest(args [3]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62993,6 +77883,8 @@ func (s *Server) handleReposDeleteAutolinkRequest(args [3]string, argsEscaped bo // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection func (s *Server) handleReposDeleteBranchProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-branch-protection"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63014,7 +77906,16 @@ func (s *Server) handleReposDeleteBranchProtectionRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63026,8 +77927,27 @@ func (s *Server) handleReposDeleteBranchProtectionRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63113,6 +78033,8 @@ func (s *Server) handleReposDeleteBranchProtectionRequest(args [3]string, argsEs // // DELETE /repos/{owner}/{repo}/comments/{comment_id} func (s *Server) handleReposDeleteCommitCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-commit-comment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63134,7 +78056,16 @@ func (s *Server) handleReposDeleteCommitCommentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63146,8 +78077,27 @@ func (s *Server) handleReposDeleteCommitCommentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63240,6 +78190,8 @@ func (s *Server) handleReposDeleteCommitCommentRequest(args [3]string, argsEscap // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures func (s *Server) handleReposDeleteCommitSignatureProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-commit-signature-protection"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63261,7 +78213,16 @@ func (s *Server) handleReposDeleteCommitSignatureProtectionRequest(args [3]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63273,8 +78234,27 @@ func (s *Server) handleReposDeleteCommitSignatureProtectionRequest(args [3]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63361,6 +78341,8 @@ func (s *Server) handleReposDeleteCommitSignatureProtectionRequest(args [3]strin // // DELETE /repos/{owner}/{repo}/keys/{key_id} func (s *Server) handleReposDeleteDeployKeyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-deploy-key"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63382,7 +78364,16 @@ func (s *Server) handleReposDeleteDeployKeyRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63394,8 +78385,27 @@ func (s *Server) handleReposDeleteDeployKeyRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63489,6 +78499,8 @@ func (s *Server) handleReposDeleteDeployKeyRequest(args [3]string, argsEscaped b // // DELETE /repos/{owner}/{repo}/deployments/{deployment_id} func (s *Server) handleReposDeleteDeploymentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-deployment"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63510,7 +78522,16 @@ func (s *Server) handleReposDeleteDeploymentRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63522,8 +78543,27 @@ func (s *Server) handleReposDeleteDeploymentRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63616,6 +78656,8 @@ func (s *Server) handleReposDeleteDeploymentRequest(args [3]string, argsEscaped // // DELETE /repos/{owner}/{repo}/contents/{path} func (s *Server) handleReposDeleteFileRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-file"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63637,7 +78679,16 @@ func (s *Server) handleReposDeleteFileRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63649,8 +78700,27 @@ func (s *Server) handleReposDeleteFileRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63751,6 +78821,8 @@ func (s *Server) handleReposDeleteFileRequest(args [3]string, argsEscaped bool, // // DELETE /repos/{owner}/{repo}/invitations/{invitation_id} func (s *Server) handleReposDeleteInvitationRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-invitation"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63772,7 +78844,16 @@ func (s *Server) handleReposDeleteInvitationRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63784,8 +78865,27 @@ func (s *Server) handleReposDeleteInvitationRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63871,6 +78971,8 @@ func (s *Server) handleReposDeleteInvitationRequest(args [3]string, argsEscaped // // DELETE /repos/{owner}/{repo}/pages func (s *Server) handleReposDeletePagesSiteRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-pages-site"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -63892,7 +78994,16 @@ func (s *Server) handleReposDeletePagesSiteRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63904,8 +79015,27 @@ func (s *Server) handleReposDeletePagesSiteRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63991,6 +79121,8 @@ func (s *Server) handleReposDeletePagesSiteRequest(args [2]string, argsEscaped b // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews func (s *Server) handleReposDeletePullRequestReviewProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-pull-request-review-protection"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64012,7 +79144,16 @@ func (s *Server) handleReposDeletePullRequestReviewProtectionRequest(args [3]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64024,8 +79165,27 @@ func (s *Server) handleReposDeletePullRequestReviewProtectionRequest(args [3]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64111,6 +79271,8 @@ func (s *Server) handleReposDeletePullRequestReviewProtectionRequest(args [3]str // // DELETE /repos/{owner}/{repo}/releases/{release_id} func (s *Server) handleReposDeleteReleaseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-release"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64132,7 +79294,16 @@ func (s *Server) handleReposDeleteReleaseRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64144,8 +79315,27 @@ func (s *Server) handleReposDeleteReleaseRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64231,6 +79421,8 @@ func (s *Server) handleReposDeleteReleaseRequest(args [3]string, argsEscaped boo // // DELETE /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *Server) handleReposDeleteReleaseAssetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-release-asset"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64252,7 +79444,16 @@ func (s *Server) handleReposDeleteReleaseAssetRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64264,8 +79465,27 @@ func (s *Server) handleReposDeleteReleaseAssetRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64351,6 +79571,8 @@ func (s *Server) handleReposDeleteReleaseAssetRequest(args [3]string, argsEscape // // DELETE /repos/{owner}/{repo}/hooks/{hook_id} func (s *Server) handleReposDeleteWebhookRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/delete-webhook"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64372,7 +79594,16 @@ func (s *Server) handleReposDeleteWebhookRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64384,8 +79615,27 @@ func (s *Server) handleReposDeleteWebhookRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64473,6 +79723,8 @@ func (s *Server) handleReposDeleteWebhookRequest(args [3]string, argsEscaped boo // // DELETE /repos/{owner}/{repo}/automated-security-fixes func (s *Server) handleReposDisableAutomatedSecurityFixesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/disable-automated-security-fixes"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64494,7 +79746,16 @@ func (s *Server) handleReposDisableAutomatedSecurityFixesRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64506,8 +79767,27 @@ func (s *Server) handleReposDisableAutomatedSecurityFixesRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64589,6 +79869,8 @@ func (s *Server) handleReposDisableAutomatedSecurityFixesRequest(args [2]string, // // DELETE /repos/{owner}/{repo}/lfs func (s *Server) handleReposDisableLfsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/disable-lfs-for-repo"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64610,7 +79892,16 @@ func (s *Server) handleReposDisableLfsForRepoRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64622,8 +79913,27 @@ func (s *Server) handleReposDisableLfsForRepoRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64708,6 +80018,8 @@ func (s *Server) handleReposDisableLfsForRepoRequest(args [2]string, argsEscaped // // DELETE /repos/{owner}/{repo}/vulnerability-alerts func (s *Server) handleReposDisableVulnerabilityAlertsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/disable-vulnerability-alerts"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -64729,7 +80041,16 @@ func (s *Server) handleReposDisableVulnerabilityAlertsRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64741,8 +80062,27 @@ func (s *Server) handleReposDisableVulnerabilityAlertsRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64829,6 +80169,8 @@ func (s *Server) handleReposDisableVulnerabilityAlertsRequest(args [2]string, ar // // GET /repos/{owner}/{repo}/tarball/{ref} func (s *Server) handleReposDownloadTarballArchiveRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/download-tarball-archive"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64850,7 +80192,16 @@ func (s *Server) handleReposDownloadTarballArchiveRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64862,8 +80213,27 @@ func (s *Server) handleReposDownloadTarballArchiveRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64954,6 +80324,8 @@ func (s *Server) handleReposDownloadTarballArchiveRequest(args [3]string, argsEs // // GET /repos/{owner}/{repo}/zipball/{ref} func (s *Server) handleReposDownloadZipballArchiveRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/download-zipball-archive"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64975,7 +80347,16 @@ func (s *Server) handleReposDownloadZipballArchiveRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64987,8 +80368,27 @@ func (s *Server) handleReposDownloadZipballArchiveRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65076,6 +80476,8 @@ func (s *Server) handleReposDownloadZipballArchiveRequest(args [3]string, argsEs // // PUT /repos/{owner}/{repo}/automated-security-fixes func (s *Server) handleReposEnableAutomatedSecurityFixesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/enable-automated-security-fixes"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -65097,7 +80499,16 @@ func (s *Server) handleReposEnableAutomatedSecurityFixesRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65109,8 +80520,27 @@ func (s *Server) handleReposEnableAutomatedSecurityFixesRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65192,6 +80622,8 @@ func (s *Server) handleReposEnableAutomatedSecurityFixesRequest(args [2]string, // // PUT /repos/{owner}/{repo}/lfs func (s *Server) handleReposEnableLfsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/enable-lfs-for-repo"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -65213,7 +80645,16 @@ func (s *Server) handleReposEnableLfsForRepoRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65225,8 +80666,27 @@ func (s *Server) handleReposEnableLfsForRepoRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65311,6 +80771,8 @@ func (s *Server) handleReposEnableLfsForRepoRequest(args [2]string, argsEscaped // // PUT /repos/{owner}/{repo}/vulnerability-alerts func (s *Server) handleReposEnableVulnerabilityAlertsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/enable-vulnerability-alerts"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -65332,7 +80794,16 @@ func (s *Server) handleReposEnableVulnerabilityAlertsRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65344,8 +80815,27 @@ func (s *Server) handleReposEnableVulnerabilityAlertsRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65428,6 +80918,8 @@ func (s *Server) handleReposEnableVulnerabilityAlertsRequest(args [2]string, arg // // GET /repos/{owner}/{repo} func (s *Server) handleReposGetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65449,7 +80941,16 @@ func (s *Server) handleReposGetRequest(args [2]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65461,8 +80962,27 @@ func (s *Server) handleReposGetRequest(args [2]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65551,6 +81071,8 @@ func (s *Server) handleReposGetRequest(args [2]string, argsEscaped bool, w http. // // GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions func (s *Server) handleReposGetAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-access-restrictions"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65572,7 +81094,16 @@ func (s *Server) handleReposGetAccessRestrictionsRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65584,8 +81115,27 @@ func (s *Server) handleReposGetAccessRestrictionsRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65675,6 +81225,8 @@ func (s *Server) handleReposGetAccessRestrictionsRequest(args [3]string, argsEsc // // GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins func (s *Server) handleReposGetAdminBranchProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-admin-branch-protection"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65696,7 +81248,16 @@ func (s *Server) handleReposGetAdminBranchProtectionRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65708,8 +81269,27 @@ func (s *Server) handleReposGetAdminBranchProtectionRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65799,6 +81379,8 @@ func (s *Server) handleReposGetAdminBranchProtectionRequest(args [3]string, args // // GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts func (s *Server) handleReposGetAllStatusCheckContextsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-all-status-check-contexts"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65820,7 +81402,16 @@ func (s *Server) handleReposGetAllStatusCheckContextsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65832,8 +81423,27 @@ func (s *Server) handleReposGetAllStatusCheckContextsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65919,6 +81529,8 @@ func (s *Server) handleReposGetAllStatusCheckContextsRequest(args [3]string, arg // // GET /repos/{owner}/{repo}/topics func (s *Server) handleReposGetAllTopicsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-all-topics"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65940,7 +81552,16 @@ func (s *Server) handleReposGetAllTopicsRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65952,8 +81573,27 @@ func (s *Server) handleReposGetAllTopicsRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66050,6 +81690,8 @@ func (s *Server) handleReposGetAllTopicsRequest(args [2]string, argsEscaped bool // // GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps func (s *Server) handleReposGetAppsWithAccessToProtectedBranchRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-apps-with-access-to-protected-branch"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66071,7 +81713,16 @@ func (s *Server) handleReposGetAppsWithAccessToProtectedBranchRequest(args [3]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66083,8 +81734,27 @@ func (s *Server) handleReposGetAppsWithAccessToProtectedBranchRequest(args [3]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66171,6 +81841,8 @@ func (s *Server) handleReposGetAppsWithAccessToProtectedBranchRequest(args [3]st // // GET /repos/{owner}/{repo}/autolinks/{autolink_id} func (s *Server) handleReposGetAutolinkRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-autolink"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66192,7 +81864,16 @@ func (s *Server) handleReposGetAutolinkRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66204,8 +81885,27 @@ func (s *Server) handleReposGetAutolinkRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66291,6 +81991,8 @@ func (s *Server) handleReposGetAutolinkRequest(args [3]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/branches/{branch} func (s *Server) handleReposGetBranchRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-branch"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66312,7 +82014,16 @@ func (s *Server) handleReposGetBranchRequest(args [3]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66324,8 +82035,27 @@ func (s *Server) handleReposGetBranchRequest(args [3]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66415,6 +82145,8 @@ func (s *Server) handleReposGetBranchRequest(args [3]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/branches/{branch}/protection func (s *Server) handleReposGetBranchProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-branch-protection"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66436,7 +82168,16 @@ func (s *Server) handleReposGetBranchProtectionRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66448,8 +82189,27 @@ func (s *Server) handleReposGetBranchProtectionRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66536,6 +82296,8 @@ func (s *Server) handleReposGetBranchProtectionRequest(args [3]string, argsEscap // // GET /repos/{owner}/{repo}/traffic/clones func (s *Server) handleReposGetClonesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-clones"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66557,7 +82319,16 @@ func (s *Server) handleReposGetClonesRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66569,8 +82340,27 @@ func (s *Server) handleReposGetClonesRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66656,6 +82446,8 @@ func (s *Server) handleReposGetClonesRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/stats/code_frequency func (s *Server) handleReposGetCodeFrequencyStatsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-code-frequency-stats"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66677,7 +82469,16 @@ func (s *Server) handleReposGetCodeFrequencyStatsRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66689,8 +82490,27 @@ func (s *Server) handleReposGetCodeFrequencyStatsRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66773,6 +82593,8 @@ func (s *Server) handleReposGetCodeFrequencyStatsRequest(args [2]string, argsEsc // // GET /repos/{owner}/{repo}/collaborators/{username}/permission func (s *Server) handleReposGetCollaboratorPermissionLevelRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-collaborator-permission-level"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66794,7 +82616,16 @@ func (s *Server) handleReposGetCollaboratorPermissionLevelRequest(args [3]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66806,8 +82637,27 @@ func (s *Server) handleReposGetCollaboratorPermissionLevelRequest(args [3]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66901,6 +82751,8 @@ func (s *Server) handleReposGetCollaboratorPermissionLevelRequest(args [3]string // // GET /repos/{owner}/{repo}/commits/{ref}/status func (s *Server) handleReposGetCombinedStatusForRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-combined-status-for-ref"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66922,7 +82774,16 @@ func (s *Server) handleReposGetCombinedStatusForRefRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66934,8 +82795,27 @@ func (s *Server) handleReposGetCombinedStatusForRefRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67075,6 +82955,8 @@ func (s *Server) handleReposGetCombinedStatusForRefRequest(args [3]string, argsE // // GET /repos/{owner}/{repo}/commits/{ref} func (s *Server) handleReposGetCommitRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-commit"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67096,7 +82978,16 @@ func (s *Server) handleReposGetCommitRequest(args [3]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67108,8 +82999,27 @@ func (s *Server) handleReposGetCommitRequest(args [3]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67204,6 +83114,8 @@ func (s *Server) handleReposGetCommitRequest(args [3]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/stats/commit_activity func (s *Server) handleReposGetCommitActivityStatsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-commit-activity-stats"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67225,7 +83137,16 @@ func (s *Server) handleReposGetCommitActivityStatsRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67237,8 +83158,27 @@ func (s *Server) handleReposGetCommitActivityStatsRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67320,6 +83260,8 @@ func (s *Server) handleReposGetCommitActivityStatsRequest(args [2]string, argsEs // // GET /repos/{owner}/{repo}/comments/{comment_id} func (s *Server) handleReposGetCommitCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-commit-comment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67341,7 +83283,16 @@ func (s *Server) handleReposGetCommitCommentRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67353,8 +83304,27 @@ func (s *Server) handleReposGetCommitCommentRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67449,6 +83419,8 @@ func (s *Server) handleReposGetCommitCommentRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures func (s *Server) handleReposGetCommitSignatureProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-commit-signature-protection"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67470,7 +83442,16 @@ func (s *Server) handleReposGetCommitSignatureProtectionRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67482,8 +83463,27 @@ func (s *Server) handleReposGetCommitSignatureProtectionRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67578,6 +83578,8 @@ func (s *Server) handleReposGetCommitSignatureProtectionRequest(args [3]string, // // GET /repos/{owner}/{repo}/community/profile func (s *Server) handleReposGetCommunityProfileMetricsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-community-profile-metrics"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67599,7 +83601,16 @@ func (s *Server) handleReposGetCommunityProfileMetricsRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67611,8 +83622,27 @@ func (s *Server) handleReposGetCommunityProfileMetricsRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67699,6 +83729,8 @@ func (s *Server) handleReposGetCommunityProfileMetricsRequest(args [2]string, ar // // GET /repos/{owner}/{repo}/stats/contributors func (s *Server) handleReposGetContributorsStatsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-contributors-stats"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67720,7 +83752,16 @@ func (s *Server) handleReposGetContributorsStatsRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67732,8 +83773,27 @@ func (s *Server) handleReposGetContributorsStatsRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67815,6 +83875,8 @@ func (s *Server) handleReposGetContributorsStatsRequest(args [2]string, argsEsca // // GET /repos/{owner}/{repo}/keys/{key_id} func (s *Server) handleReposGetDeployKeyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-deploy-key"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67836,7 +83898,16 @@ func (s *Server) handleReposGetDeployKeyRequest(args [3]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67848,8 +83919,27 @@ func (s *Server) handleReposGetDeployKeyRequest(args [3]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67935,6 +84025,8 @@ func (s *Server) handleReposGetDeployKeyRequest(args [3]string, argsEscaped bool // // GET /repos/{owner}/{repo}/deployments/{deployment_id} func (s *Server) handleReposGetDeploymentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-deployment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67956,7 +84048,16 @@ func (s *Server) handleReposGetDeploymentRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67968,8 +84069,27 @@ func (s *Server) handleReposGetDeploymentRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68055,6 +84175,8 @@ func (s *Server) handleReposGetDeploymentRequest(args [3]string, argsEscaped boo // // GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id} func (s *Server) handleReposGetDeploymentStatusRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-deployment-status"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68076,7 +84198,16 @@ func (s *Server) handleReposGetDeploymentStatusRequest(args [4]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68088,8 +84219,27 @@ func (s *Server) handleReposGetDeploymentStatusRequest(args [4]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68179,6 +84329,8 @@ func (s *Server) handleReposGetDeploymentStatusRequest(args [4]string, argsEscap // // GET /repos/{owner}/{repo}/pages/builds/latest func (s *Server) handleReposGetLatestPagesBuildRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-latest-pages-build"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68200,7 +84352,16 @@ func (s *Server) handleReposGetLatestPagesBuildRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68212,8 +84373,27 @@ func (s *Server) handleReposGetLatestPagesBuildRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68298,6 +84478,8 @@ func (s *Server) handleReposGetLatestPagesBuildRequest(args [2]string, argsEscap // // GET /repos/{owner}/{repo}/releases/latest func (s *Server) handleReposGetLatestReleaseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-latest-release"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68319,7 +84501,16 @@ func (s *Server) handleReposGetLatestReleaseRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68331,8 +84522,27 @@ func (s *Server) handleReposGetLatestReleaseRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68414,6 +84624,8 @@ func (s *Server) handleReposGetLatestReleaseRequest(args [2]string, argsEscaped // // GET /repos/{owner}/{repo}/pages func (s *Server) handleReposGetPagesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-pages"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68435,7 +84647,16 @@ func (s *Server) handleReposGetPagesRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68447,8 +84668,27 @@ func (s *Server) handleReposGetPagesRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68530,6 +84770,8 @@ func (s *Server) handleReposGetPagesRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/pages/builds/{build_id} func (s *Server) handleReposGetPagesBuildRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-pages-build"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68551,7 +84793,16 @@ func (s *Server) handleReposGetPagesBuildRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68563,8 +84814,27 @@ func (s *Server) handleReposGetPagesBuildRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68656,6 +84926,8 @@ func (s *Server) handleReposGetPagesBuildRequest(args [3]string, argsEscaped boo // // GET /repos/{owner}/{repo}/pages/health func (s *Server) handleReposGetPagesHealthCheckRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-pages-health-check"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68677,7 +84949,16 @@ func (s *Server) handleReposGetPagesHealthCheckRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68689,8 +84970,27 @@ func (s *Server) handleReposGetPagesHealthCheckRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68775,6 +85075,8 @@ func (s *Server) handleReposGetPagesHealthCheckRequest(args [2]string, argsEscap // // GET /repos/{owner}/{repo}/stats/participation func (s *Server) handleReposGetParticipationStatsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-participation-stats"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68796,7 +85098,16 @@ func (s *Server) handleReposGetParticipationStatsRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68808,8 +85119,27 @@ func (s *Server) handleReposGetParticipationStatsRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68895,6 +85225,8 @@ func (s *Server) handleReposGetParticipationStatsRequest(args [2]string, argsEsc // // GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews func (s *Server) handleReposGetPullRequestReviewProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-pull-request-review-protection"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68916,7 +85248,16 @@ func (s *Server) handleReposGetPullRequestReviewProtectionRequest(args [3]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68928,8 +85269,27 @@ func (s *Server) handleReposGetPullRequestReviewProtectionRequest(args [3]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69020,6 +85380,8 @@ func (s *Server) handleReposGetPullRequestReviewProtectionRequest(args [3]string // // GET /repos/{owner}/{repo}/stats/punch_card func (s *Server) handleReposGetPunchCardStatsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-punch-card-stats"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69041,7 +85403,16 @@ func (s *Server) handleReposGetPunchCardStatsRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69053,8 +85424,27 @@ func (s *Server) handleReposGetPunchCardStatsRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69138,6 +85528,8 @@ func (s *Server) handleReposGetPunchCardStatsRequest(args [2]string, argsEscaped // // GET /repos/{owner}/{repo}/readme func (s *Server) handleReposGetReadmeRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-readme"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69159,7 +85551,16 @@ func (s *Server) handleReposGetReadmeRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69171,8 +85572,27 @@ func (s *Server) handleReposGetReadmeRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69260,6 +85680,8 @@ func (s *Server) handleReposGetReadmeRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/readme/{dir} func (s *Server) handleReposGetReadmeInDirectoryRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-readme-in-directory"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69281,7 +85703,16 @@ func (s *Server) handleReposGetReadmeInDirectoryRequest(args [3]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69293,8 +85724,27 @@ func (s *Server) handleReposGetReadmeInDirectoryRequest(args [3]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69386,6 +85836,8 @@ func (s *Server) handleReposGetReadmeInDirectoryRequest(args [3]string, argsEsca // // GET /repos/{owner}/{repo}/releases/{release_id} func (s *Server) handleReposGetReleaseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-release"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69407,7 +85859,16 @@ func (s *Server) handleReposGetReleaseRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69419,8 +85880,27 @@ func (s *Server) handleReposGetReleaseRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69509,6 +85989,8 @@ func (s *Server) handleReposGetReleaseRequest(args [3]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *Server) handleReposGetReleaseAssetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-release-asset"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69530,7 +86012,16 @@ func (s *Server) handleReposGetReleaseAssetRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69542,8 +86033,27 @@ func (s *Server) handleReposGetReleaseAssetRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69629,6 +86139,8 @@ func (s *Server) handleReposGetReleaseAssetRequest(args [3]string, argsEscaped b // // GET /repos/{owner}/{repo}/releases/tags/{tag} func (s *Server) handleReposGetReleaseByTagRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-release-by-tag"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69650,7 +86162,16 @@ func (s *Server) handleReposGetReleaseByTagRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69662,8 +86183,27 @@ func (s *Server) handleReposGetReleaseByTagRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69753,6 +86293,8 @@ func (s *Server) handleReposGetReleaseByTagRequest(args [3]string, argsEscaped b // // GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks func (s *Server) handleReposGetStatusChecksProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-status-checks-protection"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69774,7 +86316,16 @@ func (s *Server) handleReposGetStatusChecksProtectionRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69786,8 +86337,27 @@ func (s *Server) handleReposGetStatusChecksProtectionRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69878,6 +86448,8 @@ func (s *Server) handleReposGetStatusChecksProtectionRequest(args [3]string, arg // // GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams func (s *Server) handleReposGetTeamsWithAccessToProtectedBranchRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-teams-with-access-to-protected-branch"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69899,7 +86471,16 @@ func (s *Server) handleReposGetTeamsWithAccessToProtectedBranchRequest(args [3]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69911,8 +86492,27 @@ func (s *Server) handleReposGetTeamsWithAccessToProtectedBranchRequest(args [3]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69998,6 +86598,8 @@ func (s *Server) handleReposGetTeamsWithAccessToProtectedBranchRequest(args [3]s // // GET /repos/{owner}/{repo}/traffic/popular/paths func (s *Server) handleReposGetTopPathsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-top-paths"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70019,7 +86621,16 @@ func (s *Server) handleReposGetTopPathsRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70031,8 +86642,27 @@ func (s *Server) handleReposGetTopPathsRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70114,6 +86744,8 @@ func (s *Server) handleReposGetTopPathsRequest(args [2]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/traffic/popular/referrers func (s *Server) handleReposGetTopReferrersRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-top-referrers"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70135,7 +86767,16 @@ func (s *Server) handleReposGetTopReferrersRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70147,8 +86788,27 @@ func (s *Server) handleReposGetTopReferrersRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70235,6 +86895,8 @@ func (s *Server) handleReposGetTopReferrersRequest(args [2]string, argsEscaped b // // GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users func (s *Server) handleReposGetUsersWithAccessToProtectedBranchRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-users-with-access-to-protected-branch"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70256,7 +86918,16 @@ func (s *Server) handleReposGetUsersWithAccessToProtectedBranchRequest(args [3]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70268,8 +86939,27 @@ func (s *Server) handleReposGetUsersWithAccessToProtectedBranchRequest(args [3]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70356,6 +87046,8 @@ func (s *Server) handleReposGetUsersWithAccessToProtectedBranchRequest(args [3]s // // GET /repos/{owner}/{repo}/traffic/views func (s *Server) handleReposGetViewsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-views"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70377,7 +87069,16 @@ func (s *Server) handleReposGetViewsRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70389,8 +87090,27 @@ func (s *Server) handleReposGetViewsRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70478,6 +87198,8 @@ func (s *Server) handleReposGetViewsRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/hooks/{hook_id} func (s *Server) handleReposGetWebhookRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-webhook"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70499,7 +87221,16 @@ func (s *Server) handleReposGetWebhookRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70511,8 +87242,27 @@ func (s *Server) handleReposGetWebhookRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70602,6 +87352,8 @@ func (s *Server) handleReposGetWebhookRequest(args [3]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/hooks/{hook_id}/config func (s *Server) handleReposGetWebhookConfigForRepoRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-webhook-config-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70623,7 +87375,16 @@ func (s *Server) handleReposGetWebhookConfigForRepoRequest(args [3]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70635,8 +87396,27 @@ func (s *Server) handleReposGetWebhookConfigForRepoRequest(args [3]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70722,6 +87502,8 @@ func (s *Server) handleReposGetWebhookConfigForRepoRequest(args [3]string, argsE // // GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id} func (s *Server) handleReposGetWebhookDeliveryRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/get-webhook-delivery"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70743,7 +87525,16 @@ func (s *Server) handleReposGetWebhookDeliveryRequest(args [4]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70755,8 +87546,27 @@ func (s *Server) handleReposGetWebhookDeliveryRequest(args [4]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70847,6 +87657,8 @@ func (s *Server) handleReposGetWebhookDeliveryRequest(args [4]string, argsEscape // // GET /repos/{owner}/{repo}/autolinks func (s *Server) handleReposListAutolinksRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-autolinks"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70868,7 +87680,16 @@ func (s *Server) handleReposListAutolinksRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70880,8 +87701,27 @@ func (s *Server) handleReposListAutolinksRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70967,6 +87807,8 @@ func (s *Server) handleReposListAutolinksRequest(args [2]string, argsEscaped boo // // GET /repos/{owner}/{repo}/branches func (s *Server) handleReposListBranchesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-branches"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70988,7 +87830,16 @@ func (s *Server) handleReposListBranchesRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71000,8 +87851,27 @@ func (s *Server) handleReposListBranchesRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71100,6 +87970,8 @@ func (s *Server) handleReposListBranchesRequest(args [2]string, argsEscaped bool // // GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head func (s *Server) handleReposListBranchesForHeadCommitRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-branches-for-head-commit"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71121,7 +87993,16 @@ func (s *Server) handleReposListBranchesForHeadCommitRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71133,8 +88014,27 @@ func (s *Server) handleReposListBranchesForHeadCommitRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71224,6 +88124,8 @@ func (s *Server) handleReposListBranchesForHeadCommitRequest(args [3]string, arg // // GET /repos/{owner}/{repo}/collaborators func (s *Server) handleReposListCollaboratorsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-collaborators"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71245,7 +88147,16 @@ func (s *Server) handleReposListCollaboratorsRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71257,8 +88168,27 @@ func (s *Server) handleReposListCollaboratorsRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71352,6 +88282,8 @@ func (s *Server) handleReposListCollaboratorsRequest(args [2]string, argsEscaped // // GET /repos/{owner}/{repo}/commits/{commit_sha}/comments func (s *Server) handleReposListCommentsForCommitRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-comments-for-commit"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71373,7 +88305,16 @@ func (s *Server) handleReposListCommentsForCommitRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71385,8 +88326,27 @@ func (s *Server) handleReposListCommentsForCommitRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71483,6 +88443,8 @@ func (s *Server) handleReposListCommentsForCommitRequest(args [3]string, argsEsc // // GET /repos/{owner}/{repo}/comments func (s *Server) handleReposListCommitCommentsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-commit-comments-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71504,7 +88466,16 @@ func (s *Server) handleReposListCommitCommentsForRepoRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71516,8 +88487,27 @@ func (s *Server) handleReposListCommitCommentsForRepoRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71610,6 +88600,8 @@ func (s *Server) handleReposListCommitCommentsForRepoRequest(args [2]string, arg // // GET /repos/{owner}/{repo}/commits/{ref}/statuses func (s *Server) handleReposListCommitStatusesForRefRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-commit-statuses-for-ref"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71631,7 +88623,16 @@ func (s *Server) handleReposListCommitStatusesForRefRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71643,8 +88644,27 @@ func (s *Server) handleReposListCommitStatusesForRefRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71769,6 +88789,8 @@ func (s *Server) handleReposListCommitStatusesForRefRequest(args [3]string, args // // GET /repos/{owner}/{repo}/commits func (s *Server) handleReposListCommitsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-commits"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71790,7 +88812,16 @@ func (s *Server) handleReposListCommitsRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71802,8 +88833,27 @@ func (s *Server) handleReposListCommitsRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71919,6 +88969,8 @@ func (s *Server) handleReposListCommitsRequest(args [2]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/contributors func (s *Server) handleReposListContributorsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-contributors"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71940,7 +88992,16 @@ func (s *Server) handleReposListContributorsRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71952,8 +89013,27 @@ func (s *Server) handleReposListContributorsRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72047,6 +89127,8 @@ func (s *Server) handleReposListContributorsRequest(args [2]string, argsEscaped // // GET /repos/{owner}/{repo}/keys func (s *Server) handleReposListDeployKeysRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-deploy-keys"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72068,7 +89150,16 @@ func (s *Server) handleReposListDeployKeysRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72080,8 +89171,27 @@ func (s *Server) handleReposListDeployKeysRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72171,6 +89281,8 @@ func (s *Server) handleReposListDeployKeysRequest(args [2]string, argsEscaped bo // // GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses func (s *Server) handleReposListDeploymentStatusesRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-deployment-statuses"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72192,7 +89304,16 @@ func (s *Server) handleReposListDeploymentStatusesRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72204,8 +89325,27 @@ func (s *Server) handleReposListDeploymentStatusesRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72299,6 +89439,8 @@ func (s *Server) handleReposListDeploymentStatusesRequest(args [3]string, argsEs // // GET /repos/{owner}/{repo}/deployments func (s *Server) handleReposListDeploymentsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-deployments"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72320,7 +89462,16 @@ func (s *Server) handleReposListDeploymentsRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72332,8 +89483,27 @@ func (s *Server) handleReposListDeploymentsRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72442,6 +89612,8 @@ func (s *Server) handleReposListDeploymentsRequest(args [2]string, argsEscaped b // // GET /user/repos func (s *Server) handleReposListForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72463,7 +89635,16 @@ func (s *Server) handleReposListForAuthenticatedUserRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72475,8 +89656,27 @@ func (s *Server) handleReposListForAuthenticatedUserRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72586,6 +89786,8 @@ func (s *Server) handleReposListForAuthenticatedUserRequest(args [0]string, args // // GET /orgs/{org}/repos func (s *Server) handleReposListForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72607,7 +89809,16 @@ func (s *Server) handleReposListForOrgRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72619,8 +89830,27 @@ func (s *Server) handleReposListForOrgRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72719,6 +89949,8 @@ func (s *Server) handleReposListForOrgRequest(args [1]string, argsEscaped bool, // // GET /users/{username}/repos func (s *Server) handleReposListForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72740,7 +89972,16 @@ func (s *Server) handleReposListForUserRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72752,8 +89993,27 @@ func (s *Server) handleReposListForUserRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72851,6 +90111,8 @@ func (s *Server) handleReposListForUserRequest(args [1]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/forks func (s *Server) handleReposListForksRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-forks"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72872,7 +90134,16 @@ func (s *Server) handleReposListForksRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72884,8 +90155,27 @@ func (s *Server) handleReposListForksRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72980,6 +90270,8 @@ func (s *Server) handleReposListForksRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/invitations func (s *Server) handleReposListInvitationsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-invitations"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73001,7 +90293,16 @@ func (s *Server) handleReposListInvitationsRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73013,8 +90314,27 @@ func (s *Server) handleReposListInvitationsRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73105,6 +90425,8 @@ func (s *Server) handleReposListInvitationsRequest(args [2]string, argsEscaped b // // GET /user/repository_invitations func (s *Server) handleReposListInvitationsForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-invitations-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73126,7 +90448,16 @@ func (s *Server) handleReposListInvitationsForAuthenticatedUserRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73138,8 +90469,27 @@ func (s *Server) handleReposListInvitationsForAuthenticatedUserRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73222,6 +90572,8 @@ func (s *Server) handleReposListInvitationsForAuthenticatedUserRequest(args [0]s // // GET /repos/{owner}/{repo}/languages func (s *Server) handleReposListLanguagesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-languages"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73243,7 +90595,16 @@ func (s *Server) handleReposListLanguagesRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73255,8 +90616,27 @@ func (s *Server) handleReposListLanguagesRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73338,6 +90718,8 @@ func (s *Server) handleReposListLanguagesRequest(args [2]string, argsEscaped boo // // GET /repos/{owner}/{repo}/pages/builds func (s *Server) handleReposListPagesBuildsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-pages-builds"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73359,7 +90741,16 @@ func (s *Server) handleReposListPagesBuildsRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73371,8 +90762,27 @@ func (s *Server) handleReposListPagesBuildsRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73468,6 +90878,8 @@ func (s *Server) handleReposListPagesBuildsRequest(args [2]string, argsEscaped b // // GET /repositories func (s *Server) handleReposListPublicRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-public"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73489,7 +90901,16 @@ func (s *Server) handleReposListPublicRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73501,8 +90922,27 @@ func (s *Server) handleReposListPublicRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73585,6 +91025,8 @@ func (s *Server) handleReposListPublicRequest(args [0]string, argsEscaped bool, // // GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls func (s *Server) handleReposListPullRequestsAssociatedWithCommitRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-pull-requests-associated-with-commit"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73606,7 +91048,16 @@ func (s *Server) handleReposListPullRequestsAssociatedWithCommitRequest(args [3] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73618,8 +91069,27 @@ func (s *Server) handleReposListPullRequestsAssociatedWithCommitRequest(args [3] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73713,6 +91183,8 @@ func (s *Server) handleReposListPullRequestsAssociatedWithCommitRequest(args [3] // // GET /repos/{owner}/{repo}/releases/{release_id}/assets func (s *Server) handleReposListReleaseAssetsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-release-assets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73734,7 +91206,16 @@ func (s *Server) handleReposListReleaseAssetsRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73746,8 +91227,27 @@ func (s *Server) handleReposListReleaseAssetsRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73845,6 +91345,8 @@ func (s *Server) handleReposListReleaseAssetsRequest(args [3]string, argsEscaped // // GET /repos/{owner}/{repo}/releases func (s *Server) handleReposListReleasesRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-releases"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73866,7 +91368,16 @@ func (s *Server) handleReposListReleasesRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73878,8 +91389,27 @@ func (s *Server) handleReposListReleasesRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73969,6 +91499,8 @@ func (s *Server) handleReposListReleasesRequest(args [2]string, argsEscaped bool // // GET /repos/{owner}/{repo}/tags func (s *Server) handleReposListTagsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-tags"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73990,7 +91522,16 @@ func (s *Server) handleReposListTagsRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74002,8 +91543,27 @@ func (s *Server) handleReposListTagsRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74093,6 +91653,8 @@ func (s *Server) handleReposListTagsRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/teams func (s *Server) handleReposListTeamsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-teams"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74114,7 +91676,16 @@ func (s *Server) handleReposListTeamsRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74126,8 +91697,27 @@ func (s *Server) handleReposListTeamsRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74217,6 +91807,8 @@ func (s *Server) handleReposListTeamsRequest(args [2]string, argsEscaped bool, w // // GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries func (s *Server) handleReposListWebhookDeliveriesRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-webhook-deliveries"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74238,7 +91830,16 @@ func (s *Server) handleReposListWebhookDeliveriesRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74250,8 +91851,27 @@ func (s *Server) handleReposListWebhookDeliveriesRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74345,6 +91965,8 @@ func (s *Server) handleReposListWebhookDeliveriesRequest(args [3]string, argsEsc // // GET /repos/{owner}/{repo}/hooks func (s *Server) handleReposListWebhooksRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/list-webhooks"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74366,7 +91988,16 @@ func (s *Server) handleReposListWebhooksRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74378,8 +92009,27 @@ func (s *Server) handleReposListWebhooksRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74469,6 +92119,8 @@ func (s *Server) handleReposListWebhooksRequest(args [2]string, argsEscaped bool // // POST /repos/{owner}/{repo}/merges func (s *Server) handleReposMergeRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/merge"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74490,7 +92142,16 @@ func (s *Server) handleReposMergeRequest(args [2]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74502,8 +92163,27 @@ func (s *Server) handleReposMergeRequest(args [2]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74601,6 +92281,8 @@ func (s *Server) handleReposMergeRequest(args [2]string, argsEscaped bool, w htt // // POST /repos/{owner}/{repo}/merge-upstream func (s *Server) handleReposMergeUpstreamRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/merge-upstream"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74622,7 +92304,16 @@ func (s *Server) handleReposMergeUpstreamRequest(args [2]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74634,8 +92325,27 @@ func (s *Server) handleReposMergeUpstreamRequest(args [2]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74733,6 +92443,8 @@ func (s *Server) handleReposMergeUpstreamRequest(args [2]string, argsEscaped boo // // POST /repos/{owner}/{repo}/hooks/{hook_id}/pings func (s *Server) handleReposPingWebhookRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/ping-webhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74754,7 +92466,16 @@ func (s *Server) handleReposPingWebhookRequest(args [3]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74766,8 +92487,27 @@ func (s *Server) handleReposPingWebhookRequest(args [3]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74853,6 +92593,8 @@ func (s *Server) handleReposPingWebhookRequest(args [3]string, argsEscaped bool, // // POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts func (s *Server) handleReposRedeliverWebhookDeliveryRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/redeliver-webhook-delivery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74874,7 +92616,16 @@ func (s *Server) handleReposRedeliverWebhookDeliveryRequest(args [4]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74886,8 +92637,27 @@ func (s *Server) handleReposRedeliverWebhookDeliveryRequest(args [4]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74991,6 +92761,8 @@ func (s *Server) handleReposRedeliverWebhookDeliveryRequest(args [4]string, args // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps func (s *Server) handleReposRemoveAppAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/remove-app-access-restrictions"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -75012,7 +92784,16 @@ func (s *Server) handleReposRemoveAppAccessRestrictionsRequest(args [3]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75024,8 +92805,27 @@ func (s *Server) handleReposRemoveAppAccessRestrictionsRequest(args [3]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75126,6 +92926,8 @@ func (s *Server) handleReposRemoveAppAccessRestrictionsRequest(args [3]string, a // // DELETE /repos/{owner}/{repo}/collaborators/{username} func (s *Server) handleReposRemoveCollaboratorRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/remove-collaborator"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -75147,7 +92949,16 @@ func (s *Server) handleReposRemoveCollaboratorRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75159,8 +92970,27 @@ func (s *Server) handleReposRemoveCollaboratorRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75250,6 +93080,8 @@ func (s *Server) handleReposRemoveCollaboratorRequest(args [3]string, argsEscape // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts func (s *Server) handleReposRemoveStatusCheckContextsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/remove-status-check-contexts"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -75271,7 +93103,16 @@ func (s *Server) handleReposRemoveStatusCheckContextsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75283,8 +93124,27 @@ func (s *Server) handleReposRemoveStatusCheckContextsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75389,6 +93249,8 @@ func (s *Server) handleReposRemoveStatusCheckContextsRequest(args [3]string, arg // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks func (s *Server) handleReposRemoveStatusCheckProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/remove-status-check-protection"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -75410,7 +93272,16 @@ func (s *Server) handleReposRemoveStatusCheckProtectionRequest(args [3]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75422,8 +93293,27 @@ func (s *Server) handleReposRemoveStatusCheckProtectionRequest(args [3]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75523,6 +93413,8 @@ func (s *Server) handleReposRemoveStatusCheckProtectionRequest(args [3]string, a // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams func (s *Server) handleReposRemoveTeamAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/remove-team-access-restrictions"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -75544,7 +93436,16 @@ func (s *Server) handleReposRemoveTeamAccessRestrictionsRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75556,8 +93457,27 @@ func (s *Server) handleReposRemoveTeamAccessRestrictionsRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75671,6 +93591,8 @@ func (s *Server) handleReposRemoveTeamAccessRestrictionsRequest(args [3]string, // // DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users func (s *Server) handleReposRemoveUserAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/remove-user-access-restrictions"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -75692,7 +93614,16 @@ func (s *Server) handleReposRemoveUserAccessRestrictionsRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75704,8 +93635,27 @@ func (s *Server) handleReposRemoveUserAccessRestrictionsRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75818,6 +93768,8 @@ func (s *Server) handleReposRemoveUserAccessRestrictionsRequest(args [3]string, // // POST /repos/{owner}/{repo}/branches/{branch}/rename func (s *Server) handleReposRenameBranchRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/rename-branch"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75839,7 +93791,16 @@ func (s *Server) handleReposRenameBranchRequest(args [3]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75851,8 +93812,27 @@ func (s *Server) handleReposRenameBranchRequest(args [3]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75953,6 +93933,8 @@ func (s *Server) handleReposRenameBranchRequest(args [3]string, argsEscaped bool // // PUT /repos/{owner}/{repo}/topics func (s *Server) handleReposReplaceAllTopicsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/replace-all-topics"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -75974,7 +93956,16 @@ func (s *Server) handleReposReplaceAllTopicsRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75986,8 +93977,27 @@ func (s *Server) handleReposReplaceAllTopicsRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76089,6 +94099,8 @@ func (s *Server) handleReposReplaceAllTopicsRequest(args [2]string, argsEscaped // // POST /repos/{owner}/{repo}/pages/builds func (s *Server) handleReposRequestPagesBuildRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/request-pages-build"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76110,7 +94122,16 @@ func (s *Server) handleReposRequestPagesBuildRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76122,8 +94143,27 @@ func (s *Server) handleReposRequestPagesBuildRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76211,6 +94251,8 @@ func (s *Server) handleReposRequestPagesBuildRequest(args [2]string, argsEscaped // // POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins func (s *Server) handleReposSetAdminBranchProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/set-admin-branch-protection"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76232,7 +94274,16 @@ func (s *Server) handleReposSetAdminBranchProtectionRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76244,8 +94295,27 @@ func (s *Server) handleReposSetAdminBranchProtectionRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76347,6 +94417,8 @@ func (s *Server) handleReposSetAdminBranchProtectionRequest(args [3]string, args // // PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps func (s *Server) handleReposSetAppAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/set-app-access-restrictions"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -76368,7 +94440,16 @@ func (s *Server) handleReposSetAppAccessRestrictionsRequest(args [3]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76380,8 +94461,27 @@ func (s *Server) handleReposSetAppAccessRestrictionsRequest(args [3]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76486,6 +94586,8 @@ func (s *Server) handleReposSetAppAccessRestrictionsRequest(args [3]string, args // // PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts func (s *Server) handleReposSetStatusCheckContextsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/set-status-check-contexts"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -76507,7 +94609,16 @@ func (s *Server) handleReposSetStatusCheckContextsRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76519,8 +94630,27 @@ func (s *Server) handleReposSetStatusCheckContextsRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76636,6 +94766,8 @@ func (s *Server) handleReposSetStatusCheckContextsRequest(args [3]string, argsEs // // PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams func (s *Server) handleReposSetTeamAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/set-team-access-restrictions"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -76657,7 +94789,16 @@ func (s *Server) handleReposSetTeamAccessRestrictionsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76669,8 +94810,27 @@ func (s *Server) handleReposSetTeamAccessRestrictionsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76785,6 +94945,8 @@ func (s *Server) handleReposSetTeamAccessRestrictionsRequest(args [3]string, arg // // PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users func (s *Server) handleReposSetUserAccessRestrictionsRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/set-user-access-restrictions"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -76806,7 +94968,16 @@ func (s *Server) handleReposSetUserAccessRestrictionsRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76818,8 +94989,27 @@ func (s *Server) handleReposSetUserAccessRestrictionsRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76923,6 +95113,8 @@ func (s *Server) handleReposSetUserAccessRestrictionsRequest(args [3]string, arg // // POST /repos/{owner}/{repo}/hooks/{hook_id}/tests func (s *Server) handleReposTestPushWebhookRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/test-push-webhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76944,7 +95136,16 @@ func (s *Server) handleReposTestPushWebhookRequest(args [3]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76956,8 +95157,27 @@ func (s *Server) handleReposTestPushWebhookRequest(args [3]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77047,6 +95267,8 @@ func (s *Server) handleReposTestPushWebhookRequest(args [3]string, argsEscaped b // // POST /repos/{owner}/{repo}/transfer func (s *Server) handleReposTransferRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/transfer"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77068,7 +95290,16 @@ func (s *Server) handleReposTransferRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77080,8 +95311,27 @@ func (s *Server) handleReposTransferRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77179,6 +95429,8 @@ func (s *Server) handleReposTransferRequest(args [2]string, argsEscaped bool, w // // PATCH /repos/{owner}/{repo} func (s *Server) handleReposUpdateRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -77200,7 +95452,16 @@ func (s *Server) handleReposUpdateRequest(args [2]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77212,8 +95473,27 @@ func (s *Server) handleReposUpdateRequest(args [2]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77317,6 +95597,8 @@ func (s *Server) handleReposUpdateRequest(args [2]string, argsEscaped bool, w ht // // PUT /repos/{owner}/{repo}/branches/{branch}/protection func (s *Server) handleReposUpdateBranchProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-branch-protection"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -77338,7 +95620,16 @@ func (s *Server) handleReposUpdateBranchProtectionRequest(args [3]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77350,8 +95641,27 @@ func (s *Server) handleReposUpdateBranchProtectionRequest(args [3]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77452,6 +95762,8 @@ func (s *Server) handleReposUpdateBranchProtectionRequest(args [3]string, argsEs // // PATCH /repos/{owner}/{repo}/comments/{comment_id} func (s *Server) handleReposUpdateCommitCommentRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-commit-comment"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -77473,7 +95785,16 @@ func (s *Server) handleReposUpdateCommitCommentRequest(args [3]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77485,8 +95806,27 @@ func (s *Server) handleReposUpdateCommitCommentRequest(args [3]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77587,6 +95927,8 @@ func (s *Server) handleReposUpdateCommitCommentRequest(args [3]string, argsEscap // // PATCH /repos/{owner}/{repo}/invitations/{invitation_id} func (s *Server) handleReposUpdateInvitationRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-invitation"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -77608,7 +95950,16 @@ func (s *Server) handleReposUpdateInvitationRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77620,8 +95971,27 @@ func (s *Server) handleReposUpdateInvitationRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77729,6 +96099,8 @@ func (s *Server) handleReposUpdateInvitationRequest(args [3]string, argsEscaped // // PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews func (s *Server) handleReposUpdatePullRequestReviewProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-pull-request-review-protection"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -77750,7 +96122,16 @@ func (s *Server) handleReposUpdatePullRequestReviewProtectionRequest(args [3]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77762,8 +96143,27 @@ func (s *Server) handleReposUpdatePullRequestReviewProtectionRequest(args [3]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77864,6 +96264,8 @@ func (s *Server) handleReposUpdatePullRequestReviewProtectionRequest(args [3]str // // PATCH /repos/{owner}/{repo}/releases/{release_id} func (s *Server) handleReposUpdateReleaseRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-release"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -77885,7 +96287,16 @@ func (s *Server) handleReposUpdateReleaseRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77897,8 +96308,27 @@ func (s *Server) handleReposUpdateReleaseRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77999,6 +96429,8 @@ func (s *Server) handleReposUpdateReleaseRequest(args [3]string, argsEscaped boo // // PATCH /repos/{owner}/{repo}/releases/assets/{asset_id} func (s *Server) handleReposUpdateReleaseAssetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-release-asset"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -78020,7 +96452,16 @@ func (s *Server) handleReposUpdateReleaseAssetRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78032,8 +96473,27 @@ func (s *Server) handleReposUpdateReleaseAssetRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78140,6 +96600,8 @@ func (s *Server) handleReposUpdateReleaseAssetRequest(args [3]string, argsEscape // // PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks func (s *Server) handleReposUpdateStatusCheckProtectionRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-status-check-protection"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -78161,7 +96623,16 @@ func (s *Server) handleReposUpdateStatusCheckProtectionRequest(args [3]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78173,8 +96644,27 @@ func (s *Server) handleReposUpdateStatusCheckProtectionRequest(args [3]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78278,6 +96768,8 @@ func (s *Server) handleReposUpdateStatusCheckProtectionRequest(args [3]string, a // // PATCH /repos/{owner}/{repo}/hooks/{hook_id} func (s *Server) handleReposUpdateWebhookRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-webhook"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -78299,7 +96791,16 @@ func (s *Server) handleReposUpdateWebhookRequest(args [3]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78311,8 +96812,27 @@ func (s *Server) handleReposUpdateWebhookRequest(args [3]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78417,6 +96937,8 @@ func (s *Server) handleReposUpdateWebhookRequest(args [3]string, argsEscaped boo // // PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config func (s *Server) handleReposUpdateWebhookConfigForRepoRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/update-webhook-config-for-repo"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -78438,7 +96960,16 @@ func (s *Server) handleReposUpdateWebhookConfigForRepoRequest(args [3]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78450,8 +96981,27 @@ func (s *Server) handleReposUpdateWebhookConfigForRepoRequest(args [3]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78577,6 +97127,8 @@ func (s *Server) handleReposUpdateWebhookConfigForRepoRequest(args [3]string, ar // // POST /repos/{owner}/{repo}/releases/{release_id}/assets func (s *Server) handleReposUploadReleaseAssetRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("repos/upload-release-asset"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78598,7 +97150,16 @@ func (s *Server) handleReposUploadReleaseAssetRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78610,8 +97171,27 @@ func (s *Server) handleReposUploadReleaseAssetRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78720,6 +97300,8 @@ func (s *Server) handleReposUploadReleaseAssetRequest(args [3]string, argsEscape // // DELETE /scim/v2/organizations/{org}/Users/{scim_user_id} func (s *Server) handleScimDeleteUserFromOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("scim/delete-user-from-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -78741,7 +97323,16 @@ func (s *Server) handleScimDeleteUserFromOrgRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78753,8 +97344,27 @@ func (s *Server) handleScimDeleteUserFromOrgRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78855,6 +97465,8 @@ func (s *Server) handleScimDeleteUserFromOrgRequest(args [2]string, argsEscaped // // GET /search/code func (s *Server) handleSearchCodeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/code"), semconv.HTTPRequestMethodKey.String("GET"), @@ -78876,7 +97488,16 @@ func (s *Server) handleSearchCodeRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78888,8 +97509,27 @@ func (s *Server) handleSearchCodeRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78993,6 +97633,8 @@ func (s *Server) handleSearchCodeRequest(args [0]string, argsEscaped bool, w htt // // GET /search/commits func (s *Server) handleSearchCommitsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/commits"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79014,7 +97656,16 @@ func (s *Server) handleSearchCommitsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79026,8 +97677,27 @@ func (s *Server) handleSearchCommitsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79143,6 +97813,8 @@ func (s *Server) handleSearchCommitsRequest(args [0]string, argsEscaped bool, w // // GET /search/issues func (s *Server) handleSearchIssuesAndPullRequestsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/issues-and-pull-requests"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79164,7 +97836,16 @@ func (s *Server) handleSearchIssuesAndPullRequestsRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79176,8 +97857,27 @@ func (s *Server) handleSearchIssuesAndPullRequestsRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79280,6 +97980,8 @@ func (s *Server) handleSearchIssuesAndPullRequestsRequest(args [0]string, argsEs // // GET /search/labels func (s *Server) handleSearchLabelsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/labels"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79301,7 +98003,16 @@ func (s *Server) handleSearchLabelsRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79313,8 +98024,27 @@ func (s *Server) handleSearchLabelsRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79427,6 +98157,8 @@ func (s *Server) handleSearchLabelsRequest(args [0]string, argsEscaped bool, w h // // GET /search/repositories func (s *Server) handleSearchReposRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/repos"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79448,7 +98180,16 @@ func (s *Server) handleSearchReposRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79460,8 +98201,27 @@ func (s *Server) handleSearchReposRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79568,6 +98328,8 @@ func (s *Server) handleSearchReposRequest(args [0]string, argsEscaped bool, w ht // // GET /search/topics func (s *Server) handleSearchTopicsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/topics"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79589,7 +98351,16 @@ func (s *Server) handleSearchTopicsRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79601,8 +98372,27 @@ func (s *Server) handleSearchTopicsRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79699,6 +98489,8 @@ func (s *Server) handleSearchTopicsRequest(args [0]string, argsEscaped bool, w h // // GET /search/users func (s *Server) handleSearchUsersRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search/users"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79720,7 +98512,16 @@ func (s *Server) handleSearchUsersRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79732,8 +98533,27 @@ func (s *Server) handleSearchUsersRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79830,6 +98650,8 @@ func (s *Server) handleSearchUsersRequest(args [0]string, argsEscaped bool, w ht // // GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number} func (s *Server) handleSecretScanningGetAlertRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("secret-scanning/get-alert"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79851,7 +98673,16 @@ func (s *Server) handleSecretScanningGetAlertRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79863,8 +98694,27 @@ func (s *Server) handleSecretScanningGetAlertRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79954,6 +98804,8 @@ func (s *Server) handleSecretScanningGetAlertRequest(args [3]string, argsEscaped // // GET /orgs/{org}/secret-scanning/alerts func (s *Server) handleSecretScanningListAlertsForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("secret-scanning/list-alerts-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79975,7 +98827,16 @@ func (s *Server) handleSecretScanningListAlertsForOrgRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79987,8 +98848,27 @@ func (s *Server) handleSecretScanningListAlertsForOrgRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80085,6 +98965,8 @@ func (s *Server) handleSecretScanningListAlertsForOrgRequest(args [1]string, arg // // GET /repos/{owner}/{repo}/secret-scanning/alerts func (s *Server) handleSecretScanningListAlertsForRepoRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("secret-scanning/list-alerts-for-repo"), semconv.HTTPRequestMethodKey.String("GET"), @@ -80106,7 +98988,16 @@ func (s *Server) handleSecretScanningListAlertsForRepoRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80118,8 +99009,27 @@ func (s *Server) handleSecretScanningListAlertsForRepoRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80220,6 +99130,8 @@ func (s *Server) handleSecretScanningListAlertsForRepoRequest(args [2]string, ar // // PATCH /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number} func (s *Server) handleSecretScanningUpdateAlertRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("secret-scanning/update-alert"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -80241,7 +99153,16 @@ func (s *Server) handleSecretScanningUpdateAlertRequest(args [3]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80253,8 +99174,27 @@ func (s *Server) handleSecretScanningUpdateAlertRequest(args [3]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80376,6 +99316,8 @@ func (s *Server) handleSecretScanningUpdateAlertRequest(args [3]string, argsEsca // // PUT /teams/{team_id}/members/{username} func (s *Server) handleTeamsAddMemberLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-member-legacy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -80397,7 +99339,16 @@ func (s *Server) handleTeamsAddMemberLegacyRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80409,8 +99360,27 @@ func (s *Server) handleTeamsAddMemberLegacyRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80513,6 +99483,8 @@ func (s *Server) handleTeamsAddMemberLegacyRequest(args [2]string, argsEscaped b // // PUT /orgs/{org}/teams/{team_slug}/memberships/{username} func (s *Server) handleTeamsAddOrUpdateMembershipForUserInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-or-update-membership-for-user-in-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -80534,7 +99506,16 @@ func (s *Server) handleTeamsAddOrUpdateMembershipForUserInOrgRequest(args [3]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80546,8 +99527,27 @@ func (s *Server) handleTeamsAddOrUpdateMembershipForUserInOrgRequest(args [3]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80674,6 +99674,8 @@ func (s *Server) handleTeamsAddOrUpdateMembershipForUserInOrgRequest(args [3]str // // PUT /teams/{team_id}/memberships/{username} func (s *Server) handleTeamsAddOrUpdateMembershipForUserLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-or-update-membership-for-user-legacy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -80695,7 +99697,16 @@ func (s *Server) handleTeamsAddOrUpdateMembershipForUserLegacyRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80707,8 +99718,27 @@ func (s *Server) handleTeamsAddOrUpdateMembershipForUserLegacyRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80809,6 +99839,8 @@ func (s *Server) handleTeamsAddOrUpdateMembershipForUserLegacyRequest(args [2]st // // PUT /orgs/{org}/teams/{team_slug}/projects/{project_id} func (s *Server) handleTeamsAddOrUpdateProjectPermissionsInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-or-update-project-permissions-in-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -80830,7 +99862,16 @@ func (s *Server) handleTeamsAddOrUpdateProjectPermissionsInOrgRequest(args [3]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80842,8 +99883,27 @@ func (s *Server) handleTeamsAddOrUpdateProjectPermissionsInOrgRequest(args [3]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80952,6 +100012,8 @@ func (s *Server) handleTeamsAddOrUpdateProjectPermissionsInOrgRequest(args [3]st // // PUT /teams/{team_id}/projects/{project_id} func (s *Server) handleTeamsAddOrUpdateProjectPermissionsLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-or-update-project-permissions-legacy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -80973,7 +100035,16 @@ func (s *Server) handleTeamsAddOrUpdateProjectPermissionsLegacyRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80985,8 +100056,27 @@ func (s *Server) handleTeamsAddOrUpdateProjectPermissionsLegacyRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81094,6 +100184,8 @@ func (s *Server) handleTeamsAddOrUpdateProjectPermissionsLegacyRequest(args [2]s // // PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} func (s *Server) handleTeamsAddOrUpdateRepoPermissionsInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-or-update-repo-permissions-in-org"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -81115,7 +100207,16 @@ func (s *Server) handleTeamsAddOrUpdateRepoPermissionsInOrgRequest(args [4]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81127,8 +100228,27 @@ func (s *Server) handleTeamsAddOrUpdateRepoPermissionsInOrgRequest(args [4]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81246,6 +100366,8 @@ func (s *Server) handleTeamsAddOrUpdateRepoPermissionsInOrgRequest(args [4]strin // // PUT /teams/{team_id}/repos/{owner}/{repo} func (s *Server) handleTeamsAddOrUpdateRepoPermissionsLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/add-or-update-repo-permissions-legacy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -81267,7 +100389,16 @@ func (s *Server) handleTeamsAddOrUpdateRepoPermissionsLegacyRequest(args [3]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81279,8 +100410,27 @@ func (s *Server) handleTeamsAddOrUpdateRepoPermissionsLegacyRequest(args [3]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81384,6 +100534,8 @@ func (s *Server) handleTeamsAddOrUpdateRepoPermissionsLegacyRequest(args [3]stri // // GET /orgs/{org}/teams/{team_slug}/projects/{project_id} func (s *Server) handleTeamsCheckPermissionsForProjectInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/check-permissions-for-project-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81405,7 +100557,16 @@ func (s *Server) handleTeamsCheckPermissionsForProjectInOrgRequest(args [3]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81417,8 +100578,27 @@ func (s *Server) handleTeamsCheckPermissionsForProjectInOrgRequest(args [3]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81511,6 +100691,8 @@ func (s *Server) handleTeamsCheckPermissionsForProjectInOrgRequest(args [3]strin // // GET /teams/{team_id}/projects/{project_id} func (s *Server) handleTeamsCheckPermissionsForProjectLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/check-permissions-for-project-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81532,7 +100714,16 @@ func (s *Server) handleTeamsCheckPermissionsForProjectLegacyRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81544,8 +100735,27 @@ func (s *Server) handleTeamsCheckPermissionsForProjectLegacyRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81635,6 +100845,8 @@ func (s *Server) handleTeamsCheckPermissionsForProjectLegacyRequest(args [2]stri // // GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} func (s *Server) handleTeamsCheckPermissionsForRepoInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/check-permissions-for-repo-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81656,7 +100868,16 @@ func (s *Server) handleTeamsCheckPermissionsForRepoInOrgRequest(args [4]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81668,8 +100889,27 @@ func (s *Server) handleTeamsCheckPermissionsForRepoInOrgRequest(args [4]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81768,6 +101008,8 @@ func (s *Server) handleTeamsCheckPermissionsForRepoInOrgRequest(args [4]string, // // GET /teams/{team_id}/repos/{owner}/{repo} func (s *Server) handleTeamsCheckPermissionsForRepoLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/check-permissions-for-repo-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81789,7 +101031,16 @@ func (s *Server) handleTeamsCheckPermissionsForRepoLegacyRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81801,8 +101052,27 @@ func (s *Server) handleTeamsCheckPermissionsForRepoLegacyRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81895,6 +101165,8 @@ func (s *Server) handleTeamsCheckPermissionsForRepoLegacyRequest(args [3]string, // // POST /orgs/{org}/teams func (s *Server) handleTeamsCreateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81916,7 +101188,16 @@ func (s *Server) handleTeamsCreateRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81928,8 +101209,27 @@ func (s *Server) handleTeamsCreateRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82032,6 +101332,8 @@ func (s *Server) handleTeamsCreateRequest(args [1]string, argsEscaped bool, w ht // // POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments func (s *Server) handleTeamsCreateDiscussionCommentInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create-discussion-comment-in-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82053,7 +101355,16 @@ func (s *Server) handleTeamsCreateDiscussionCommentInOrgRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82065,8 +101376,27 @@ func (s *Server) handleTeamsCreateDiscussionCommentInOrgRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82180,6 +101510,8 @@ func (s *Server) handleTeamsCreateDiscussionCommentInOrgRequest(args [3]string, // // POST /teams/{team_id}/discussions/{discussion_number}/comments func (s *Server) handleTeamsCreateDiscussionCommentLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create-discussion-comment-legacy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82201,7 +101533,16 @@ func (s *Server) handleTeamsCreateDiscussionCommentLegacyRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82213,8 +101554,27 @@ func (s *Server) handleTeamsCreateDiscussionCommentLegacyRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82321,6 +101681,8 @@ func (s *Server) handleTeamsCreateDiscussionCommentLegacyRequest(args [2]string, // // POST /orgs/{org}/teams/{team_slug}/discussions func (s *Server) handleTeamsCreateDiscussionInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create-discussion-in-org"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82342,7 +101704,16 @@ func (s *Server) handleTeamsCreateDiscussionInOrgRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82354,8 +101725,27 @@ func (s *Server) handleTeamsCreateDiscussionInOrgRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82465,6 +101855,8 @@ func (s *Server) handleTeamsCreateDiscussionInOrgRequest(args [2]string, argsEsc // // POST /teams/{team_id}/discussions func (s *Server) handleTeamsCreateDiscussionLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create-discussion-legacy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82486,7 +101878,16 @@ func (s *Server) handleTeamsCreateDiscussionLegacyRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82498,8 +101899,27 @@ func (s *Server) handleTeamsCreateDiscussionLegacyRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82599,6 +102019,8 @@ func (s *Server) handleTeamsCreateDiscussionLegacyRequest(args [1]string, argsEs // // PATCH /orgs/{org}/teams/{team_slug}/team-sync/group-mappings func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create-or-update-idp-group-connections-in-org"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -82620,7 +102042,16 @@ func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsInOrgRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82632,8 +102063,27 @@ func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsInOrgRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82741,6 +102191,8 @@ func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsInOrgRequest(args [ // // PATCH /teams/{team_id}/team-sync/group-mappings func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/create-or-update-idp-group-connections-legacy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -82762,7 +102214,16 @@ func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsLegacyRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82774,8 +102235,27 @@ func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsLegacyRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82871,6 +102351,8 @@ func (s *Server) handleTeamsCreateOrUpdateIdpGroupConnectionsLegacyRequest(args // // DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number} func (s *Server) handleTeamsDeleteDiscussionCommentInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/delete-discussion-comment-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -82892,7 +102374,16 @@ func (s *Server) handleTeamsDeleteDiscussionCommentInOrgRequest(args [4]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82904,8 +102395,27 @@ func (s *Server) handleTeamsDeleteDiscussionCommentInOrgRequest(args [4]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83001,6 +102511,8 @@ func (s *Server) handleTeamsDeleteDiscussionCommentInOrgRequest(args [4]string, // // DELETE /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number} func (s *Server) handleTeamsDeleteDiscussionCommentLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/delete-discussion-comment-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -83022,7 +102534,16 @@ func (s *Server) handleTeamsDeleteDiscussionCommentLegacyRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83034,8 +102555,27 @@ func (s *Server) handleTeamsDeleteDiscussionCommentLegacyRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83124,6 +102664,8 @@ func (s *Server) handleTeamsDeleteDiscussionCommentLegacyRequest(args [3]string, // // DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number} func (s *Server) handleTeamsDeleteDiscussionInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/delete-discussion-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -83145,7 +102687,16 @@ func (s *Server) handleTeamsDeleteDiscussionInOrgRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83157,8 +102708,27 @@ func (s *Server) handleTeamsDeleteDiscussionInOrgRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83250,6 +102820,8 @@ func (s *Server) handleTeamsDeleteDiscussionInOrgRequest(args [3]string, argsEsc // // DELETE /teams/{team_id}/discussions/{discussion_number} func (s *Server) handleTeamsDeleteDiscussionLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/delete-discussion-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -83271,7 +102843,16 @@ func (s *Server) handleTeamsDeleteDiscussionLegacyRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83283,8 +102864,27 @@ func (s *Server) handleTeamsDeleteDiscussionLegacyRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83370,6 +102970,8 @@ func (s *Server) handleTeamsDeleteDiscussionLegacyRequest(args [2]string, argsEs // // DELETE /orgs/{org}/teams/{team_slug} func (s *Server) handleTeamsDeleteInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/delete-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -83391,7 +102993,16 @@ func (s *Server) handleTeamsDeleteInOrgRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83403,8 +103014,27 @@ func (s *Server) handleTeamsDeleteInOrgRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83493,6 +103123,8 @@ func (s *Server) handleTeamsDeleteInOrgRequest(args [2]string, argsEscaped bool, // // DELETE /teams/{team_id} func (s *Server) handleTeamsDeleteLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/delete-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -83514,7 +103146,16 @@ func (s *Server) handleTeamsDeleteLegacyRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83526,8 +103167,27 @@ func (s *Server) handleTeamsDeleteLegacyRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83607,6 +103267,8 @@ func (s *Server) handleTeamsDeleteLegacyRequest(args [1]string, argsEscaped bool // // GET /orgs/{org}/teams/{team_slug} func (s *Server) handleTeamsGetByNameRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-by-name"), semconv.HTTPRequestMethodKey.String("GET"), @@ -83628,7 +103290,16 @@ func (s *Server) handleTeamsGetByNameRequest(args [2]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83640,8 +103311,27 @@ func (s *Server) handleTeamsGetByNameRequest(args [2]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83726,6 +103416,8 @@ func (s *Server) handleTeamsGetByNameRequest(args [2]string, argsEscaped bool, w // // GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number} func (s *Server) handleTeamsGetDiscussionCommentInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-discussion-comment-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -83747,7 +103439,16 @@ func (s *Server) handleTeamsGetDiscussionCommentInOrgRequest(args [4]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83759,8 +103460,27 @@ func (s *Server) handleTeamsGetDiscussionCommentInOrgRequest(args [4]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83856,6 +103576,8 @@ func (s *Server) handleTeamsGetDiscussionCommentInOrgRequest(args [4]string, arg // // GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number} func (s *Server) handleTeamsGetDiscussionCommentLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-discussion-comment-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -83877,7 +103599,16 @@ func (s *Server) handleTeamsGetDiscussionCommentLegacyRequest(args [3]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83889,8 +103620,27 @@ func (s *Server) handleTeamsGetDiscussionCommentLegacyRequest(args [3]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83979,6 +103729,8 @@ func (s *Server) handleTeamsGetDiscussionCommentLegacyRequest(args [3]string, ar // // GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number} func (s *Server) handleTeamsGetDiscussionInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-discussion-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84000,7 +103752,16 @@ func (s *Server) handleTeamsGetDiscussionInOrgRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84012,8 +103773,27 @@ func (s *Server) handleTeamsGetDiscussionInOrgRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84105,6 +103885,8 @@ func (s *Server) handleTeamsGetDiscussionInOrgRequest(args [3]string, argsEscape // // GET /teams/{team_id}/discussions/{discussion_number} func (s *Server) handleTeamsGetDiscussionLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-discussion-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84126,7 +103908,16 @@ func (s *Server) handleTeamsGetDiscussionLegacyRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84138,8 +103929,27 @@ func (s *Server) handleTeamsGetDiscussionLegacyRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84225,6 +104035,8 @@ func (s *Server) handleTeamsGetDiscussionLegacyRequest(args [2]string, argsEscap // // GET /teams/{team_id} func (s *Server) handleTeamsGetLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84246,7 +104058,16 @@ func (s *Server) handleTeamsGetLegacyRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84258,8 +104079,27 @@ func (s *Server) handleTeamsGetLegacyRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84343,6 +104183,8 @@ func (s *Server) handleTeamsGetLegacyRequest(args [1]string, argsEscaped bool, w // // GET /teams/{team_id}/members/{username} func (s *Server) handleTeamsGetMemberLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-member-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84364,7 +104206,16 @@ func (s *Server) handleTeamsGetMemberLegacyRequest(args [2]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84376,8 +104227,27 @@ func (s *Server) handleTeamsGetMemberLegacyRequest(args [2]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84466,6 +104336,8 @@ func (s *Server) handleTeamsGetMemberLegacyRequest(args [2]string, argsEscaped b // // GET /orgs/{org}/teams/{team_slug}/memberships/{username} func (s *Server) handleTeamsGetMembershipForUserInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-membership-for-user-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84487,7 +104359,16 @@ func (s *Server) handleTeamsGetMembershipForUserInOrgRequest(args [3]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84499,8 +104380,27 @@ func (s *Server) handleTeamsGetMembershipForUserInOrgRequest(args [3]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84596,6 +104496,8 @@ func (s *Server) handleTeamsGetMembershipForUserInOrgRequest(args [3]string, arg // // GET /teams/{team_id}/memberships/{username} func (s *Server) handleTeamsGetMembershipForUserLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/get-membership-for-user-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84617,7 +104519,16 @@ func (s *Server) handleTeamsGetMembershipForUserLegacyRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84629,8 +104540,27 @@ func (s *Server) handleTeamsGetMembershipForUserLegacyRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84712,6 +104642,8 @@ func (s *Server) handleTeamsGetMembershipForUserLegacyRequest(args [2]string, ar // // GET /orgs/{org}/teams func (s *Server) handleTeamsListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84733,7 +104665,16 @@ func (s *Server) handleTeamsListRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84745,8 +104686,27 @@ func (s *Server) handleTeamsListRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84834,6 +104794,8 @@ func (s *Server) handleTeamsListRequest(args [1]string, argsEscaped bool, w http // // GET /orgs/{org}/teams/{team_slug}/teams func (s *Server) handleTeamsListChildInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-child-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84855,7 +104817,16 @@ func (s *Server) handleTeamsListChildInOrgRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84867,8 +104838,27 @@ func (s *Server) handleTeamsListChildInOrgRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84962,6 +104952,8 @@ func (s *Server) handleTeamsListChildInOrgRequest(args [2]string, argsEscaped bo // // GET /teams/{team_id}/teams func (s *Server) handleTeamsListChildLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-child-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -84983,7 +104975,16 @@ func (s *Server) handleTeamsListChildLegacyRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84995,8 +104996,27 @@ func (s *Server) handleTeamsListChildLegacyRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85085,6 +105105,8 @@ func (s *Server) handleTeamsListChildLegacyRequest(args [1]string, argsEscaped b // // GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments func (s *Server) handleTeamsListDiscussionCommentsInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-discussion-comments-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85106,7 +105128,16 @@ func (s *Server) handleTeamsListDiscussionCommentsInOrgRequest(args [3]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85118,8 +105149,27 @@ func (s *Server) handleTeamsListDiscussionCommentsInOrgRequest(args [3]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85223,6 +105273,8 @@ func (s *Server) handleTeamsListDiscussionCommentsInOrgRequest(args [3]string, a // // GET /teams/{team_id}/discussions/{discussion_number}/comments func (s *Server) handleTeamsListDiscussionCommentsLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-discussion-comments-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85244,7 +105296,16 @@ func (s *Server) handleTeamsListDiscussionCommentsLegacyRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85256,8 +105317,27 @@ func (s *Server) handleTeamsListDiscussionCommentsLegacyRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85354,6 +105434,8 @@ func (s *Server) handleTeamsListDiscussionCommentsLegacyRequest(args [2]string, // // GET /orgs/{org}/teams/{team_slug}/discussions func (s *Server) handleTeamsListDiscussionsInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-discussions-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85375,7 +105457,16 @@ func (s *Server) handleTeamsListDiscussionsInOrgRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85387,8 +105478,27 @@ func (s *Server) handleTeamsListDiscussionsInOrgRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85492,6 +105602,8 @@ func (s *Server) handleTeamsListDiscussionsInOrgRequest(args [2]string, argsEsca // // GET /teams/{team_id}/discussions func (s *Server) handleTeamsListDiscussionsLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-discussions-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85513,7 +105625,16 @@ func (s *Server) handleTeamsListDiscussionsLegacyRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85525,8 +105646,27 @@ func (s *Server) handleTeamsListDiscussionsLegacyRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85619,6 +105759,8 @@ func (s *Server) handleTeamsListDiscussionsLegacyRequest(args [1]string, argsEsc // // GET /user/teams func (s *Server) handleTeamsListForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85640,7 +105782,16 @@ func (s *Server) handleTeamsListForAuthenticatedUserRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85652,8 +105803,27 @@ func (s *Server) handleTeamsListForAuthenticatedUserRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85743,6 +105913,8 @@ func (s *Server) handleTeamsListForAuthenticatedUserRequest(args [0]string, args // // GET /teams/{team_id}/team-sync/group-mappings func (s *Server) handleTeamsListIdpGroupsForLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-idp-groups-for-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85764,7 +105936,16 @@ func (s *Server) handleTeamsListIdpGroupsForLegacyRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85776,8 +105957,27 @@ func (s *Server) handleTeamsListIdpGroupsForLegacyRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85861,6 +106061,8 @@ func (s *Server) handleTeamsListIdpGroupsForLegacyRequest(args [1]string, argsEs // // GET /orgs/{org}/team-sync/groups func (s *Server) handleTeamsListIdpGroupsForOrgRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-idp-groups-for-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -85882,7 +106084,16 @@ func (s *Server) handleTeamsListIdpGroupsForOrgRequest(args [1]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85894,8 +106105,27 @@ func (s *Server) handleTeamsListIdpGroupsForOrgRequest(args [1]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85986,6 +106216,8 @@ func (s *Server) handleTeamsListIdpGroupsForOrgRequest(args [1]string, argsEscap // // GET /orgs/{org}/teams/{team_slug}/team-sync/group-mappings func (s *Server) handleTeamsListIdpGroupsInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-idp-groups-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86007,7 +106239,16 @@ func (s *Server) handleTeamsListIdpGroupsInOrgRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86019,8 +106260,27 @@ func (s *Server) handleTeamsListIdpGroupsInOrgRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86103,6 +106363,8 @@ func (s *Server) handleTeamsListIdpGroupsInOrgRequest(args [2]string, argsEscape // // GET /orgs/{org}/teams/{team_slug}/members func (s *Server) handleTeamsListMembersInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-members-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86124,7 +106386,16 @@ func (s *Server) handleTeamsListMembersInOrgRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86136,8 +106407,27 @@ func (s *Server) handleTeamsListMembersInOrgRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86236,6 +106526,8 @@ func (s *Server) handleTeamsListMembersInOrgRequest(args [2]string, argsEscaped // // GET /teams/{team_id}/members func (s *Server) handleTeamsListMembersLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-members-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86257,7 +106549,16 @@ func (s *Server) handleTeamsListMembersLegacyRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86269,8 +106570,27 @@ func (s *Server) handleTeamsListMembersLegacyRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86365,6 +106685,8 @@ func (s *Server) handleTeamsListMembersLegacyRequest(args [1]string, argsEscaped // // GET /orgs/{org}/teams/{team_slug}/invitations func (s *Server) handleTeamsListPendingInvitationsInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-pending-invitations-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86386,7 +106708,16 @@ func (s *Server) handleTeamsListPendingInvitationsInOrgRequest(args [2]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86398,8 +106729,27 @@ func (s *Server) handleTeamsListPendingInvitationsInOrgRequest(args [2]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86497,6 +106847,8 @@ func (s *Server) handleTeamsListPendingInvitationsInOrgRequest(args [2]string, a // // GET /teams/{team_id}/invitations func (s *Server) handleTeamsListPendingInvitationsLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-pending-invitations-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86518,7 +106870,16 @@ func (s *Server) handleTeamsListPendingInvitationsLegacyRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86530,8 +106891,27 @@ func (s *Server) handleTeamsListPendingInvitationsLegacyRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86619,6 +106999,8 @@ func (s *Server) handleTeamsListPendingInvitationsLegacyRequest(args [1]string, // // GET /orgs/{org}/teams/{team_slug}/projects func (s *Server) handleTeamsListProjectsInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-projects-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86640,7 +107022,16 @@ func (s *Server) handleTeamsListProjectsInOrgRequest(args [2]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86652,8 +107043,27 @@ func (s *Server) handleTeamsListProjectsInOrgRequest(args [2]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86748,6 +107158,8 @@ func (s *Server) handleTeamsListProjectsInOrgRequest(args [2]string, argsEscaped // // GET /teams/{team_id}/projects func (s *Server) handleTeamsListProjectsLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-projects-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86769,7 +107181,16 @@ func (s *Server) handleTeamsListProjectsLegacyRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86781,8 +107202,27 @@ func (s *Server) handleTeamsListProjectsLegacyRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86870,6 +107310,8 @@ func (s *Server) handleTeamsListProjectsLegacyRequest(args [1]string, argsEscape // // GET /orgs/{org}/teams/{team_slug}/repos func (s *Server) handleTeamsListReposInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-repos-in-org"), semconv.HTTPRequestMethodKey.String("GET"), @@ -86891,7 +107333,16 @@ func (s *Server) handleTeamsListReposInOrgRequest(args [2]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86903,8 +107354,27 @@ func (s *Server) handleTeamsListReposInOrgRequest(args [2]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86998,6 +107468,8 @@ func (s *Server) handleTeamsListReposInOrgRequest(args [2]string, argsEscaped bo // // GET /teams/{team_id}/repos func (s *Server) handleTeamsListReposLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/list-repos-legacy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -87019,7 +107491,16 @@ func (s *Server) handleTeamsListReposLegacyRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87031,8 +107512,27 @@ func (s *Server) handleTeamsListReposLegacyRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87138,6 +107638,8 @@ func (s *Server) handleTeamsListReposLegacyRequest(args [1]string, argsEscaped b // // DELETE /teams/{team_id}/members/{username} func (s *Server) handleTeamsRemoveMemberLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-member-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87159,7 +107661,16 @@ func (s *Server) handleTeamsRemoveMemberLegacyRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87171,8 +107682,27 @@ func (s *Server) handleTeamsRemoveMemberLegacyRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87268,6 +107798,8 @@ func (s *Server) handleTeamsRemoveMemberLegacyRequest(args [2]string, argsEscape // // DELETE /orgs/{org}/teams/{team_slug}/memberships/{username} func (s *Server) handleTeamsRemoveMembershipForUserInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-membership-for-user-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87289,7 +107821,16 @@ func (s *Server) handleTeamsRemoveMembershipForUserInOrgRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87301,8 +107842,27 @@ func (s *Server) handleTeamsRemoveMembershipForUserInOrgRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87405,6 +107965,8 @@ func (s *Server) handleTeamsRemoveMembershipForUserInOrgRequest(args [3]string, // // DELETE /teams/{team_id}/memberships/{username} func (s *Server) handleTeamsRemoveMembershipForUserLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-membership-for-user-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87426,7 +107988,16 @@ func (s *Server) handleTeamsRemoveMembershipForUserLegacyRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87438,8 +108009,27 @@ func (s *Server) handleTeamsRemoveMembershipForUserLegacyRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87526,6 +108116,8 @@ func (s *Server) handleTeamsRemoveMembershipForUserLegacyRequest(args [2]string, // // DELETE /orgs/{org}/teams/{team_slug}/projects/{project_id} func (s *Server) handleTeamsRemoveProjectInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-project-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87547,7 +108139,16 @@ func (s *Server) handleTeamsRemoveProjectInOrgRequest(args [3]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87559,8 +108160,27 @@ func (s *Server) handleTeamsRemoveProjectInOrgRequest(args [3]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87654,6 +108274,8 @@ func (s *Server) handleTeamsRemoveProjectInOrgRequest(args [3]string, argsEscape // // DELETE /teams/{team_id}/projects/{project_id} func (s *Server) handleTeamsRemoveProjectLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-project-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87675,7 +108297,16 @@ func (s *Server) handleTeamsRemoveProjectLegacyRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87687,8 +108318,27 @@ func (s *Server) handleTeamsRemoveProjectLegacyRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87775,6 +108425,8 @@ func (s *Server) handleTeamsRemoveProjectLegacyRequest(args [2]string, argsEscap // // DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} func (s *Server) handleTeamsRemoveRepoInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-repo-in-org"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87796,7 +108448,16 @@ func (s *Server) handleTeamsRemoveRepoInOrgRequest(args [4]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87808,8 +108469,27 @@ func (s *Server) handleTeamsRemoveRepoInOrgRequest(args [4]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87907,6 +108587,8 @@ func (s *Server) handleTeamsRemoveRepoInOrgRequest(args [4]string, argsEscaped b // // DELETE /teams/{team_id}/repos/{owner}/{repo} func (s *Server) handleTeamsRemoveRepoLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/remove-repo-legacy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -87928,7 +108610,16 @@ func (s *Server) handleTeamsRemoveRepoLegacyRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87940,8 +108631,27 @@ func (s *Server) handleTeamsRemoveRepoLegacyRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88030,6 +108740,8 @@ func (s *Server) handleTeamsRemoveRepoLegacyRequest(args [3]string, argsEscaped // // PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number} func (s *Server) handleTeamsUpdateDiscussionCommentInOrgRequest(args [4]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/update-discussion-comment-in-org"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -88051,7 +108763,16 @@ func (s *Server) handleTeamsUpdateDiscussionCommentInOrgRequest(args [4]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88063,8 +108784,27 @@ func (s *Server) handleTeamsUpdateDiscussionCommentInOrgRequest(args [4]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88175,6 +108915,8 @@ func (s *Server) handleTeamsUpdateDiscussionCommentInOrgRequest(args [4]string, // // PATCH /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number} func (s *Server) handleTeamsUpdateDiscussionCommentLegacyRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/update-discussion-comment-legacy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -88196,7 +108938,16 @@ func (s *Server) handleTeamsUpdateDiscussionCommentLegacyRequest(args [3]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88208,8 +108959,27 @@ func (s *Server) handleTeamsUpdateDiscussionCommentLegacyRequest(args [3]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88314,6 +109084,8 @@ func (s *Server) handleTeamsUpdateDiscussionCommentLegacyRequest(args [3]string, // // PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number} func (s *Server) handleTeamsUpdateDiscussionInOrgRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/update-discussion-in-org"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -88335,7 +109107,16 @@ func (s *Server) handleTeamsUpdateDiscussionInOrgRequest(args [3]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88347,8 +109128,27 @@ func (s *Server) handleTeamsUpdateDiscussionInOrgRequest(args [3]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88456,6 +109256,8 @@ func (s *Server) handleTeamsUpdateDiscussionInOrgRequest(args [3]string, argsEsc // // PATCH /teams/{team_id}/discussions/{discussion_number} func (s *Server) handleTeamsUpdateDiscussionLegacyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/update-discussion-legacy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -88477,7 +109279,16 @@ func (s *Server) handleTeamsUpdateDiscussionLegacyRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88489,8 +109300,27 @@ func (s *Server) handleTeamsUpdateDiscussionLegacyRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88589,6 +109419,8 @@ func (s *Server) handleTeamsUpdateDiscussionLegacyRequest(args [2]string, argsEs // // PATCH /orgs/{org}/teams/{team_slug} func (s *Server) handleTeamsUpdateInOrgRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/update-in-org"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -88610,7 +109442,16 @@ func (s *Server) handleTeamsUpdateInOrgRequest(args [2]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88622,8 +109463,27 @@ func (s *Server) handleTeamsUpdateInOrgRequest(args [2]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88726,6 +109586,8 @@ func (s *Server) handleTeamsUpdateInOrgRequest(args [2]string, argsEscaped bool, // // PATCH /teams/{team_id} func (s *Server) handleTeamsUpdateLegacyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("teams/update-legacy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -88747,7 +109609,16 @@ func (s *Server) handleTeamsUpdateLegacyRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88759,8 +109630,27 @@ func (s *Server) handleTeamsUpdateLegacyRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88853,6 +109743,8 @@ func (s *Server) handleTeamsUpdateLegacyRequest(args [1]string, argsEscaped bool // // POST /user/emails func (s *Server) handleUsersAddEmailForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/add-email-for-authenticated"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88874,7 +109766,16 @@ func (s *Server) handleUsersAddEmailForAuthenticatedRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88886,8 +109787,27 @@ func (s *Server) handleUsersAddEmailForAuthenticatedRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88965,6 +109885,8 @@ func (s *Server) handleUsersAddEmailForAuthenticatedRequest(args [0]string, args // // PUT /user/blocks/{username} func (s *Server) handleUsersBlockRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/block"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -88986,7 +109908,16 @@ func (s *Server) handleUsersBlockRequest(args [1]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88998,8 +109929,27 @@ func (s *Server) handleUsersBlockRequest(args [1]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89077,6 +110027,8 @@ func (s *Server) handleUsersBlockRequest(args [1]string, argsEscaped bool, w htt // // GET /user/blocks/{username} func (s *Server) handleUsersCheckBlockedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/check-blocked"), semconv.HTTPRequestMethodKey.String("GET"), @@ -89098,7 +110050,16 @@ func (s *Server) handleUsersCheckBlockedRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89110,8 +110071,27 @@ func (s *Server) handleUsersCheckBlockedRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89189,6 +110169,8 @@ func (s *Server) handleUsersCheckBlockedRequest(args [1]string, argsEscaped bool // // GET /users/{username}/following/{target_user} func (s *Server) handleUsersCheckFollowingForUserRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/check-following-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -89210,7 +110192,16 @@ func (s *Server) handleUsersCheckFollowingForUserRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89222,8 +110213,27 @@ func (s *Server) handleUsersCheckFollowingForUserRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89305,6 +110315,8 @@ func (s *Server) handleUsersCheckFollowingForUserRequest(args [2]string, argsEsc // // GET /user/following/{username} func (s *Server) handleUsersCheckPersonIsFollowedByAuthenticatedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/check-person-is-followed-by-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -89326,7 +110338,16 @@ func (s *Server) handleUsersCheckPersonIsFollowedByAuthenticatedRequest(args [1] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89338,8 +110359,27 @@ func (s *Server) handleUsersCheckPersonIsFollowedByAuthenticatedRequest(args [1] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89419,6 +110459,8 @@ func (s *Server) handleUsersCheckPersonIsFollowedByAuthenticatedRequest(args [1] // // POST /user/gpg_keys func (s *Server) handleUsersCreateGpgKeyForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/create-gpg-key-for-authenticated"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89440,7 +110482,16 @@ func (s *Server) handleUsersCreateGpgKeyForAuthenticatedRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89452,8 +110503,27 @@ func (s *Server) handleUsersCreateGpgKeyForAuthenticatedRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89533,6 +110603,8 @@ func (s *Server) handleUsersCreateGpgKeyForAuthenticatedRequest(args [0]string, // // POST /user/keys func (s *Server) handleUsersCreatePublicSSHKeyForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/create-public-ssh-key-for-authenticated"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89554,7 +110626,16 @@ func (s *Server) handleUsersCreatePublicSSHKeyForAuthenticatedRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89566,8 +110647,27 @@ func (s *Server) handleUsersCreatePublicSSHKeyForAuthenticatedRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89645,6 +110745,8 @@ func (s *Server) handleUsersCreatePublicSSHKeyForAuthenticatedRequest(args [0]st // // DELETE /user/emails func (s *Server) handleUsersDeleteEmailForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/delete-email-for-authenticated"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -89666,7 +110768,16 @@ func (s *Server) handleUsersDeleteEmailForAuthenticatedRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89678,8 +110789,27 @@ func (s *Server) handleUsersDeleteEmailForAuthenticatedRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89759,6 +110889,8 @@ func (s *Server) handleUsersDeleteEmailForAuthenticatedRequest(args [0]string, a // // DELETE /user/gpg_keys/{gpg_key_id} func (s *Server) handleUsersDeleteGpgKeyForAuthenticatedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/delete-gpg-key-for-authenticated"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -89780,7 +110912,16 @@ func (s *Server) handleUsersDeleteGpgKeyForAuthenticatedRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89792,8 +110933,27 @@ func (s *Server) handleUsersDeleteGpgKeyForAuthenticatedRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89873,6 +111033,8 @@ func (s *Server) handleUsersDeleteGpgKeyForAuthenticatedRequest(args [1]string, // // DELETE /user/keys/{key_id} func (s *Server) handleUsersDeletePublicSSHKeyForAuthenticatedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/delete-public-ssh-key-for-authenticated"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -89894,7 +111056,16 @@ func (s *Server) handleUsersDeletePublicSSHKeyForAuthenticatedRequest(args [1]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89906,8 +111077,27 @@ func (s *Server) handleUsersDeletePublicSSHKeyForAuthenticatedRequest(args [1]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89989,6 +111179,8 @@ func (s *Server) handleUsersDeletePublicSSHKeyForAuthenticatedRequest(args [1]st // // PUT /user/following/{username} func (s *Server) handleUsersFollowRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/follow"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -90010,7 +111202,16 @@ func (s *Server) handleUsersFollowRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90022,8 +111223,27 @@ func (s *Server) handleUsersFollowRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90104,6 +111324,8 @@ func (s *Server) handleUsersFollowRequest(args [1]string, argsEscaped bool, w ht // // GET /user func (s *Server) handleUsersGetAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/get-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90125,7 +111347,16 @@ func (s *Server) handleUsersGetAuthenticatedRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90137,8 +111368,27 @@ func (s *Server) handleUsersGetAuthenticatedRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -90211,6 +111461,8 @@ func (s *Server) handleUsersGetAuthenticatedRequest(args [0]string, argsEscaped // // GET /users/{username} func (s *Server) handleUsersGetByUsernameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/get-by-username"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90232,7 +111484,16 @@ func (s *Server) handleUsersGetByUsernameRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90244,8 +111505,27 @@ func (s *Server) handleUsersGetByUsernameRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90332,6 +111612,8 @@ func (s *Server) handleUsersGetByUsernameRequest(args [1]string, argsEscaped boo // // GET /users/{username}/hovercard func (s *Server) handleUsersGetContextForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/get-context-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90353,7 +111635,16 @@ func (s *Server) handleUsersGetContextForUserRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90365,8 +111656,27 @@ func (s *Server) handleUsersGetContextForUserRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90454,6 +111764,8 @@ func (s *Server) handleUsersGetContextForUserRequest(args [1]string, argsEscaped // // GET /user/gpg_keys/{gpg_key_id} func (s *Server) handleUsersGetGpgKeyForAuthenticatedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/get-gpg-key-for-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90475,7 +111787,16 @@ func (s *Server) handleUsersGetGpgKeyForAuthenticatedRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90487,8 +111808,27 @@ func (s *Server) handleUsersGetGpgKeyForAuthenticatedRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90568,6 +111908,8 @@ func (s *Server) handleUsersGetGpgKeyForAuthenticatedRequest(args [1]string, arg // // GET /user/keys/{key_id} func (s *Server) handleUsersGetPublicSSHKeyForAuthenticatedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/get-public-ssh-key-for-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90589,7 +111931,16 @@ func (s *Server) handleUsersGetPublicSSHKeyForAuthenticatedRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90601,8 +111952,27 @@ func (s *Server) handleUsersGetPublicSSHKeyForAuthenticatedRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90684,6 +112054,8 @@ func (s *Server) handleUsersGetPublicSSHKeyForAuthenticatedRequest(args [1]strin // // GET /users func (s *Server) handleUsersListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90705,7 +112077,16 @@ func (s *Server) handleUsersListRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90717,8 +112098,27 @@ func (s *Server) handleUsersListRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90800,6 +112200,8 @@ func (s *Server) handleUsersListRequest(args [0]string, argsEscaped bool, w http // // GET /user/blocks func (s *Server) handleUsersListBlockedByAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-blocked-by-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90821,7 +112223,16 @@ func (s *Server) handleUsersListBlockedByAuthenticatedRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90833,8 +112244,27 @@ func (s *Server) handleUsersListBlockedByAuthenticatedRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -90894,6 +112324,8 @@ func (s *Server) handleUsersListBlockedByAuthenticatedRequest(args [0]string, ar // // GET /user/emails func (s *Server) handleUsersListEmailsForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-emails-for-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -90915,7 +112347,16 @@ func (s *Server) handleUsersListEmailsForAuthenticatedRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90927,8 +112368,27 @@ func (s *Server) handleUsersListEmailsForAuthenticatedRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91010,6 +112470,8 @@ func (s *Server) handleUsersListEmailsForAuthenticatedRequest(args [0]string, ar // // GET /user/following func (s *Server) handleUsersListFollowedByAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-followed-by-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91031,7 +112493,16 @@ func (s *Server) handleUsersListFollowedByAuthenticatedRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91043,8 +112514,27 @@ func (s *Server) handleUsersListFollowedByAuthenticatedRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91126,6 +112616,8 @@ func (s *Server) handleUsersListFollowedByAuthenticatedRequest(args [0]string, a // // GET /user/followers func (s *Server) handleUsersListFollowersForAuthenticatedUserRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-followers-for-authenticated-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91147,7 +112639,16 @@ func (s *Server) handleUsersListFollowersForAuthenticatedUserRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91159,8 +112660,27 @@ func (s *Server) handleUsersListFollowersForAuthenticatedUserRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91242,6 +112762,8 @@ func (s *Server) handleUsersListFollowersForAuthenticatedUserRequest(args [0]str // // GET /users/{username}/followers func (s *Server) handleUsersListFollowersForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-followers-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91263,7 +112785,16 @@ func (s *Server) handleUsersListFollowersForUserRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91275,8 +112806,27 @@ func (s *Server) handleUsersListFollowersForUserRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91362,6 +112912,8 @@ func (s *Server) handleUsersListFollowersForUserRequest(args [1]string, argsEsca // // GET /users/{username}/following func (s *Server) handleUsersListFollowingForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-following-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91383,7 +112935,16 @@ func (s *Server) handleUsersListFollowingForUserRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91395,8 +112956,27 @@ func (s *Server) handleUsersListFollowingForUserRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91484,6 +113064,8 @@ func (s *Server) handleUsersListFollowingForUserRequest(args [1]string, argsEsca // // GET /user/gpg_keys func (s *Server) handleUsersListGpgKeysForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-gpg-keys-for-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91505,7 +113087,16 @@ func (s *Server) handleUsersListGpgKeysForAuthenticatedRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91517,8 +113108,27 @@ func (s *Server) handleUsersListGpgKeysForAuthenticatedRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91600,6 +113210,8 @@ func (s *Server) handleUsersListGpgKeysForAuthenticatedRequest(args [0]string, a // // GET /users/{username}/gpg_keys func (s *Server) handleUsersListGpgKeysForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-gpg-keys-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91621,7 +113233,16 @@ func (s *Server) handleUsersListGpgKeysForUserRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91633,8 +113254,27 @@ func (s *Server) handleUsersListGpgKeysForUserRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91723,6 +113363,8 @@ func (s *Server) handleUsersListGpgKeysForUserRequest(args [1]string, argsEscape // // GET /user/public_emails func (s *Server) handleUsersListPublicEmailsForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-public-emails-for-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91744,7 +113386,16 @@ func (s *Server) handleUsersListPublicEmailsForAuthenticatedRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91756,8 +113407,27 @@ func (s *Server) handleUsersListPublicEmailsForAuthenticatedRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91839,6 +113509,8 @@ func (s *Server) handleUsersListPublicEmailsForAuthenticatedRequest(args [0]stri // // GET /users/{username}/keys func (s *Server) handleUsersListPublicKeysForUserRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-public-keys-for-user"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91860,7 +113532,16 @@ func (s *Server) handleUsersListPublicKeysForUserRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91872,8 +113553,27 @@ func (s *Server) handleUsersListPublicKeysForUserRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91961,6 +113661,8 @@ func (s *Server) handleUsersListPublicKeysForUserRequest(args [1]string, argsEsc // // GET /user/keys func (s *Server) handleUsersListPublicSSHKeysForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/list-public-ssh-keys-for-authenticated"), semconv.HTTPRequestMethodKey.String("GET"), @@ -91982,7 +113684,16 @@ func (s *Server) handleUsersListPublicSSHKeysForAuthenticatedRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91994,8 +113705,27 @@ func (s *Server) handleUsersListPublicSSHKeysForAuthenticatedRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92077,6 +113807,8 @@ func (s *Server) handleUsersListPublicSSHKeysForAuthenticatedRequest(args [0]str // // PATCH /user/email/visibility func (s *Server) handleUsersSetPrimaryEmailVisibilityForAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/set-primary-email-visibility-for-authenticated"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -92098,7 +113830,16 @@ func (s *Server) handleUsersSetPrimaryEmailVisibilityForAuthenticatedRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92110,8 +113851,27 @@ func (s *Server) handleUsersSetPrimaryEmailVisibilityForAuthenticatedRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92189,6 +113949,8 @@ func (s *Server) handleUsersSetPrimaryEmailVisibilityForAuthenticatedRequest(arg // // DELETE /user/blocks/{username} func (s *Server) handleUsersUnblockRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/unblock"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -92210,7 +113972,16 @@ func (s *Server) handleUsersUnblockRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92222,8 +113993,27 @@ func (s *Server) handleUsersUnblockRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92302,6 +114092,8 @@ func (s *Server) handleUsersUnblockRequest(args [1]string, argsEscaped bool, w h // // DELETE /user/following/{username} func (s *Server) handleUsersUnfollowRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/unfollow"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -92323,7 +114115,16 @@ func (s *Server) handleUsersUnfollowRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92335,8 +114136,27 @@ func (s *Server) handleUsersUnfollowRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92416,6 +114236,8 @@ func (s *Server) handleUsersUnfollowRequest(args [1]string, argsEscaped bool, w // // PATCH /user func (s *Server) handleUsersUpdateAuthenticatedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("users/update-authenticated"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -92437,7 +114259,16 @@ func (s *Server) handleUsersUpdateAuthenticatedRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92449,8 +114280,27 @@ func (s *Server) handleUsersUpdateAuthenticatedRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_gotd/oas_handlers_gen.go b/examples/ex_gotd/oas_handlers_gen.go index 7904b20ab..e954b4c03 100644 --- a/examples/ex_gotd/oas_handlers_gen.go +++ b/examples/ex_gotd/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAddStickerToSetRequest handles addStickerToSet operation. // // POST /addStickerToSet func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("addStickerToSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45,7 +57,16 @@ func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -145,6 +185,8 @@ func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, // // POST /answerCallbackQuery func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerCallbackQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -166,7 +208,16 @@ func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -178,8 +229,27 @@ func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -266,6 +336,8 @@ func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bo // // POST /answerInlineQuery func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerInlineQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -287,7 +359,16 @@ func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -299,8 +380,27 @@ func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -387,6 +487,8 @@ func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool // // POST /answerPreCheckoutQuery func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerPreCheckoutQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -408,7 +510,16 @@ func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -420,8 +531,27 @@ func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -508,6 +638,8 @@ func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped // // POST /answerShippingQuery func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerShippingQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -529,7 +661,16 @@ func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -541,8 +682,27 @@ func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -629,6 +789,8 @@ func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bo // // POST /answerWebAppQuery func (s *Server) handleAnswerWebAppQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerWebAppQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -650,7 +812,16 @@ func (s *Server) handleAnswerWebAppQueryRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -662,8 +833,27 @@ func (s *Server) handleAnswerWebAppQueryRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -750,6 +940,8 @@ func (s *Server) handleAnswerWebAppQueryRequest(args [0]string, argsEscaped bool // // POST /approveChatJoinRequest func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("approveChatJoinRequest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -771,7 +963,16 @@ func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -783,8 +984,27 @@ func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -871,6 +1091,8 @@ func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped // // POST /banChatMember func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("banChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -892,7 +1114,16 @@ func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -904,8 +1135,27 @@ func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -992,6 +1242,8 @@ func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w // // POST /banChatSenderChat func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("banChatSenderChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1013,7 +1265,16 @@ func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1025,8 +1286,27 @@ func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1113,6 +1393,8 @@ func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool // // POST /close func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("close"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1134,7 +1416,16 @@ func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.Res startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1146,8 +1437,27 @@ func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.Res var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1215,6 +1525,8 @@ func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.Res // // POST /copyMessage func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("copyMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1236,7 +1548,16 @@ func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1248,8 +1569,27 @@ func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1336,6 +1676,8 @@ func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w ht // // POST /createChatInviteLink func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1357,7 +1699,16 @@ func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1369,8 +1720,27 @@ func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1457,6 +1827,8 @@ func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped b // // POST /createNewStickerSet func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createNewStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1478,7 +1850,16 @@ func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1490,8 +1871,27 @@ func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1578,6 +1978,8 @@ func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bo // // POST /declineChatJoinRequest func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("declineChatJoinRequest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1599,7 +2001,16 @@ func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1611,8 +2022,27 @@ func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1699,6 +2129,8 @@ func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped // // POST /deleteChatPhoto func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteChatPhoto"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1720,7 +2152,16 @@ func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1732,8 +2173,27 @@ func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1820,6 +2280,8 @@ func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, // // POST /deleteChatStickerSet func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteChatStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1841,7 +2303,16 @@ func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1853,8 +2324,27 @@ func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1941,6 +2431,8 @@ func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped b // // POST /deleteMessage func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1962,7 +2454,16 @@ func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1974,8 +2475,27 @@ func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2062,6 +2582,8 @@ func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w // // POST /deleteMyCommands func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteMyCommands"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2083,7 +2605,16 @@ func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2095,8 +2626,27 @@ func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2183,6 +2733,8 @@ func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, // // POST /deleteStickerFromSet func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteStickerFromSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2204,7 +2756,16 @@ func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2216,8 +2777,27 @@ func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2304,6 +2884,8 @@ func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped b // // POST /deleteWebhook func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteWebhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2325,7 +2907,16 @@ func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2337,8 +2928,27 @@ func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2425,6 +3035,8 @@ func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w // // POST /editChatInviteLink func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2446,7 +3058,16 @@ func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2458,8 +3079,27 @@ func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2546,6 +3186,8 @@ func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped boo // // POST /editMessageCaption func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageCaption"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2567,7 +3209,16 @@ func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2579,8 +3230,27 @@ func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2667,6 +3337,8 @@ func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped boo // // POST /editMessageLiveLocation func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageLiveLocation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2688,7 +3360,16 @@ func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2700,8 +3381,27 @@ func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2788,6 +3488,8 @@ func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscape // // POST /editMessageMedia func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageMedia"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2809,7 +3511,16 @@ func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2821,8 +3532,27 @@ func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2909,6 +3639,8 @@ func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, // // POST /editMessageReplyMarkup func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageReplyMarkup"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2930,7 +3662,16 @@ func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2942,8 +3683,27 @@ func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3030,6 +3790,8 @@ func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped // // POST /editMessageText func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageText"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3051,7 +3813,16 @@ func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3063,8 +3834,27 @@ func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3151,6 +3941,8 @@ func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, // // POST /exportChatInviteLink func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("exportChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3172,7 +3964,16 @@ func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3184,8 +3985,27 @@ func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3272,6 +4092,8 @@ func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped b // // POST /forwardMessage func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("forwardMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3293,7 +4115,16 @@ func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3305,8 +4136,27 @@ func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3393,6 +4243,8 @@ func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w // // POST /getChat func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3414,7 +4266,16 @@ func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3426,8 +4287,27 @@ func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3514,6 +4394,8 @@ func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.R // // POST /getChatAdministrators func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatAdministrators"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3535,7 +4417,16 @@ func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3547,8 +4438,27 @@ func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3635,6 +4545,8 @@ func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped // // POST /getChatMember func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3656,7 +4568,16 @@ func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3668,8 +4589,27 @@ func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3756,6 +4696,8 @@ func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w // // POST /getChatMemberCount func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatMemberCount"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3777,7 +4719,16 @@ func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3789,8 +4740,27 @@ func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3877,6 +4847,8 @@ func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped boo // // POST /getChatMenuButton func (s *Server) handleGetChatMenuButtonRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatMenuButton"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3898,7 +4870,16 @@ func (s *Server) handleGetChatMenuButtonRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3910,8 +4891,27 @@ func (s *Server) handleGetChatMenuButtonRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3998,6 +4998,8 @@ func (s *Server) handleGetChatMenuButtonRequest(args [0]string, argsEscaped bool // // POST /getFile func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getFile"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4019,7 +5021,16 @@ func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4031,8 +5042,27 @@ func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4119,6 +5149,8 @@ func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.R // // POST /getGameHighScores func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getGameHighScores"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4140,7 +5172,16 @@ func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4152,8 +5193,27 @@ func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4240,6 +5300,8 @@ func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool // // POST /getMe func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getMe"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4261,7 +5323,16 @@ func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.Res startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4273,8 +5344,27 @@ func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.Res var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -4342,6 +5432,8 @@ func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.Res // // POST /getMyCommands func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getMyCommands"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4363,7 +5455,16 @@ func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4375,8 +5476,27 @@ func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4463,6 +5583,8 @@ func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w // // POST /getMyDefaultAdministratorRights func (s *Server) handleGetMyDefaultAdministratorRightsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getMyDefaultAdministratorRights"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4484,7 +5606,16 @@ func (s *Server) handleGetMyDefaultAdministratorRightsRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4496,8 +5627,27 @@ func (s *Server) handleGetMyDefaultAdministratorRightsRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4584,6 +5734,8 @@ func (s *Server) handleGetMyDefaultAdministratorRightsRequest(args [0]string, ar // // POST /getStickerSet func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4605,7 +5757,16 @@ func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4617,8 +5778,27 @@ func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4705,6 +5885,8 @@ func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w // // POST /getUpdates func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getUpdates"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4726,7 +5908,16 @@ func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4738,8 +5929,27 @@ func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4826,6 +6036,8 @@ func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w htt // // POST /getUserProfilePhotos func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getUserProfilePhotos"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4847,7 +6059,16 @@ func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4859,8 +6080,27 @@ func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4947,6 +6187,8 @@ func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped b // // POST /getWebhookInfo func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getWebhookInfo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4968,7 +6210,16 @@ func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4980,8 +6231,27 @@ func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -5049,6 +6319,8 @@ func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w // // POST /leaveChat func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("leaveChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5070,7 +6342,16 @@ func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5082,8 +6363,27 @@ func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5170,6 +6470,8 @@ func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http // // POST /logOut func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("logOut"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5191,7 +6493,16 @@ func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5203,8 +6514,27 @@ func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -5272,6 +6602,8 @@ func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.Re // // POST /pinChatMessage func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pinChatMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5293,7 +6625,16 @@ func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5305,8 +6646,27 @@ func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5393,6 +6753,8 @@ func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w // // POST /promoteChatMember func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("promoteChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5414,7 +6776,16 @@ func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5426,8 +6797,27 @@ func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5514,6 +6904,8 @@ func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool // // POST /restrictChatMember func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("restrictChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5535,7 +6927,16 @@ func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5547,8 +6948,27 @@ func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5635,6 +7055,8 @@ func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped boo // // POST /revokeChatInviteLink func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("revokeChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5656,7 +7078,16 @@ func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5668,8 +7099,27 @@ func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5756,6 +7206,8 @@ func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped b // // POST /sendAnimation func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendAnimation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5777,7 +7229,16 @@ func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5789,8 +7250,27 @@ func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5877,6 +7357,8 @@ func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w // // POST /sendAudio func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendAudio"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5898,7 +7380,16 @@ func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5910,8 +7401,27 @@ func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5998,6 +7508,8 @@ func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http // // POST /sendChatAction func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendChatAction"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6019,7 +7531,16 @@ func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6031,8 +7552,27 @@ func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6119,6 +7659,8 @@ func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w // // POST /sendContact func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendContact"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6140,7 +7682,16 @@ func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6152,8 +7703,27 @@ func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6240,6 +7810,8 @@ func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w ht // // POST /sendDice func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendDice"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6261,7 +7833,16 @@ func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6273,8 +7854,27 @@ func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6361,6 +7961,8 @@ func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http. // // POST /sendDocument func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendDocument"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6382,7 +7984,16 @@ func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6394,8 +8005,27 @@ func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6482,6 +8112,8 @@ func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w h // // POST /sendGame func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendGame"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6503,7 +8135,16 @@ func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6515,8 +8156,27 @@ func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6603,6 +8263,8 @@ func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http. // // POST /sendInvoice func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendInvoice"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6624,7 +8286,16 @@ func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6636,8 +8307,27 @@ func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6724,6 +8414,8 @@ func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w ht // // POST /sendLocation func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendLocation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6745,7 +8437,16 @@ func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6757,8 +8458,27 @@ func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6845,6 +8565,8 @@ func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w h // // POST /sendMediaGroup func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendMediaGroup"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6866,7 +8588,16 @@ func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6878,8 +8609,27 @@ func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6966,6 +8716,8 @@ func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w // // POST /sendMessage func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6987,7 +8739,16 @@ func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6999,8 +8760,27 @@ func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7087,6 +8867,8 @@ func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w ht // // POST /sendPhoto func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendPhoto"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7108,7 +8890,16 @@ func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7120,8 +8911,27 @@ func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7208,6 +9018,8 @@ func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http // // POST /sendPoll func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendPoll"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7229,7 +9041,16 @@ func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7241,8 +9062,27 @@ func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7329,6 +9169,8 @@ func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http. // // POST /sendSticker func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendSticker"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7350,7 +9192,16 @@ func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7362,8 +9213,27 @@ func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7450,6 +9320,8 @@ func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w ht // // POST /sendVenue func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVenue"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7471,7 +9343,16 @@ func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7483,8 +9364,27 @@ func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7571,6 +9471,8 @@ func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http // // POST /sendVideo func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVideo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7592,7 +9494,16 @@ func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7604,8 +9515,27 @@ func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7692,6 +9622,8 @@ func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http // // POST /sendVideoNote func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVideoNote"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7713,7 +9645,16 @@ func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7725,8 +9666,27 @@ func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7813,6 +9773,8 @@ func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w // // POST /sendVoice func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVoice"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7834,7 +9796,16 @@ func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7846,8 +9817,27 @@ func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7934,6 +9924,8 @@ func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http // // POST /setChatAdministratorCustomTitle func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatAdministratorCustomTitle"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7955,7 +9947,16 @@ func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7967,8 +9968,27 @@ func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8055,6 +10075,8 @@ func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, ar // // POST /setChatDescription func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatDescription"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8076,7 +10098,16 @@ func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8088,8 +10119,27 @@ func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8176,6 +10226,8 @@ func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped boo // // POST /setChatMenuButton func (s *Server) handleSetChatMenuButtonRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatMenuButton"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8197,7 +10249,16 @@ func (s *Server) handleSetChatMenuButtonRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8209,8 +10270,27 @@ func (s *Server) handleSetChatMenuButtonRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8297,6 +10377,8 @@ func (s *Server) handleSetChatMenuButtonRequest(args [0]string, argsEscaped bool // // POST /setChatPermissions func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatPermissions"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8318,7 +10400,16 @@ func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8330,8 +10421,27 @@ func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8418,6 +10528,8 @@ func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped boo // // POST /setChatPhoto func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatPhoto"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8439,7 +10551,16 @@ func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8451,8 +10572,27 @@ func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8539,6 +10679,8 @@ func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w h // // POST /setChatStickerSet func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8560,7 +10702,16 @@ func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8572,8 +10723,27 @@ func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8660,6 +10830,8 @@ func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool // // POST /setChatTitle func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatTitle"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8681,7 +10853,16 @@ func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8693,8 +10874,27 @@ func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8781,6 +10981,8 @@ func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w h // // POST /setGameScore func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setGameScore"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8802,7 +11004,16 @@ func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8814,8 +11025,27 @@ func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8902,6 +11132,8 @@ func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w h // // POST /setMyCommands func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setMyCommands"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8923,7 +11155,16 @@ func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8935,8 +11176,27 @@ func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9023,6 +11283,8 @@ func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w // // POST /setMyDefaultAdministratorRights func (s *Server) handleSetMyDefaultAdministratorRightsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setMyDefaultAdministratorRights"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9044,7 +11306,16 @@ func (s *Server) handleSetMyDefaultAdministratorRightsRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9056,8 +11327,27 @@ func (s *Server) handleSetMyDefaultAdministratorRightsRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9144,6 +11434,8 @@ func (s *Server) handleSetMyDefaultAdministratorRightsRequest(args [0]string, ar // // POST /setPassportDataErrors func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setPassportDataErrors"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9165,7 +11457,16 @@ func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9177,8 +11478,27 @@ func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9265,6 +11585,8 @@ func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped // // POST /setStickerPositionInSet func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setStickerPositionInSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9286,7 +11608,16 @@ func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9298,8 +11629,27 @@ func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9386,6 +11736,8 @@ func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscape // // POST /setStickerSetThumb func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setStickerSetThumb"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9407,7 +11759,16 @@ func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9419,8 +11780,27 @@ func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9507,6 +11887,8 @@ func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped boo // // POST /setWebhook func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setWebhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9528,7 +11910,16 @@ func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9540,8 +11931,27 @@ func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9628,6 +12038,8 @@ func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w htt // // POST /stopMessageLiveLocation func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("stopMessageLiveLocation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9649,7 +12061,16 @@ func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9661,8 +12082,27 @@ func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9749,6 +12189,8 @@ func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscape // // POST /stopPoll func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("stopPoll"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9770,7 +12212,16 @@ func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9782,8 +12233,27 @@ func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9870,6 +12340,8 @@ func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http. // // POST /unbanChatMember func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unbanChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9891,7 +12363,16 @@ func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9903,8 +12384,27 @@ func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9991,6 +12491,8 @@ func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, // // POST /unbanChatSenderChat func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unbanChatSenderChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10012,7 +12514,16 @@ func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10024,8 +12535,27 @@ func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10112,6 +12642,8 @@ func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bo // // POST /unpinAllChatMessages func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unpinAllChatMessages"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10133,7 +12665,16 @@ func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10145,8 +12686,27 @@ func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10233,6 +12793,8 @@ func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped b // // POST /unpinChatMessage func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unpinChatMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10254,7 +12816,16 @@ func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10266,8 +12837,27 @@ func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10354,6 +12944,8 @@ func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, // // POST /uploadStickerFile func (s *Server) handleUploadStickerFileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("uploadStickerFile"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10375,7 +12967,16 @@ func (s *Server) handleUploadStickerFileRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10387,8 +12988,27 @@ func (s *Server) handleUploadStickerFileRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_k8s/oas_handlers_gen.go b/examples/ex_k8s/oas_handlers_gen.go index 1b07689a7..15c59f636 100644 --- a/examples/ex_k8s/oas_handlers_gen.go +++ b/examples/ex_k8s/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleConnectCoreV1DeleteNamespacedPodProxyRequest handles connectCoreV1DeleteNamespacedPodProxy operation. // // Connect DELETE requests to proxy of Pod. // // DELETE /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1DeleteNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -47,7 +59,16 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -190,6 +230,8 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyRequest(args [2]stri // // DELETE /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1DeleteNamespacedPodProxyWithPath"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -211,7 +253,16 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyWithPathRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -223,8 +274,27 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyWithPathRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -358,6 +428,8 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedPodProxyWithPathRequest(args // // DELETE /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1DeleteNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -379,7 +451,16 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -391,8 +472,27 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -522,6 +622,8 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyRequest(args [2] // // DELETE /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1DeleteNamespacedServiceProxyWithPath"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -543,7 +645,16 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyWithPathRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -555,8 +666,27 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyWithPathRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -690,6 +820,8 @@ func (s *Server) handleConnectCoreV1DeleteNamespacedServiceProxyWithPathRequest( // // DELETE /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1DeleteNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1DeleteNodeProxy"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -711,7 +843,16 @@ func (s *Server) handleConnectCoreV1DeleteNodeProxyRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -723,8 +864,27 @@ func (s *Server) handleConnectCoreV1DeleteNodeProxyRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -850,6 +1010,8 @@ func (s *Server) handleConnectCoreV1DeleteNodeProxyRequest(args [1]string, argsE // // DELETE /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1DeleteNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1DeleteNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -871,7 +1033,16 @@ func (s *Server) handleConnectCoreV1DeleteNodeProxyWithPathRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -883,8 +1054,27 @@ func (s *Server) handleConnectCoreV1DeleteNodeProxyWithPathRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1014,6 +1204,8 @@ func (s *Server) handleConnectCoreV1DeleteNodeProxyWithPathRequest(args [2]strin // // GET /api/v1/namespaces/{namespace}/pods/{name}/attach func (s *Server) handleConnectCoreV1GetNamespacedPodAttachRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNamespacedPodAttach"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1035,7 +1227,16 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodAttachRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1047,8 +1248,27 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodAttachRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1194,6 +1414,8 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodAttachRequest(args [2]string // // GET /api/v1/namespaces/{namespace}/pods/{name}/exec func (s *Server) handleConnectCoreV1GetNamespacedPodExecRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNamespacedPodExec"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1215,7 +1437,16 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodExecRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1227,8 +1458,27 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodExecRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1378,6 +1628,8 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodExecRequest(args [2]string, // // GET /api/v1/namespaces/{namespace}/pods/{name}/portforward func (s *Server) handleConnectCoreV1GetNamespacedPodPortforwardRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNamespacedPodPortforward"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1399,7 +1651,16 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodPortforwardRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1411,8 +1672,27 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodPortforwardRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1542,6 +1822,8 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodPortforwardRequest(args [2]s // // GET /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1GetNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1563,7 +1845,16 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodProxyRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1575,8 +1866,27 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodProxyRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1706,6 +2016,8 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodProxyRequest(args [2]string, // // GET /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} func (s *Server) handleConnectCoreV1GetNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNamespacedPodProxyWithPath"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1727,7 +2039,16 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodProxyWithPathRequest(args [3 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1739,8 +2060,27 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodProxyWithPathRequest(args [3 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1874,6 +2214,8 @@ func (s *Server) handleConnectCoreV1GetNamespacedPodProxyWithPathRequest(args [3 // // GET /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1GetNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1895,7 +2237,16 @@ func (s *Server) handleConnectCoreV1GetNamespacedServiceProxyRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1907,184 +2258,233 @@ func (s *Server) handleConnectCoreV1GetNamespacedServiceProxyRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ConnectCoreV1GetNamespacedServiceProxyOperation, - ID: "connectCoreV1GetNamespacedServiceProxy", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1GetNamespacedServiceProxyOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeConnectCoreV1GetNamespacedServiceProxyParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response ConnectCoreV1GetNamespacedServiceProxyRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ConnectCoreV1GetNamespacedServiceProxyOperation, - OperationSummary: "", - OperationID: "connectCoreV1GetNamespacedServiceProxy", - Body: nil, - Params: middleware.Parameters{ - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "path", - In: "query", - }: params.Path, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ConnectCoreV1GetNamespacedServiceProxyParams - Response = ConnectCoreV1GetNamespacedServiceProxyRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackConnectCoreV1GetNamespacedServiceProxyParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ConnectCoreV1GetNamespacedServiceProxy(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ConnectCoreV1GetNamespacedServiceProxy(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeConnectCoreV1GetNamespacedServiceProxyResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleConnectCoreV1GetNamespacedServiceProxyWithPathRequest handles connectCoreV1GetNamespacedServiceProxyWithPath operation. -// -// Connect GET requests to proxy of Service. -// -// GET /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} -func (s *Server) handleConnectCoreV1GetNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("connectCoreV1GetNamespacedServiceProxyWithPath"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/services/{name}/proxy/{path}"), - } - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ConnectCoreV1GetNamespacedServiceProxyWithPathOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ConnectCoreV1GetNamespacedServiceProxyWithPathOperation, - ID: "connectCoreV1GetNamespacedServiceProxyWithPath", + Name: ConnectCoreV1GetNamespacedServiceProxyOperation, + ID: "connectCoreV1GetNamespacedServiceProxy", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1GetNamespacedServiceProxyWithPathOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1GetNamespacedServiceProxyOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeConnectCoreV1GetNamespacedServiceProxyParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ConnectCoreV1GetNamespacedServiceProxyRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ConnectCoreV1GetNamespacedServiceProxyOperation, + OperationSummary: "", + OperationID: "connectCoreV1GetNamespacedServiceProxy", + Body: nil, + Params: middleware.Parameters{ + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "path", + In: "query", + }: params.Path, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ConnectCoreV1GetNamespacedServiceProxyParams + Response = ConnectCoreV1GetNamespacedServiceProxyRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackConnectCoreV1GetNamespacedServiceProxyParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ConnectCoreV1GetNamespacedServiceProxy(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ConnectCoreV1GetNamespacedServiceProxy(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeConnectCoreV1GetNamespacedServiceProxyResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleConnectCoreV1GetNamespacedServiceProxyWithPathRequest handles connectCoreV1GetNamespacedServiceProxyWithPath operation. +// +// Connect GET requests to proxy of Service. +// +// GET /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} +func (s *Server) handleConnectCoreV1GetNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("connectCoreV1GetNamespacedServiceProxyWithPath"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/services/{name}/proxy/{path}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ConnectCoreV1GetNamespacedServiceProxyWithPathOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ConnectCoreV1GetNamespacedServiceProxyWithPathOperation, + ID: "connectCoreV1GetNamespacedServiceProxyWithPath", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1GetNamespacedServiceProxyWithPathOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -2206,6 +2606,8 @@ func (s *Server) handleConnectCoreV1GetNamespacedServiceProxyWithPathRequest(arg // // GET /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1GetNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNodeProxy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2227,7 +2629,16 @@ func (s *Server) handleConnectCoreV1GetNodeProxyRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2239,8 +2650,27 @@ func (s *Server) handleConnectCoreV1GetNodeProxyRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2366,6 +2796,8 @@ func (s *Server) handleConnectCoreV1GetNodeProxyRequest(args [1]string, argsEsca // // GET /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1GetNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1GetNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2387,7 +2819,16 @@ func (s *Server) handleConnectCoreV1GetNodeProxyWithPathRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2399,8 +2840,27 @@ func (s *Server) handleConnectCoreV1GetNodeProxyWithPathRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2530,6 +2990,8 @@ func (s *Server) handleConnectCoreV1GetNodeProxyWithPathRequest(args [2]string, // // HEAD /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1HeadNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("HEAD"), @@ -2551,7 +3013,16 @@ func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2563,8 +3034,27 @@ func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2694,6 +3184,8 @@ func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyRequest(args [2]string // // HEAD /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1HeadNamespacedPodProxyWithPath"), semconv.HTTPRequestMethodKey.String("HEAD"), @@ -2715,7 +3207,16 @@ func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyWithPathRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2727,8 +3228,27 @@ func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyWithPathRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2862,6 +3382,8 @@ func (s *Server) handleConnectCoreV1HeadNamespacedPodProxyWithPathRequest(args [ // // HEAD /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1HeadNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("HEAD"), @@ -2883,7 +3405,16 @@ func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2895,8 +3426,27 @@ func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3026,6 +3576,8 @@ func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyRequest(args [2]st // // HEAD /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1HeadNamespacedServiceProxyWithPath"), semconv.HTTPRequestMethodKey.String("HEAD"), @@ -3047,7 +3599,16 @@ func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyWithPathRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3059,8 +3620,27 @@ func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyWithPathRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3194,6 +3774,8 @@ func (s *Server) handleConnectCoreV1HeadNamespacedServiceProxyWithPathRequest(ar // // HEAD /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1HeadNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1HeadNodeProxy"), semconv.HTTPRequestMethodKey.String("HEAD"), @@ -3215,7 +3797,16 @@ func (s *Server) handleConnectCoreV1HeadNodeProxyRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3227,8 +3818,27 @@ func (s *Server) handleConnectCoreV1HeadNodeProxyRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3354,6 +3964,8 @@ func (s *Server) handleConnectCoreV1HeadNodeProxyRequest(args [1]string, argsEsc // // HEAD /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1HeadNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1HeadNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("HEAD"), @@ -3375,7 +3987,16 @@ func (s *Server) handleConnectCoreV1HeadNodeProxyWithPathRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3387,8 +4008,27 @@ func (s *Server) handleConnectCoreV1HeadNodeProxyWithPathRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3518,6 +4158,8 @@ func (s *Server) handleConnectCoreV1HeadNodeProxyWithPathRequest(args [2]string, // // OPTIONS /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1OptionsNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("OPTIONS"), @@ -3539,7 +4181,16 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3551,8 +4202,27 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3682,6 +4352,8 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyRequest(args [2]str // // OPTIONS /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1OptionsNamespacedPodProxyWithPath"), semconv.HTTPRequestMethodKey.String("OPTIONS"), @@ -3703,7 +4375,16 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyWithPathRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3715,8 +4396,27 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyWithPathRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3850,6 +4550,8 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedPodProxyWithPathRequest(arg // // OPTIONS /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1OptionsNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("OPTIONS"), @@ -3871,7 +4573,16 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyRequest(args [2 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3883,8 +4594,27 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyRequest(args [2 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4014,6 +4744,8 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyRequest(args [2 // // OPTIONS /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1OptionsNamespacedServiceProxyWithPath"), semconv.HTTPRequestMethodKey.String("OPTIONS"), @@ -4035,7 +4767,16 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyWithPathRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4047,8 +4788,27 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyWithPathRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4182,6 +4942,8 @@ func (s *Server) handleConnectCoreV1OptionsNamespacedServiceProxyWithPathRequest // // OPTIONS /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1OptionsNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1OptionsNodeProxy"), semconv.HTTPRequestMethodKey.String("OPTIONS"), @@ -4203,7 +4965,16 @@ func (s *Server) handleConnectCoreV1OptionsNodeProxyRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4215,8 +4986,27 @@ func (s *Server) handleConnectCoreV1OptionsNodeProxyRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4342,6 +5132,8 @@ func (s *Server) handleConnectCoreV1OptionsNodeProxyRequest(args [1]string, args // // OPTIONS /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1OptionsNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1OptionsNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("OPTIONS"), @@ -4363,7 +5155,16 @@ func (s *Server) handleConnectCoreV1OptionsNodeProxyWithPathRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4375,8 +5176,27 @@ func (s *Server) handleConnectCoreV1OptionsNodeProxyWithPathRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4506,6 +5326,8 @@ func (s *Server) handleConnectCoreV1OptionsNodeProxyWithPathRequest(args [2]stri // // PATCH /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PatchNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -4527,7 +5349,16 @@ func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4539,8 +5370,27 @@ func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4670,6 +5520,8 @@ func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyRequest(args [2]strin // // PATCH /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PatchNamespacedPodProxyWithPath"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -4691,7 +5543,16 @@ func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyWithPathRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4703,8 +5564,27 @@ func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyWithPathRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4838,6 +5718,8 @@ func (s *Server) handleConnectCoreV1PatchNamespacedPodProxyWithPathRequest(args // // PATCH /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PatchNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -4859,7 +5741,16 @@ func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4871,8 +5762,27 @@ func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5002,6 +5912,8 @@ func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyRequest(args [2]s // // PATCH /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PatchNamespacedServiceProxyWithPath"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -5023,7 +5935,16 @@ func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyWithPathRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5035,8 +5956,27 @@ func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyWithPathRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5170,6 +6110,8 @@ func (s *Server) handleConnectCoreV1PatchNamespacedServiceProxyWithPathRequest(a // // PATCH /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1PatchNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PatchNodeProxy"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -5191,7 +6133,16 @@ func (s *Server) handleConnectCoreV1PatchNodeProxyRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5203,8 +6154,27 @@ func (s *Server) handleConnectCoreV1PatchNodeProxyRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5330,6 +6300,8 @@ func (s *Server) handleConnectCoreV1PatchNodeProxyRequest(args [1]string, argsEs // // PATCH /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PatchNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PatchNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("PATCH"), @@ -5351,7 +6323,16 @@ func (s *Server) handleConnectCoreV1PatchNodeProxyWithPathRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5363,8 +6344,27 @@ func (s *Server) handleConnectCoreV1PatchNodeProxyWithPathRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5494,6 +6494,8 @@ func (s *Server) handleConnectCoreV1PatchNodeProxyWithPathRequest(args [2]string // // POST /api/v1/namespaces/{namespace}/pods/{name}/attach func (s *Server) handleConnectCoreV1PostNamespacedPodAttachRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNamespacedPodAttach"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5515,7 +6517,16 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodAttachRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5527,8 +6538,27 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodAttachRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5674,6 +6704,8 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodAttachRequest(args [2]strin // // POST /api/v1/namespaces/{namespace}/pods/{name}/exec func (s *Server) handleConnectCoreV1PostNamespacedPodExecRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNamespacedPodExec"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5695,7 +6727,16 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodExecRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5707,8 +6748,27 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodExecRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5858,6 +6918,8 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodExecRequest(args [2]string, // // POST /api/v1/namespaces/{namespace}/pods/{name}/portforward func (s *Server) handleConnectCoreV1PostNamespacedPodPortforwardRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNamespacedPodPortforward"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5879,7 +6941,16 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodPortforwardRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5891,8 +6962,27 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodPortforwardRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6022,6 +7112,8 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodPortforwardRequest(args [2] // // POST /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1PostNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6043,7 +7135,16 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodProxyRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6055,184 +7156,233 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodProxyRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ConnectCoreV1PostNamespacedPodProxyOperation, - ID: "connectCoreV1PostNamespacedPodProxy", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1PostNamespacedPodProxyOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeConnectCoreV1PostNamespacedPodProxyParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response ConnectCoreV1PostNamespacedPodProxyRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ConnectCoreV1PostNamespacedPodProxyOperation, - OperationSummary: "", - OperationID: "connectCoreV1PostNamespacedPodProxy", - Body: nil, - Params: middleware.Parameters{ - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "path", - In: "query", - }: params.Path, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ConnectCoreV1PostNamespacedPodProxyParams - Response = ConnectCoreV1PostNamespacedPodProxyRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackConnectCoreV1PostNamespacedPodProxyParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ConnectCoreV1PostNamespacedPodProxy(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ConnectCoreV1PostNamespacedPodProxy(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeConnectCoreV1PostNamespacedPodProxyResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleConnectCoreV1PostNamespacedPodProxyWithPathRequest handles connectCoreV1PostNamespacedPodProxyWithPath operation. -// -// Connect POST requests to proxy of Pod. -// -// POST /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} -func (s *Server) handleConnectCoreV1PostNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("connectCoreV1PostNamespacedPodProxyWithPath"), - semconv.HTTPRequestMethodKey.String("POST"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}"), - } - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ConnectCoreV1PostNamespacedPodProxyWithPathOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ConnectCoreV1PostNamespacedPodProxyWithPathOperation, - ID: "connectCoreV1PostNamespacedPodProxyWithPath", + Name: ConnectCoreV1PostNamespacedPodProxyOperation, + ID: "connectCoreV1PostNamespacedPodProxy", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1PostNamespacedPodProxyWithPathOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1PostNamespacedPodProxyOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeConnectCoreV1PostNamespacedPodProxyParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ConnectCoreV1PostNamespacedPodProxyRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ConnectCoreV1PostNamespacedPodProxyOperation, + OperationSummary: "", + OperationID: "connectCoreV1PostNamespacedPodProxy", + Body: nil, + Params: middleware.Parameters{ + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "path", + In: "query", + }: params.Path, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ConnectCoreV1PostNamespacedPodProxyParams + Response = ConnectCoreV1PostNamespacedPodProxyRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackConnectCoreV1PostNamespacedPodProxyParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ConnectCoreV1PostNamespacedPodProxy(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ConnectCoreV1PostNamespacedPodProxy(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeConnectCoreV1PostNamespacedPodProxyResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleConnectCoreV1PostNamespacedPodProxyWithPathRequest handles connectCoreV1PostNamespacedPodProxyWithPath operation. +// +// Connect POST requests to proxy of Pod. +// +// POST /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} +func (s *Server) handleConnectCoreV1PostNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("connectCoreV1PostNamespacedPodProxyWithPath"), + semconv.HTTPRequestMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ConnectCoreV1PostNamespacedPodProxyWithPathOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ConnectCoreV1PostNamespacedPodProxyWithPathOperation, + ID: "connectCoreV1PostNamespacedPodProxyWithPath", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ConnectCoreV1PostNamespacedPodProxyWithPathOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -6354,6 +7504,8 @@ func (s *Server) handleConnectCoreV1PostNamespacedPodProxyWithPathRequest(args [ // // POST /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6375,7 +7527,16 @@ func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6387,8 +7548,27 @@ func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6518,6 +7698,8 @@ func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyRequest(args [2]st // // POST /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNamespacedServiceProxyWithPath"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6539,7 +7721,16 @@ func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyWithPathRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6551,8 +7742,27 @@ func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyWithPathRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6686,6 +7896,8 @@ func (s *Server) handleConnectCoreV1PostNamespacedServiceProxyWithPathRequest(ar // // POST /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1PostNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNodeProxy"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6707,7 +7919,16 @@ func (s *Server) handleConnectCoreV1PostNodeProxyRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6719,8 +7940,27 @@ func (s *Server) handleConnectCoreV1PostNodeProxyRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6846,6 +8086,8 @@ func (s *Server) handleConnectCoreV1PostNodeProxyRequest(args [1]string, argsEsc // // POST /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PostNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PostNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6867,7 +8109,16 @@ func (s *Server) handleConnectCoreV1PostNodeProxyWithPathRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6879,8 +8130,27 @@ func (s *Server) handleConnectCoreV1PostNodeProxyWithPathRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7010,6 +8280,8 @@ func (s *Server) handleConnectCoreV1PostNodeProxyWithPathRequest(args [2]string, // // PUT /api/v1/namespaces/{namespace}/pods/{name}/proxy func (s *Server) handleConnectCoreV1PutNamespacedPodProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PutNamespacedPodProxy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -7031,7 +8303,16 @@ func (s *Server) handleConnectCoreV1PutNamespacedPodProxyRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7043,8 +8324,27 @@ func (s *Server) handleConnectCoreV1PutNamespacedPodProxyRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7174,6 +8474,8 @@ func (s *Server) handleConnectCoreV1PutNamespacedPodProxyRequest(args [2]string, // // PUT /api/v1/namespaces/{namespace}/pods/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PutNamespacedPodProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PutNamespacedPodProxyWithPath"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -7195,7 +8497,16 @@ func (s *Server) handleConnectCoreV1PutNamespacedPodProxyWithPathRequest(args [3 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7207,8 +8518,27 @@ func (s *Server) handleConnectCoreV1PutNamespacedPodProxyWithPathRequest(args [3 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7342,6 +8672,8 @@ func (s *Server) handleConnectCoreV1PutNamespacedPodProxyWithPathRequest(args [3 // // PUT /api/v1/namespaces/{namespace}/services/{name}/proxy func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PutNamespacedServiceProxy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -7363,7 +8695,16 @@ func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7375,8 +8716,27 @@ func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7506,6 +8866,8 @@ func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyRequest(args [2]str // // PUT /api/v1/namespaces/{namespace}/services/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyWithPathRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PutNamespacedServiceProxyWithPath"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -7527,7 +8889,16 @@ func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyWithPathRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7539,8 +8910,27 @@ func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyWithPathRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7674,6 +9064,8 @@ func (s *Server) handleConnectCoreV1PutNamespacedServiceProxyWithPathRequest(arg // // PUT /api/v1/nodes/{name}/proxy func (s *Server) handleConnectCoreV1PutNodeProxyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PutNodeProxy"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -7695,7 +9087,16 @@ func (s *Server) handleConnectCoreV1PutNodeProxyRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7707,8 +9108,27 @@ func (s *Server) handleConnectCoreV1PutNodeProxyRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7834,6 +9254,8 @@ func (s *Server) handleConnectCoreV1PutNodeProxyRequest(args [1]string, argsEsca // // PUT /api/v1/nodes/{name}/proxy/{path} func (s *Server) handleConnectCoreV1PutNodeProxyWithPathRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("connectCoreV1PutNodeProxyWithPath"), semconv.HTTPRequestMethodKey.String("PUT"), @@ -7855,7 +9277,16 @@ func (s *Server) handleConnectCoreV1PutNodeProxyWithPathRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7867,8 +9298,27 @@ func (s *Server) handleConnectCoreV1PutNodeProxyWithPathRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7998,6 +9448,8 @@ func (s *Server) handleConnectCoreV1PutNodeProxyWithPathRequest(args [2]string, // // GET /apis/ func (s *Server) handleGetAPIVersionsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAPIVersions"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8019,7 +9471,16 @@ func (s *Server) handleGetAPIVersionsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8031,8 +9492,27 @@ func (s *Server) handleGetAPIVersionsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8139,6 +9619,8 @@ func (s *Server) handleGetAPIVersionsRequest(args [0]string, argsEscaped bool, w // // GET /apis/admissionregistration.k8s.io/ func (s *Server) handleGetAdmissionregistrationAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAdmissionregistrationAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8160,7 +9642,16 @@ func (s *Server) handleGetAdmissionregistrationAPIGroupRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8172,8 +9663,27 @@ func (s *Server) handleGetAdmissionregistrationAPIGroupRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8280,6 +9790,8 @@ func (s *Server) handleGetAdmissionregistrationAPIGroupRequest(args [0]string, a // // GET /apis/admissionregistration.k8s.io/v1/ func (s *Server) handleGetAdmissionregistrationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAdmissionregistrationV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8301,7 +9813,16 @@ func (s *Server) handleGetAdmissionregistrationV1APIResourcesRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8313,8 +9834,27 @@ func (s *Server) handleGetAdmissionregistrationV1APIResourcesRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8421,6 +9961,8 @@ func (s *Server) handleGetAdmissionregistrationV1APIResourcesRequest(args [0]str // // GET /apis/apiextensions.k8s.io/ func (s *Server) handleGetApiextensionsAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getApiextensionsAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8442,7 +9984,16 @@ func (s *Server) handleGetApiextensionsAPIGroupRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8454,8 +10005,27 @@ func (s *Server) handleGetApiextensionsAPIGroupRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8562,6 +10132,8 @@ func (s *Server) handleGetApiextensionsAPIGroupRequest(args [0]string, argsEscap // // GET /apis/apiextensions.k8s.io/v1/ func (s *Server) handleGetApiextensionsV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getApiextensionsV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8583,7 +10155,16 @@ func (s *Server) handleGetApiextensionsV1APIResourcesRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8595,8 +10176,27 @@ func (s *Server) handleGetApiextensionsV1APIResourcesRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8703,6 +10303,8 @@ func (s *Server) handleGetApiextensionsV1APIResourcesRequest(args [0]string, arg // // GET /apis/apiregistration.k8s.io/ func (s *Server) handleGetApiregistrationAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getApiregistrationAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8724,7 +10326,16 @@ func (s *Server) handleGetApiregistrationAPIGroupRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8736,8 +10347,27 @@ func (s *Server) handleGetApiregistrationAPIGroupRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8844,6 +10474,8 @@ func (s *Server) handleGetApiregistrationAPIGroupRequest(args [0]string, argsEsc // // GET /apis/apiregistration.k8s.io/v1/ func (s *Server) handleGetApiregistrationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getApiregistrationV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -8865,7 +10497,16 @@ func (s *Server) handleGetApiregistrationV1APIResourcesRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8877,8 +10518,27 @@ func (s *Server) handleGetApiregistrationV1APIResourcesRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8985,6 +10645,8 @@ func (s *Server) handleGetApiregistrationV1APIResourcesRequest(args [0]string, a // // GET /apis/apps/ func (s *Server) handleGetAppsAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAppsAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9006,7 +10668,16 @@ func (s *Server) handleGetAppsAPIGroupRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9018,8 +10689,27 @@ func (s *Server) handleGetAppsAPIGroupRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9126,6 +10816,8 @@ func (s *Server) handleGetAppsAPIGroupRequest(args [0]string, argsEscaped bool, // // GET /apis/apps/v1/ func (s *Server) handleGetAppsV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAppsV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9147,7 +10839,16 @@ func (s *Server) handleGetAppsV1APIResourcesRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9159,8 +10860,27 @@ func (s *Server) handleGetAppsV1APIResourcesRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9267,6 +10987,8 @@ func (s *Server) handleGetAppsV1APIResourcesRequest(args [0]string, argsEscaped // // GET /apis/authentication.k8s.io/ func (s *Server) handleGetAuthenticationAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAuthenticationAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9288,7 +11010,16 @@ func (s *Server) handleGetAuthenticationAPIGroupRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9300,8 +11031,27 @@ func (s *Server) handleGetAuthenticationAPIGroupRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9408,6 +11158,8 @@ func (s *Server) handleGetAuthenticationAPIGroupRequest(args [0]string, argsEsca // // GET /apis/authentication.k8s.io/v1/ func (s *Server) handleGetAuthenticationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAuthenticationV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9429,7 +11181,16 @@ func (s *Server) handleGetAuthenticationV1APIResourcesRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9441,8 +11202,27 @@ func (s *Server) handleGetAuthenticationV1APIResourcesRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9549,6 +11329,8 @@ func (s *Server) handleGetAuthenticationV1APIResourcesRequest(args [0]string, ar // // GET /apis/authorization.k8s.io/ func (s *Server) handleGetAuthorizationAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAuthorizationAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9570,7 +11352,16 @@ func (s *Server) handleGetAuthorizationAPIGroupRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9582,8 +11373,27 @@ func (s *Server) handleGetAuthorizationAPIGroupRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9690,6 +11500,8 @@ func (s *Server) handleGetAuthorizationAPIGroupRequest(args [0]string, argsEscap // // GET /apis/authorization.k8s.io/v1/ func (s *Server) handleGetAuthorizationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAuthorizationV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9711,7 +11523,16 @@ func (s *Server) handleGetAuthorizationV1APIResourcesRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9723,8 +11544,27 @@ func (s *Server) handleGetAuthorizationV1APIResourcesRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9831,6 +11671,8 @@ func (s *Server) handleGetAuthorizationV1APIResourcesRequest(args [0]string, arg // // GET /apis/autoscaling/ func (s *Server) handleGetAutoscalingAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAutoscalingAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9852,7 +11694,16 @@ func (s *Server) handleGetAutoscalingAPIGroupRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9864,8 +11715,27 @@ func (s *Server) handleGetAutoscalingAPIGroupRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9972,6 +11842,8 @@ func (s *Server) handleGetAutoscalingAPIGroupRequest(args [0]string, argsEscaped // // GET /apis/autoscaling/v1/ func (s *Server) handleGetAutoscalingV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAutoscalingV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -9993,7 +11865,16 @@ func (s *Server) handleGetAutoscalingV1APIResourcesRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10005,8 +11886,27 @@ func (s *Server) handleGetAutoscalingV1APIResourcesRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10113,6 +12013,8 @@ func (s *Server) handleGetAutoscalingV1APIResourcesRequest(args [0]string, argsE // // GET /apis/autoscaling/v2beta1/ func (s *Server) handleGetAutoscalingV2beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAutoscalingV2beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10134,7 +12036,16 @@ func (s *Server) handleGetAutoscalingV2beta1APIResourcesRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10146,8 +12057,27 @@ func (s *Server) handleGetAutoscalingV2beta1APIResourcesRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10254,6 +12184,8 @@ func (s *Server) handleGetAutoscalingV2beta1APIResourcesRequest(args [0]string, // // GET /apis/autoscaling/v2beta2/ func (s *Server) handleGetAutoscalingV2beta2APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getAutoscalingV2beta2APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10275,7 +12207,16 @@ func (s *Server) handleGetAutoscalingV2beta2APIResourcesRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10287,161 +12228,210 @@ func (s *Server) handleGetAutoscalingV2beta2APIResourcesRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: GetAutoscalingV2beta2APIResourcesOperation, - ID: "getAutoscalingV2beta2APIResources", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, GetAutoscalingV2beta2APIResourcesOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - var response GetAutoscalingV2beta2APIResourcesRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: GetAutoscalingV2beta2APIResourcesOperation, - OperationSummary: "", - OperationID: "getAutoscalingV2beta2APIResources", - Body: nil, - Params: middleware.Parameters{}, - Raw: r, - } - - type ( - Request = struct{} - Params = struct{} - Response = GetAutoscalingV2beta2APIResourcesRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - nil, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.GetAutoscalingV2beta2APIResources(ctx) - return response, err - }, - ) - } else { - response, err = s.h.GetAutoscalingV2beta2APIResources(ctx) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeGetAutoscalingV2beta2APIResourcesResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleGetBatchAPIGroupRequest handles getBatchAPIGroup operation. -// -// Get information of a group. -// -// GET /apis/batch/ -func (s *Server) handleGetBatchAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("getBatchAPIGroup"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/batch/"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), GetBatchAPIGroupOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: GetBatchAPIGroupOperation, - ID: "getBatchAPIGroup", + Name: GetAutoscalingV2beta2APIResourcesOperation, + ID: "getAutoscalingV2beta2APIResources", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, GetBatchAPIGroupOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, GetAutoscalingV2beta2APIResourcesOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + + var response GetAutoscalingV2beta2APIResourcesRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: GetAutoscalingV2beta2APIResourcesOperation, + OperationSummary: "", + OperationID: "getAutoscalingV2beta2APIResources", + Body: nil, + Params: middleware.Parameters{}, + Raw: r, + } + + type ( + Request = struct{} + Params = struct{} + Response = GetAutoscalingV2beta2APIResourcesRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + nil, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.GetAutoscalingV2beta2APIResources(ctx) + return response, err + }, + ) + } else { + response, err = s.h.GetAutoscalingV2beta2APIResources(ctx) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeGetAutoscalingV2beta2APIResourcesResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleGetBatchAPIGroupRequest handles getBatchAPIGroup operation. +// +// Get information of a group. +// +// GET /apis/batch/ +func (s *Server) handleGetBatchAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("getBatchAPIGroup"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/batch/"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), GetBatchAPIGroupOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: GetBatchAPIGroupOperation, + ID: "getBatchAPIGroup", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, GetBatchAPIGroupOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -10536,6 +12526,8 @@ func (s *Server) handleGetBatchAPIGroupRequest(args [0]string, argsEscaped bool, // // GET /apis/batch/v1/ func (s *Server) handleGetBatchV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getBatchV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10557,7 +12549,16 @@ func (s *Server) handleGetBatchV1APIResourcesRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10569,8 +12570,27 @@ func (s *Server) handleGetBatchV1APIResourcesRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10677,6 +12697,8 @@ func (s *Server) handleGetBatchV1APIResourcesRequest(args [0]string, argsEscaped // // GET /apis/batch/v1beta1/ func (s *Server) handleGetBatchV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getBatchV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10698,7 +12720,16 @@ func (s *Server) handleGetBatchV1beta1APIResourcesRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10710,8 +12741,27 @@ func (s *Server) handleGetBatchV1beta1APIResourcesRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10818,6 +12868,8 @@ func (s *Server) handleGetBatchV1beta1APIResourcesRequest(args [0]string, argsEs // // GET /apis/certificates.k8s.io/ func (s *Server) handleGetCertificatesAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCertificatesAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10839,7 +12891,16 @@ func (s *Server) handleGetCertificatesAPIGroupRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10851,8 +12912,27 @@ func (s *Server) handleGetCertificatesAPIGroupRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10959,6 +13039,8 @@ func (s *Server) handleGetCertificatesAPIGroupRequest(args [0]string, argsEscape // // GET /apis/certificates.k8s.io/v1/ func (s *Server) handleGetCertificatesV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCertificatesV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -10980,7 +13062,16 @@ func (s *Server) handleGetCertificatesV1APIResourcesRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10992,8 +13083,27 @@ func (s *Server) handleGetCertificatesV1APIResourcesRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11100,6 +13210,8 @@ func (s *Server) handleGetCertificatesV1APIResourcesRequest(args [0]string, args // // GET /version/ func (s *Server) handleGetCodeVersionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCodeVersion"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11121,7 +13233,16 @@ func (s *Server) handleGetCodeVersionRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11133,8 +13254,27 @@ func (s *Server) handleGetCodeVersionRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11241,6 +13381,8 @@ func (s *Server) handleGetCodeVersionRequest(args [0]string, argsEscaped bool, w // // GET /apis/coordination.k8s.io/ func (s *Server) handleGetCoordinationAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCoordinationAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11262,7 +13404,16 @@ func (s *Server) handleGetCoordinationAPIGroupRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11274,8 +13425,27 @@ func (s *Server) handleGetCoordinationAPIGroupRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11382,6 +13552,8 @@ func (s *Server) handleGetCoordinationAPIGroupRequest(args [0]string, argsEscape // // GET /apis/coordination.k8s.io/v1/ func (s *Server) handleGetCoordinationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCoordinationV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11403,7 +13575,16 @@ func (s *Server) handleGetCoordinationV1APIResourcesRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11415,8 +13596,27 @@ func (s *Server) handleGetCoordinationV1APIResourcesRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11523,6 +13723,8 @@ func (s *Server) handleGetCoordinationV1APIResourcesRequest(args [0]string, args // // GET /api/ func (s *Server) handleGetCoreAPIVersionsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCoreAPIVersions"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11544,7 +13746,16 @@ func (s *Server) handleGetCoreAPIVersionsRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11556,8 +13767,27 @@ func (s *Server) handleGetCoreAPIVersionsRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11664,6 +13894,8 @@ func (s *Server) handleGetCoreAPIVersionsRequest(args [0]string, argsEscaped boo // // GET /api/v1/ func (s *Server) handleGetCoreV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getCoreV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11685,7 +13917,16 @@ func (s *Server) handleGetCoreV1APIResourcesRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11697,8 +13938,27 @@ func (s *Server) handleGetCoreV1APIResourcesRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11805,6 +14065,8 @@ func (s *Server) handleGetCoreV1APIResourcesRequest(args [0]string, argsEscaped // // GET /apis/discovery.k8s.io/ func (s *Server) handleGetDiscoveryAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getDiscoveryAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11826,7 +14088,16 @@ func (s *Server) handleGetDiscoveryAPIGroupRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11838,8 +14109,27 @@ func (s *Server) handleGetDiscoveryAPIGroupRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11946,6 +14236,8 @@ func (s *Server) handleGetDiscoveryAPIGroupRequest(args [0]string, argsEscaped b // // GET /apis/discovery.k8s.io/v1/ func (s *Server) handleGetDiscoveryV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getDiscoveryV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -11967,7 +14259,16 @@ func (s *Server) handleGetDiscoveryV1APIResourcesRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11979,8 +14280,27 @@ func (s *Server) handleGetDiscoveryV1APIResourcesRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12087,6 +14407,8 @@ func (s *Server) handleGetDiscoveryV1APIResourcesRequest(args [0]string, argsEsc // // GET /apis/discovery.k8s.io/v1beta1/ func (s *Server) handleGetDiscoveryV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getDiscoveryV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12108,7 +14430,16 @@ func (s *Server) handleGetDiscoveryV1beta1APIResourcesRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12120,8 +14451,27 @@ func (s *Server) handleGetDiscoveryV1beta1APIResourcesRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12228,6 +14578,8 @@ func (s *Server) handleGetDiscoveryV1beta1APIResourcesRequest(args [0]string, ar // // GET /apis/events.k8s.io/ func (s *Server) handleGetEventsAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getEventsAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12249,7 +14601,16 @@ func (s *Server) handleGetEventsAPIGroupRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12261,8 +14622,27 @@ func (s *Server) handleGetEventsAPIGroupRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12369,6 +14749,8 @@ func (s *Server) handleGetEventsAPIGroupRequest(args [0]string, argsEscaped bool // // GET /apis/events.k8s.io/v1/ func (s *Server) handleGetEventsV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getEventsV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12390,7 +14772,16 @@ func (s *Server) handleGetEventsV1APIResourcesRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12402,8 +14793,27 @@ func (s *Server) handleGetEventsV1APIResourcesRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12510,6 +14920,8 @@ func (s *Server) handleGetEventsV1APIResourcesRequest(args [0]string, argsEscape // // GET /apis/events.k8s.io/v1beta1/ func (s *Server) handleGetEventsV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getEventsV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12531,7 +14943,16 @@ func (s *Server) handleGetEventsV1beta1APIResourcesRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12543,8 +14964,27 @@ func (s *Server) handleGetEventsV1beta1APIResourcesRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12651,6 +15091,8 @@ func (s *Server) handleGetEventsV1beta1APIResourcesRequest(args [0]string, argsE // // GET /apis/flowcontrol.apiserver.k8s.io/ func (s *Server) handleGetFlowcontrolApiserverAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getFlowcontrolApiserverAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12672,7 +15114,16 @@ func (s *Server) handleGetFlowcontrolApiserverAPIGroupRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12684,8 +15135,27 @@ func (s *Server) handleGetFlowcontrolApiserverAPIGroupRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12792,6 +15262,8 @@ func (s *Server) handleGetFlowcontrolApiserverAPIGroupRequest(args [0]string, ar // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/ func (s *Server) handleGetFlowcontrolApiserverV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getFlowcontrolApiserverV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12813,7 +15285,16 @@ func (s *Server) handleGetFlowcontrolApiserverV1beta1APIResourcesRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12825,8 +15306,27 @@ func (s *Server) handleGetFlowcontrolApiserverV1beta1APIResourcesRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12933,6 +15433,8 @@ func (s *Server) handleGetFlowcontrolApiserverV1beta1APIResourcesRequest(args [0 // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/ func (s *Server) handleGetFlowcontrolApiserverV1beta2APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getFlowcontrolApiserverV1beta2APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -12954,7 +15456,16 @@ func (s *Server) handleGetFlowcontrolApiserverV1beta2APIResourcesRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12966,8 +15477,27 @@ func (s *Server) handleGetFlowcontrolApiserverV1beta2APIResourcesRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13074,6 +15604,8 @@ func (s *Server) handleGetFlowcontrolApiserverV1beta2APIResourcesRequest(args [0 // // GET /apis/internal.apiserver.k8s.io/ func (s *Server) handleGetInternalApiserverAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getInternalApiserverAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13095,7 +15627,16 @@ func (s *Server) handleGetInternalApiserverAPIGroupRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13107,8 +15648,27 @@ func (s *Server) handleGetInternalApiserverAPIGroupRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13215,6 +15775,8 @@ func (s *Server) handleGetInternalApiserverAPIGroupRequest(args [0]string, argsE // // GET /apis/internal.apiserver.k8s.io/v1alpha1/ func (s *Server) handleGetInternalApiserverV1alpha1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getInternalApiserverV1alpha1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13236,7 +15798,16 @@ func (s *Server) handleGetInternalApiserverV1alpha1APIResourcesRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13248,8 +15819,27 @@ func (s *Server) handleGetInternalApiserverV1alpha1APIResourcesRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13356,6 +15946,8 @@ func (s *Server) handleGetInternalApiserverV1alpha1APIResourcesRequest(args [0]s // // GET /apis/networking.k8s.io/ func (s *Server) handleGetNetworkingAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getNetworkingAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13377,7 +15969,16 @@ func (s *Server) handleGetNetworkingAPIGroupRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13389,8 +15990,27 @@ func (s *Server) handleGetNetworkingAPIGroupRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13497,6 +16117,8 @@ func (s *Server) handleGetNetworkingAPIGroupRequest(args [0]string, argsEscaped // // GET /apis/networking.k8s.io/v1/ func (s *Server) handleGetNetworkingV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getNetworkingV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13518,7 +16140,16 @@ func (s *Server) handleGetNetworkingV1APIResourcesRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13530,8 +16161,27 @@ func (s *Server) handleGetNetworkingV1APIResourcesRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13638,6 +16288,8 @@ func (s *Server) handleGetNetworkingV1APIResourcesRequest(args [0]string, argsEs // // GET /apis/node.k8s.io/ func (s *Server) handleGetNodeAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getNodeAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13659,7 +16311,16 @@ func (s *Server) handleGetNodeAPIGroupRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13671,8 +16332,27 @@ func (s *Server) handleGetNodeAPIGroupRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13779,6 +16459,8 @@ func (s *Server) handleGetNodeAPIGroupRequest(args [0]string, argsEscaped bool, // // GET /apis/node.k8s.io/v1/ func (s *Server) handleGetNodeV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getNodeV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13800,7 +16482,16 @@ func (s *Server) handleGetNodeV1APIResourcesRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13812,8 +16503,27 @@ func (s *Server) handleGetNodeV1APIResourcesRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13920,6 +16630,8 @@ func (s *Server) handleGetNodeV1APIResourcesRequest(args [0]string, argsEscaped // // GET /apis/node.k8s.io/v1alpha1/ func (s *Server) handleGetNodeV1alpha1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getNodeV1alpha1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -13941,7 +16653,16 @@ func (s *Server) handleGetNodeV1alpha1APIResourcesRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13953,8 +16674,27 @@ func (s *Server) handleGetNodeV1alpha1APIResourcesRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14061,6 +16801,8 @@ func (s *Server) handleGetNodeV1alpha1APIResourcesRequest(args [0]string, argsEs // // GET /apis/node.k8s.io/v1beta1/ func (s *Server) handleGetNodeV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getNodeV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14082,7 +16824,16 @@ func (s *Server) handleGetNodeV1beta1APIResourcesRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14094,8 +16845,27 @@ func (s *Server) handleGetNodeV1beta1APIResourcesRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14202,6 +16972,8 @@ func (s *Server) handleGetNodeV1beta1APIResourcesRequest(args [0]string, argsEsc // // GET /apis/policy/ func (s *Server) handleGetPolicyAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPolicyAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14223,7 +16995,16 @@ func (s *Server) handleGetPolicyAPIGroupRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14235,8 +17016,27 @@ func (s *Server) handleGetPolicyAPIGroupRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14343,6 +17143,8 @@ func (s *Server) handleGetPolicyAPIGroupRequest(args [0]string, argsEscaped bool // // GET /apis/policy/v1/ func (s *Server) handleGetPolicyV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPolicyV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14364,7 +17166,16 @@ func (s *Server) handleGetPolicyV1APIResourcesRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14376,8 +17187,27 @@ func (s *Server) handleGetPolicyV1APIResourcesRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14484,6 +17314,8 @@ func (s *Server) handleGetPolicyV1APIResourcesRequest(args [0]string, argsEscape // // GET /apis/policy/v1beta1/ func (s *Server) handleGetPolicyV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPolicyV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14505,7 +17337,16 @@ func (s *Server) handleGetPolicyV1beta1APIResourcesRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14517,8 +17358,27 @@ func (s *Server) handleGetPolicyV1beta1APIResourcesRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14625,6 +17485,8 @@ func (s *Server) handleGetPolicyV1beta1APIResourcesRequest(args [0]string, argsE // // GET /apis/rbac.authorization.k8s.io/ func (s *Server) handleGetRbacAuthorizationAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getRbacAuthorizationAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14646,7 +17508,16 @@ func (s *Server) handleGetRbacAuthorizationAPIGroupRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14658,161 +17529,210 @@ func (s *Server) handleGetRbacAuthorizationAPIGroupRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: GetRbacAuthorizationAPIGroupOperation, - ID: "getRbacAuthorizationAPIGroup", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, GetRbacAuthorizationAPIGroupOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - var response GetRbacAuthorizationAPIGroupRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: GetRbacAuthorizationAPIGroupOperation, - OperationSummary: "", - OperationID: "getRbacAuthorizationAPIGroup", - Body: nil, - Params: middleware.Parameters{}, - Raw: r, - } - - type ( - Request = struct{} - Params = struct{} - Response = GetRbacAuthorizationAPIGroupRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - nil, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.GetRbacAuthorizationAPIGroup(ctx) - return response, err - }, - ) - } else { - response, err = s.h.GetRbacAuthorizationAPIGroup(ctx) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeGetRbacAuthorizationAPIGroupResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleGetRbacAuthorizationV1APIResourcesRequest handles getRbacAuthorizationV1APIResources operation. -// -// Get available resources. -// -// GET /apis/rbac.authorization.k8s.io/v1/ -func (s *Server) handleGetRbacAuthorizationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("getRbacAuthorizationV1APIResources"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/rbac.authorization.k8s.io/v1/"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), GetRbacAuthorizationV1APIResourcesOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: GetRbacAuthorizationV1APIResourcesOperation, - ID: "getRbacAuthorizationV1APIResources", + Name: GetRbacAuthorizationAPIGroupOperation, + ID: "getRbacAuthorizationAPIGroup", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, GetRbacAuthorizationV1APIResourcesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, GetRbacAuthorizationAPIGroupOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + + var response GetRbacAuthorizationAPIGroupRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: GetRbacAuthorizationAPIGroupOperation, + OperationSummary: "", + OperationID: "getRbacAuthorizationAPIGroup", + Body: nil, + Params: middleware.Parameters{}, + Raw: r, + } + + type ( + Request = struct{} + Params = struct{} + Response = GetRbacAuthorizationAPIGroupRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + nil, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.GetRbacAuthorizationAPIGroup(ctx) + return response, err + }, + ) + } else { + response, err = s.h.GetRbacAuthorizationAPIGroup(ctx) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeGetRbacAuthorizationAPIGroupResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleGetRbacAuthorizationV1APIResourcesRequest handles getRbacAuthorizationV1APIResources operation. +// +// Get available resources. +// +// GET /apis/rbac.authorization.k8s.io/v1/ +func (s *Server) handleGetRbacAuthorizationV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("getRbacAuthorizationV1APIResources"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/rbac.authorization.k8s.io/v1/"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), GetRbacAuthorizationV1APIResourcesOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: GetRbacAuthorizationV1APIResourcesOperation, + ID: "getRbacAuthorizationV1APIResources", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, GetRbacAuthorizationV1APIResourcesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -14907,6 +17827,8 @@ func (s *Server) handleGetRbacAuthorizationV1APIResourcesRequest(args [0]string, // // GET /apis/scheduling.k8s.io/ func (s *Server) handleGetSchedulingAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getSchedulingAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -14928,7 +17850,16 @@ func (s *Server) handleGetSchedulingAPIGroupRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14940,8 +17871,27 @@ func (s *Server) handleGetSchedulingAPIGroupRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15048,6 +17998,8 @@ func (s *Server) handleGetSchedulingAPIGroupRequest(args [0]string, argsEscaped // // GET /apis/scheduling.k8s.io/v1/ func (s *Server) handleGetSchedulingV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getSchedulingV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15069,7 +18021,16 @@ func (s *Server) handleGetSchedulingV1APIResourcesRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15081,8 +18042,27 @@ func (s *Server) handleGetSchedulingV1APIResourcesRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15189,6 +18169,8 @@ func (s *Server) handleGetSchedulingV1APIResourcesRequest(args [0]string, argsEs // // GET /.well-known/openid-configuration/ func (s *Server) handleGetServiceAccountIssuerOpenIDConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getServiceAccountIssuerOpenIDConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15210,7 +18192,16 @@ func (s *Server) handleGetServiceAccountIssuerOpenIDConfigurationRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15222,8 +18213,27 @@ func (s *Server) handleGetServiceAccountIssuerOpenIDConfigurationRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15330,6 +18340,8 @@ func (s *Server) handleGetServiceAccountIssuerOpenIDConfigurationRequest(args [0 // // GET /openid/v1/jwks/ func (s *Server) handleGetServiceAccountIssuerOpenIDKeysetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getServiceAccountIssuerOpenIDKeyset"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15351,7 +18363,16 @@ func (s *Server) handleGetServiceAccountIssuerOpenIDKeysetRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15363,8 +18384,27 @@ func (s *Server) handleGetServiceAccountIssuerOpenIDKeysetRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15471,6 +18511,8 @@ func (s *Server) handleGetServiceAccountIssuerOpenIDKeysetRequest(args [0]string // // GET /apis/storage.k8s.io/ func (s *Server) handleGetStorageAPIGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getStorageAPIGroup"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15492,7 +18534,16 @@ func (s *Server) handleGetStorageAPIGroupRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15504,8 +18555,27 @@ func (s *Server) handleGetStorageAPIGroupRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15612,6 +18682,8 @@ func (s *Server) handleGetStorageAPIGroupRequest(args [0]string, argsEscaped boo // // GET /apis/storage.k8s.io/v1/ func (s *Server) handleGetStorageV1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getStorageV1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15633,7 +18705,16 @@ func (s *Server) handleGetStorageV1APIResourcesRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15645,8 +18726,27 @@ func (s *Server) handleGetStorageV1APIResourcesRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15753,6 +18853,8 @@ func (s *Server) handleGetStorageV1APIResourcesRequest(args [0]string, argsEscap // // GET /apis/storage.k8s.io/v1alpha1/ func (s *Server) handleGetStorageV1alpha1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getStorageV1alpha1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15774,7 +18876,16 @@ func (s *Server) handleGetStorageV1alpha1APIResourcesRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15786,8 +18897,27 @@ func (s *Server) handleGetStorageV1alpha1APIResourcesRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15894,6 +19024,8 @@ func (s *Server) handleGetStorageV1alpha1APIResourcesRequest(args [0]string, arg // // GET /apis/storage.k8s.io/v1beta1/ func (s *Server) handleGetStorageV1beta1APIResourcesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getStorageV1beta1APIResources"), semconv.HTTPRequestMethodKey.String("GET"), @@ -15915,7 +19047,16 @@ func (s *Server) handleGetStorageV1beta1APIResourcesRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15927,8 +19068,27 @@ func (s *Server) handleGetStorageV1beta1APIResourcesRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16035,6 +19195,8 @@ func (s *Server) handleGetStorageV1beta1APIResourcesRequest(args [0]string, args // // GET /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations func (s *Server) handleListAdmissionregistrationV1MutatingWebhookConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAdmissionregistrationV1MutatingWebhookConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -16056,7 +19218,16 @@ func (s *Server) handleListAdmissionregistrationV1MutatingWebhookConfigurationRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16068,8 +19239,27 @@ func (s *Server) handleListAdmissionregistrationV1MutatingWebhookConfigurationRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16227,6 +19417,8 @@ func (s *Server) handleListAdmissionregistrationV1MutatingWebhookConfigurationRe // // GET /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations func (s *Server) handleListAdmissionregistrationV1ValidatingWebhookConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAdmissionregistrationV1ValidatingWebhookConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -16248,7 +19440,16 @@ func (s *Server) handleListAdmissionregistrationV1ValidatingWebhookConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16260,8 +19461,27 @@ func (s *Server) handleListAdmissionregistrationV1ValidatingWebhookConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16419,6 +19639,8 @@ func (s *Server) handleListAdmissionregistrationV1ValidatingWebhookConfiguration // // GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions func (s *Server) handleListApiextensionsV1CustomResourceDefinitionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listApiextensionsV1CustomResourceDefinition"), semconv.HTTPRequestMethodKey.String("GET"), @@ -16440,7 +19662,16 @@ func (s *Server) handleListApiextensionsV1CustomResourceDefinitionRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16452,8 +19683,27 @@ func (s *Server) handleListApiextensionsV1CustomResourceDefinitionRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16611,6 +19861,8 @@ func (s *Server) handleListApiextensionsV1CustomResourceDefinitionRequest(args [ // // GET /apis/apiregistration.k8s.io/v1/apiservices func (s *Server) handleListApiregistrationV1APIServiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listApiregistrationV1APIService"), semconv.HTTPRequestMethodKey.String("GET"), @@ -16632,7 +19884,16 @@ func (s *Server) handleListApiregistrationV1APIServiceRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16644,8 +19905,27 @@ func (s *Server) handleListApiregistrationV1APIServiceRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16803,6 +20083,8 @@ func (s *Server) handleListApiregistrationV1APIServiceRequest(args [0]string, ar // // GET /apis/apps/v1/controllerrevisions func (s *Server) handleListAppsV1ControllerRevisionForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1ControllerRevisionForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -16824,7 +20106,16 @@ func (s *Server) handleListAppsV1ControllerRevisionForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16836,8 +20127,27 @@ func (s *Server) handleListAppsV1ControllerRevisionForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16995,6 +20305,8 @@ func (s *Server) handleListAppsV1ControllerRevisionForAllNamespacesRequest(args // // GET /apis/apps/v1/daemonsets func (s *Server) handleListAppsV1DaemonSetForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1DaemonSetForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17016,7 +20328,16 @@ func (s *Server) handleListAppsV1DaemonSetForAllNamespacesRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17028,8 +20349,27 @@ func (s *Server) handleListAppsV1DaemonSetForAllNamespacesRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17187,6 +20527,8 @@ func (s *Server) handleListAppsV1DaemonSetForAllNamespacesRequest(args [0]string // // GET /apis/apps/v1/deployments func (s *Server) handleListAppsV1DeploymentForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1DeploymentForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17208,7 +20550,16 @@ func (s *Server) handleListAppsV1DeploymentForAllNamespacesRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17220,8 +20571,27 @@ func (s *Server) handleListAppsV1DeploymentForAllNamespacesRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17379,6 +20749,8 @@ func (s *Server) handleListAppsV1DeploymentForAllNamespacesRequest(args [0]strin // // GET /apis/apps/v1/namespaces/{namespace}/controllerrevisions func (s *Server) handleListAppsV1NamespacedControllerRevisionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1NamespacedControllerRevision"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17400,7 +20772,16 @@ func (s *Server) handleListAppsV1NamespacedControllerRevisionRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17412,8 +20793,27 @@ func (s *Server) handleListAppsV1NamespacedControllerRevisionRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17575,6 +20975,8 @@ func (s *Server) handleListAppsV1NamespacedControllerRevisionRequest(args [1]str // // GET /apis/apps/v1/namespaces/{namespace}/daemonsets func (s *Server) handleListAppsV1NamespacedDaemonSetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1NamespacedDaemonSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17596,7 +20998,16 @@ func (s *Server) handleListAppsV1NamespacedDaemonSetRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17608,8 +21019,27 @@ func (s *Server) handleListAppsV1NamespacedDaemonSetRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17771,6 +21201,8 @@ func (s *Server) handleListAppsV1NamespacedDaemonSetRequest(args [1]string, args // // GET /apis/apps/v1/namespaces/{namespace}/deployments func (s *Server) handleListAppsV1NamespacedDeploymentRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1NamespacedDeployment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17792,7 +21224,16 @@ func (s *Server) handleListAppsV1NamespacedDeploymentRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17804,8 +21245,27 @@ func (s *Server) handleListAppsV1NamespacedDeploymentRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17967,6 +21427,8 @@ func (s *Server) handleListAppsV1NamespacedDeploymentRequest(args [1]string, arg // // GET /apis/apps/v1/namespaces/{namespace}/replicasets func (s *Server) handleListAppsV1NamespacedReplicaSetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1NamespacedReplicaSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -17988,7 +21450,16 @@ func (s *Server) handleListAppsV1NamespacedReplicaSetRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18000,8 +21471,27 @@ func (s *Server) handleListAppsV1NamespacedReplicaSetRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18163,6 +21653,8 @@ func (s *Server) handleListAppsV1NamespacedReplicaSetRequest(args [1]string, arg // // GET /apis/apps/v1/namespaces/{namespace}/statefulsets func (s *Server) handleListAppsV1NamespacedStatefulSetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1NamespacedStatefulSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18184,7 +21676,16 @@ func (s *Server) handleListAppsV1NamespacedStatefulSetRequest(args [1]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18196,8 +21697,27 @@ func (s *Server) handleListAppsV1NamespacedStatefulSetRequest(args [1]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18359,6 +21879,8 @@ func (s *Server) handleListAppsV1NamespacedStatefulSetRequest(args [1]string, ar // // GET /apis/apps/v1/replicasets func (s *Server) handleListAppsV1ReplicaSetForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1ReplicaSetForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18380,7 +21902,16 @@ func (s *Server) handleListAppsV1ReplicaSetForAllNamespacesRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18392,8 +21923,27 @@ func (s *Server) handleListAppsV1ReplicaSetForAllNamespacesRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18551,6 +22101,8 @@ func (s *Server) handleListAppsV1ReplicaSetForAllNamespacesRequest(args [0]strin // // GET /apis/apps/v1/statefulsets func (s *Server) handleListAppsV1StatefulSetForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAppsV1StatefulSetForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18572,7 +22124,16 @@ func (s *Server) handleListAppsV1StatefulSetForAllNamespacesRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18584,8 +22145,27 @@ func (s *Server) handleListAppsV1StatefulSetForAllNamespacesRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18743,6 +22323,8 @@ func (s *Server) handleListAppsV1StatefulSetForAllNamespacesRequest(args [0]stri // // GET /apis/autoscaling/v1/horizontalpodautoscalers func (s *Server) handleListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAutoscalingV1HorizontalPodAutoscalerForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -18764,7 +22346,16 @@ func (s *Server) handleListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18776,212 +22367,261 @@ func (s *Server) handleListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesOperation, - ID: "listAutoscalingV1HorizontalPodAutoscalerForAllNamespaces", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - var response ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesOperation, - OperationSummary: "", - OperationID: "listAutoscalingV1HorizontalPodAutoscalerForAllNamespaces", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "pretty", - In: "query", - }: params.Pretty, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesParams - Response = ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListAutoscalingV1HorizontalPodAutoscalerForAllNamespaces(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ListAutoscalingV1HorizontalPodAutoscalerForAllNamespaces(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleListAutoscalingV1NamespacedHorizontalPodAutoscalerRequest handles listAutoscalingV1NamespacedHorizontalPodAutoscaler operation. -// -// List or watch objects of kind HorizontalPodAutoscaler. -// -// GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers -func (s *Server) handleListAutoscalingV1NamespacedHorizontalPodAutoscalerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listAutoscalingV1NamespacedHorizontalPodAutoscaler"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListAutoscalingV1NamespacedHorizontalPodAutoscalerOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListAutoscalingV1NamespacedHorizontalPodAutoscalerOperation, - ID: "listAutoscalingV1NamespacedHorizontalPodAutoscaler", + Name: ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesOperation, + ID: "listAutoscalingV1HorizontalPodAutoscalerForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListAutoscalingV1NamespacedHorizontalPodAutoscalerOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesOperation, + OperationSummary: "", + OperationID: "listAutoscalingV1HorizontalPodAutoscalerForAllNamespaces", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "pretty", + In: "query", + }: params.Pretty, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesParams + Response = ListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListAutoscalingV1HorizontalPodAutoscalerForAllNamespaces(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListAutoscalingV1HorizontalPodAutoscalerForAllNamespaces(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListAutoscalingV1HorizontalPodAutoscalerForAllNamespacesResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleListAutoscalingV1NamespacedHorizontalPodAutoscalerRequest handles listAutoscalingV1NamespacedHorizontalPodAutoscaler operation. +// +// List or watch objects of kind HorizontalPodAutoscaler. +// +// GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers +func (s *Server) handleListAutoscalingV1NamespacedHorizontalPodAutoscalerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listAutoscalingV1NamespacedHorizontalPodAutoscaler"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ListAutoscalingV1NamespacedHorizontalPodAutoscalerOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ListAutoscalingV1NamespacedHorizontalPodAutoscalerOperation, + ID: "listAutoscalingV1NamespacedHorizontalPodAutoscaler", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ListAutoscalingV1NamespacedHorizontalPodAutoscalerOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -19131,6 +22771,8 @@ func (s *Server) handleListAutoscalingV1NamespacedHorizontalPodAutoscalerRequest // // GET /apis/autoscaling/v2beta1/horizontalpodautoscalers func (s *Server) handleListAutoscalingV2beta1HorizontalPodAutoscalerForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAutoscalingV2beta1HorizontalPodAutoscalerForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19152,7 +22794,16 @@ func (s *Server) handleListAutoscalingV2beta1HorizontalPodAutoscalerForAllNamesp startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19164,8 +22815,27 @@ func (s *Server) handleListAutoscalingV2beta1HorizontalPodAutoscalerForAllNamesp var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19323,6 +22993,8 @@ func (s *Server) handleListAutoscalingV2beta1HorizontalPodAutoscalerForAllNamesp // // GET /apis/autoscaling/v2beta1/namespaces/{namespace}/horizontalpodautoscalers func (s *Server) handleListAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAutoscalingV2beta1NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19344,7 +23016,16 @@ func (s *Server) handleListAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19356,8 +23037,27 @@ func (s *Server) handleListAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19519,6 +23219,8 @@ func (s *Server) handleListAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRe // // GET /apis/autoscaling/v2beta2/horizontalpodautoscalers func (s *Server) handleListAutoscalingV2beta2HorizontalPodAutoscalerForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAutoscalingV2beta2HorizontalPodAutoscalerForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19540,7 +23242,16 @@ func (s *Server) handleListAutoscalingV2beta2HorizontalPodAutoscalerForAllNamesp startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19552,8 +23263,27 @@ func (s *Server) handleListAutoscalingV2beta2HorizontalPodAutoscalerForAllNamesp var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19711,6 +23441,8 @@ func (s *Server) handleListAutoscalingV2beta2HorizontalPodAutoscalerForAllNamesp // // GET /apis/autoscaling/v2beta2/namespaces/{namespace}/horizontalpodautoscalers func (s *Server) handleListAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listAutoscalingV2beta2NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19732,7 +23464,16 @@ func (s *Server) handleListAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19744,8 +23485,27 @@ func (s *Server) handleListAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19907,6 +23667,8 @@ func (s *Server) handleListAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRe // // GET /apis/batch/v1/cronjobs func (s *Server) handleListBatchV1CronJobForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listBatchV1CronJobForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -19928,7 +23690,16 @@ func (s *Server) handleListBatchV1CronJobForAllNamespacesRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19940,8 +23711,27 @@ func (s *Server) handleListBatchV1CronJobForAllNamespacesRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20099,6 +23889,8 @@ func (s *Server) handleListBatchV1CronJobForAllNamespacesRequest(args [0]string, // // GET /apis/batch/v1/jobs func (s *Server) handleListBatchV1JobForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listBatchV1JobForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20120,7 +23912,16 @@ func (s *Server) handleListBatchV1JobForAllNamespacesRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20132,8 +23933,27 @@ func (s *Server) handleListBatchV1JobForAllNamespacesRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20291,6 +24111,8 @@ func (s *Server) handleListBatchV1JobForAllNamespacesRequest(args [0]string, arg // // GET /apis/batch/v1/namespaces/{namespace}/cronjobs func (s *Server) handleListBatchV1NamespacedCronJobRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listBatchV1NamespacedCronJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20312,7 +24134,16 @@ func (s *Server) handleListBatchV1NamespacedCronJobRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20324,8 +24155,27 @@ func (s *Server) handleListBatchV1NamespacedCronJobRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20487,6 +24337,8 @@ func (s *Server) handleListBatchV1NamespacedCronJobRequest(args [1]string, argsE // // GET /apis/batch/v1/namespaces/{namespace}/jobs func (s *Server) handleListBatchV1NamespacedJobRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listBatchV1NamespacedJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20508,7 +24360,16 @@ func (s *Server) handleListBatchV1NamespacedJobRequest(args [1]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20520,8 +24381,27 @@ func (s *Server) handleListBatchV1NamespacedJobRequest(args [1]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20683,6 +24563,8 @@ func (s *Server) handleListBatchV1NamespacedJobRequest(args [1]string, argsEscap // // GET /apis/batch/v1beta1/cronjobs func (s *Server) handleListBatchV1beta1CronJobForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listBatchV1beta1CronJobForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20704,7 +24586,16 @@ func (s *Server) handleListBatchV1beta1CronJobForAllNamespacesRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20716,8 +24607,27 @@ func (s *Server) handleListBatchV1beta1CronJobForAllNamespacesRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20875,6 +24785,8 @@ func (s *Server) handleListBatchV1beta1CronJobForAllNamespacesRequest(args [0]st // // GET /apis/batch/v1beta1/namespaces/{namespace}/cronjobs func (s *Server) handleListBatchV1beta1NamespacedCronJobRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listBatchV1beta1NamespacedCronJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -20896,7 +24808,16 @@ func (s *Server) handleListBatchV1beta1NamespacedCronJobRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20908,8 +24829,27 @@ func (s *Server) handleListBatchV1beta1NamespacedCronJobRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21071,6 +25011,8 @@ func (s *Server) handleListBatchV1beta1NamespacedCronJobRequest(args [1]string, // // GET /apis/certificates.k8s.io/v1/certificatesigningrequests func (s *Server) handleListCertificatesV1CertificateSigningRequestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCertificatesV1CertificateSigningRequest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -21092,7 +25034,16 @@ func (s *Server) handleListCertificatesV1CertificateSigningRequestRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21104,8 +25055,27 @@ func (s *Server) handleListCertificatesV1CertificateSigningRequestRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21263,6 +25233,8 @@ func (s *Server) handleListCertificatesV1CertificateSigningRequestRequest(args [ // // GET /apis/coordination.k8s.io/v1/leases func (s *Server) handleListCoordinationV1LeaseForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoordinationV1LeaseForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -21284,7 +25256,16 @@ func (s *Server) handleListCoordinationV1LeaseForAllNamespacesRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21296,8 +25277,27 @@ func (s *Server) handleListCoordinationV1LeaseForAllNamespacesRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21455,6 +25455,8 @@ func (s *Server) handleListCoordinationV1LeaseForAllNamespacesRequest(args [0]st // // GET /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases func (s *Server) handleListCoordinationV1NamespacedLeaseRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoordinationV1NamespacedLease"), semconv.HTTPRequestMethodKey.String("GET"), @@ -21476,7 +25478,16 @@ func (s *Server) handleListCoordinationV1NamespacedLeaseRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21488,8 +25499,27 @@ func (s *Server) handleListCoordinationV1NamespacedLeaseRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21651,6 +25681,8 @@ func (s *Server) handleListCoordinationV1NamespacedLeaseRequest(args [1]string, // // GET /api/v1/componentstatuses func (s *Server) handleListCoreV1ComponentStatusRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1ComponentStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -21672,7 +25704,16 @@ func (s *Server) handleListCoreV1ComponentStatusRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21684,8 +25725,27 @@ func (s *Server) handleListCoreV1ComponentStatusRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21843,6 +25903,8 @@ func (s *Server) handleListCoreV1ComponentStatusRequest(args [0]string, argsEsca // // GET /api/v1/configmaps func (s *Server) handleListCoreV1ConfigMapForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1ConfigMapForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -21864,7 +25926,16 @@ func (s *Server) handleListCoreV1ConfigMapForAllNamespacesRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21876,8 +25947,27 @@ func (s *Server) handleListCoreV1ConfigMapForAllNamespacesRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22035,6 +26125,8 @@ func (s *Server) handleListCoreV1ConfigMapForAllNamespacesRequest(args [0]string // // GET /api/v1/endpoints func (s *Server) handleListCoreV1EndpointsForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1EndpointsForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22056,7 +26148,16 @@ func (s *Server) handleListCoreV1EndpointsForAllNamespacesRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22068,8 +26169,27 @@ func (s *Server) handleListCoreV1EndpointsForAllNamespacesRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22227,6 +26347,8 @@ func (s *Server) handleListCoreV1EndpointsForAllNamespacesRequest(args [0]string // // GET /api/v1/events func (s *Server) handleListCoreV1EventForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1EventForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -22248,7 +26370,16 @@ func (s *Server) handleListCoreV1EventForAllNamespacesRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22260,212 +26391,39 @@ func (s *Server) handleListCoreV1EventForAllNamespacesRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1EventForAllNamespacesOperation, - ID: "listCoreV1EventForAllNamespaces", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1EventForAllNamespacesOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeListCoreV1EventForAllNamespacesParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - var response ListCoreV1EventForAllNamespacesRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ListCoreV1EventForAllNamespacesOperation, - OperationSummary: "", - OperationID: "listCoreV1EventForAllNamespaces", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "pretty", - In: "query", - }: params.Pretty, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ListCoreV1EventForAllNamespacesParams - Response = ListCoreV1EventForAllNamespacesRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackListCoreV1EventForAllNamespacesParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1EventForAllNamespaces(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ListCoreV1EventForAllNamespaces(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeListCoreV1EventForAllNamespacesResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleListCoreV1LimitRangeForAllNamespacesRequest handles listCoreV1LimitRangeForAllNamespaces operation. -// -// List or watch objects of kind LimitRange. -// -// GET /api/v1/limitranges -func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1LimitRangeForAllNamespaces"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/limitranges"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1LimitRangeForAllNamespacesOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1LimitRangeForAllNamespacesOperation, - ID: "listCoreV1LimitRangeForAllNamespaces", + Name: ListCoreV1EventForAllNamespacesOperation, + ID: "listCoreV1EventForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1LimitRangeForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1EventForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -22505,7 +26463,7 @@ func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]strin return } } - params, err := decodeListCoreV1LimitRangeForAllNamespacesParams(args, argsEscaped, r) + params, err := decodeListCoreV1EventForAllNamespacesParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -22516,13 +26474,13 @@ func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]strin return } - var response ListCoreV1LimitRangeForAllNamespacesRes + var response ListCoreV1EventForAllNamespacesRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1LimitRangeForAllNamespacesOperation, + OperationName: ListCoreV1EventForAllNamespacesOperation, OperationSummary: "", - OperationID: "listCoreV1LimitRangeForAllNamespaces", + OperationID: "listCoreV1EventForAllNamespaces", Body: nil, Params: middleware.Parameters{ { @@ -22571,8 +26529,8 @@ func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]strin type ( Request = struct{} - Params = ListCoreV1LimitRangeForAllNamespacesParams - Response = ListCoreV1LimitRangeForAllNamespacesRes + Params = ListCoreV1EventForAllNamespacesParams + Response = ListCoreV1EventForAllNamespacesRes ) response, err = middleware.HookMiddleware[ Request, @@ -22581,14 +26539,14 @@ func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]strin ]( m, mreq, - unpackListCoreV1LimitRangeForAllNamespacesParams, + unpackListCoreV1EventForAllNamespacesParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1LimitRangeForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1EventForAllNamespaces(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1LimitRangeForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1EventForAllNamespaces(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -22596,7 +26554,7 @@ func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]strin return } - if err := encodeListCoreV1LimitRangeForAllNamespacesResponse(response, w, span); err != nil { + if err := encodeListCoreV1EventForAllNamespacesResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -22605,20 +26563,22 @@ func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]strin } } -// handleListCoreV1NamespaceRequest handles listCoreV1Namespace operation. +// handleListCoreV1LimitRangeForAllNamespacesRequest handles listCoreV1LimitRangeForAllNamespaces operation. // -// List or watch objects of kind Namespace. +// List or watch objects of kind LimitRange. // -// GET /api/v1/namespaces -func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/limitranges +func (s *Server) handleListCoreV1LimitRangeForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1Namespace"), + otelogen.OperationID("listCoreV1LimitRangeForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces"), + semconv.HTTPRouteKey.String("/api/v1/limitranges"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespaceOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1LimitRangeForAllNamespacesOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -22632,7 +26592,16 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22644,20 +26613,39 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1NamespaceOperation, - ID: "listCoreV1Namespace", + Name: ListCoreV1LimitRangeForAllNamespacesOperation, + ID: "listCoreV1LimitRangeForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespaceOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1LimitRangeForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -22697,7 +26685,7 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo return } } - params, err := decodeListCoreV1NamespaceParams(args, argsEscaped, r) + params, err := decodeListCoreV1LimitRangeForAllNamespacesParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -22708,13 +26696,13 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo return } - var response ListCoreV1NamespaceRes + var response ListCoreV1LimitRangeForAllNamespacesRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1NamespaceOperation, + OperationName: ListCoreV1LimitRangeForAllNamespacesOperation, OperationSummary: "", - OperationID: "listCoreV1Namespace", + OperationID: "listCoreV1LimitRangeForAllNamespaces", Body: nil, Params: middleware.Parameters{ { @@ -22737,6 +26725,10 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo Name: "limit", In: "query", }: params.Limit, + { + Name: "pretty", + In: "query", + }: params.Pretty, { Name: "resourceVersion", In: "query", @@ -22753,18 +26745,14 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo Name: "watch", In: "query", }: params.Watch, - { - Name: "pretty", - In: "query", - }: params.Pretty, }, Raw: r, } type ( Request = struct{} - Params = ListCoreV1NamespaceParams - Response = ListCoreV1NamespaceRes + Params = ListCoreV1LimitRangeForAllNamespacesParams + Response = ListCoreV1LimitRangeForAllNamespacesRes ) response, err = middleware.HookMiddleware[ Request, @@ -22773,14 +26761,14 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo ]( m, mreq, - unpackListCoreV1NamespaceParams, + unpackListCoreV1LimitRangeForAllNamespacesParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1Namespace(ctx, params) + response, err = s.h.ListCoreV1LimitRangeForAllNamespaces(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1Namespace(ctx, params) + response, err = s.h.ListCoreV1LimitRangeForAllNamespaces(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -22788,7 +26776,7 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo return } - if err := encodeListCoreV1NamespaceResponse(response, w, span); err != nil { + if err := encodeListCoreV1LimitRangeForAllNamespacesResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -22797,20 +26785,22 @@ func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bo } } -// handleListCoreV1NamespacedConfigMapRequest handles listCoreV1NamespacedConfigMap operation. +// handleListCoreV1NamespaceRequest handles listCoreV1Namespace operation. // -// List or watch objects of kind ConfigMap. +// List or watch objects of kind Namespace. // -// GET /api/v1/namespaces/{namespace}/configmaps -func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/namespaces +func (s *Server) handleListCoreV1NamespaceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1NamespacedConfigMap"), + otelogen.OperationID("listCoreV1Namespace"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/configmaps"), + semconv.HTTPRouteKey.String("/api/v1/namespaces"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedConfigMapOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespaceOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -22824,7 +26814,16 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22836,20 +26835,39 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1NamespacedConfigMapOperation, - ID: "listCoreV1NamespacedConfigMap", + Name: ListCoreV1NamespaceOperation, + ID: "listCoreV1Namespace", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedConfigMapOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespaceOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -22889,7 +26907,7 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args return } } - params, err := decodeListCoreV1NamespacedConfigMapParams(args, argsEscaped, r) + params, err := decodeListCoreV1NamespaceParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -22900,13 +26918,13 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args return } - var response ListCoreV1NamespacedConfigMapRes + var response ListCoreV1NamespaceRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1NamespacedConfigMapOperation, + OperationName: ListCoreV1NamespaceOperation, OperationSummary: "", - OperationID: "listCoreV1NamespacedConfigMap", + OperationID: "listCoreV1Namespace", Body: nil, Params: middleware.Parameters{ { @@ -22945,10 +26963,6 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args Name: "watch", In: "query", }: params.Watch, - { - Name: "namespace", - In: "path", - }: params.Namespace, { Name: "pretty", In: "query", @@ -22959,8 +26973,8 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args type ( Request = struct{} - Params = ListCoreV1NamespacedConfigMapParams - Response = ListCoreV1NamespacedConfigMapRes + Params = ListCoreV1NamespaceParams + Response = ListCoreV1NamespaceRes ) response, err = middleware.HookMiddleware[ Request, @@ -22969,14 +26983,14 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args ]( m, mreq, - unpackListCoreV1NamespacedConfigMapParams, + unpackListCoreV1NamespaceParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1NamespacedConfigMap(ctx, params) + response, err = s.h.ListCoreV1Namespace(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1NamespacedConfigMap(ctx, params) + response, err = s.h.ListCoreV1Namespace(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -22984,7 +26998,7 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args return } - if err := encodeListCoreV1NamespacedConfigMapResponse(response, w, span); err != nil { + if err := encodeListCoreV1NamespaceResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -22993,20 +27007,22 @@ func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, args } } -// handleListCoreV1NamespacedEndpointsRequest handles listCoreV1NamespacedEndpoints operation. +// handleListCoreV1NamespacedConfigMapRequest handles listCoreV1NamespacedConfigMap operation. // -// List or watch objects of kind Endpoints. +// List or watch objects of kind ConfigMap. // -// GET /api/v1/namespaces/{namespace}/endpoints -func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/namespaces/{namespace}/configmaps +func (s *Server) handleListCoreV1NamespacedConfigMapRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1NamespacedEndpoints"), + otelogen.OperationID("listCoreV1NamespacedConfigMap"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/endpoints"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/configmaps"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedEndpointsOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedConfigMapOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -23020,7 +27036,16 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23032,20 +27057,39 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1NamespacedEndpointsOperation, - ID: "listCoreV1NamespacedEndpoints", + Name: ListCoreV1NamespacedConfigMapOperation, + ID: "listCoreV1NamespacedConfigMap", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedEndpointsOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedConfigMapOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -23085,7 +27129,7 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args return } } - params, err := decodeListCoreV1NamespacedEndpointsParams(args, argsEscaped, r) + params, err := decodeListCoreV1NamespacedConfigMapParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -23096,13 +27140,13 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args return } - var response ListCoreV1NamespacedEndpointsRes + var response ListCoreV1NamespacedConfigMapRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1NamespacedEndpointsOperation, + OperationName: ListCoreV1NamespacedConfigMapOperation, OperationSummary: "", - OperationID: "listCoreV1NamespacedEndpoints", + OperationID: "listCoreV1NamespacedConfigMap", Body: nil, Params: middleware.Parameters{ { @@ -23155,8 +27199,8 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args type ( Request = struct{} - Params = ListCoreV1NamespacedEndpointsParams - Response = ListCoreV1NamespacedEndpointsRes + Params = ListCoreV1NamespacedConfigMapParams + Response = ListCoreV1NamespacedConfigMapRes ) response, err = middleware.HookMiddleware[ Request, @@ -23165,14 +27209,14 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args ]( m, mreq, - unpackListCoreV1NamespacedEndpointsParams, + unpackListCoreV1NamespacedConfigMapParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1NamespacedEndpoints(ctx, params) + response, err = s.h.ListCoreV1NamespacedConfigMap(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1NamespacedEndpoints(ctx, params) + response, err = s.h.ListCoreV1NamespacedConfigMap(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -23180,7 +27224,7 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args return } - if err := encodeListCoreV1NamespacedEndpointsResponse(response, w, span); err != nil { + if err := encodeListCoreV1NamespacedConfigMapResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -23189,20 +27233,22 @@ func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, args } } -// handleListCoreV1NamespacedEventRequest handles listCoreV1NamespacedEvent operation. +// handleListCoreV1NamespacedEndpointsRequest handles listCoreV1NamespacedEndpoints operation. // -// List or watch objects of kind Event. +// List or watch objects of kind Endpoints. // -// GET /api/v1/namespaces/{namespace}/events -func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/namespaces/{namespace}/endpoints +func (s *Server) handleListCoreV1NamespacedEndpointsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1NamespacedEvent"), + otelogen.OperationID("listCoreV1NamespacedEndpoints"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/events"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/endpoints"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedEventOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedEndpointsOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -23216,7 +27262,16 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23228,20 +27283,39 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1NamespacedEventOperation, - ID: "listCoreV1NamespacedEvent", + Name: ListCoreV1NamespacedEndpointsOperation, + ID: "listCoreV1NamespacedEndpoints", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedEventOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedEndpointsOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -23281,7 +27355,7 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca return } } - params, err := decodeListCoreV1NamespacedEventParams(args, argsEscaped, r) + params, err := decodeListCoreV1NamespacedEndpointsParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -23292,13 +27366,13 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca return } - var response ListCoreV1NamespacedEventRes + var response ListCoreV1NamespacedEndpointsRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1NamespacedEventOperation, + OperationName: ListCoreV1NamespacedEndpointsOperation, OperationSummary: "", - OperationID: "listCoreV1NamespacedEvent", + OperationID: "listCoreV1NamespacedEndpoints", Body: nil, Params: middleware.Parameters{ { @@ -23351,8 +27425,8 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca type ( Request = struct{} - Params = ListCoreV1NamespacedEventParams - Response = ListCoreV1NamespacedEventRes + Params = ListCoreV1NamespacedEndpointsParams + Response = ListCoreV1NamespacedEndpointsRes ) response, err = middleware.HookMiddleware[ Request, @@ -23361,14 +27435,14 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca ]( m, mreq, - unpackListCoreV1NamespacedEventParams, + unpackListCoreV1NamespacedEndpointsParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1NamespacedEvent(ctx, params) + response, err = s.h.ListCoreV1NamespacedEndpoints(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1NamespacedEvent(ctx, params) + response, err = s.h.ListCoreV1NamespacedEndpoints(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -23376,7 +27450,7 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca return } - if err := encodeListCoreV1NamespacedEventResponse(response, w, span); err != nil { + if err := encodeListCoreV1NamespacedEndpointsResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -23385,20 +27459,22 @@ func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEsca } } -// handleListCoreV1NamespacedLimitRangeRequest handles listCoreV1NamespacedLimitRange operation. +// handleListCoreV1NamespacedEventRequest handles listCoreV1NamespacedEvent operation. // -// List or watch objects of kind LimitRange. +// List or watch objects of kind Event. // -// GET /api/v1/namespaces/{namespace}/limitranges -func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/namespaces/{namespace}/events +func (s *Server) handleListCoreV1NamespacedEventRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1NamespacedLimitRange"), + otelogen.OperationID("listCoreV1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/limitranges"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/events"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedLimitRangeOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedEventOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -23412,7 +27488,16 @@ func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23424,20 +27509,39 @@ func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1NamespacedLimitRangeOperation, - ID: "listCoreV1NamespacedLimitRange", + Name: ListCoreV1NamespacedEventOperation, + ID: "listCoreV1NamespacedEvent", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedLimitRangeOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedEventOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -23477,7 +27581,7 @@ func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, arg return } } - params, err := decodeListCoreV1NamespacedLimitRangeParams(args, argsEscaped, r) + params, err := decodeListCoreV1NamespacedEventParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -23488,13 +27592,239 @@ func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, arg return } - var response ListCoreV1NamespacedLimitRangeRes + var response ListCoreV1NamespacedEventRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1NamespacedLimitRangeOperation, + OperationName: ListCoreV1NamespacedEventOperation, OperationSummary: "", - OperationID: "listCoreV1NamespacedLimitRange", + OperationID: "listCoreV1NamespacedEvent", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListCoreV1NamespacedEventParams + Response = ListCoreV1NamespacedEventRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListCoreV1NamespacedEventParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListCoreV1NamespacedEvent(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListCoreV1NamespacedEvent(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListCoreV1NamespacedEventResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleListCoreV1NamespacedLimitRangeRequest handles listCoreV1NamespacedLimitRange operation. +// +// List or watch objects of kind LimitRange. +// +// GET /api/v1/namespaces/{namespace}/limitranges +func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listCoreV1NamespacedLimitRange"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/limitranges"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1NamespacedLimitRangeOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ListCoreV1NamespacedLimitRangeOperation, + ID: "listCoreV1NamespacedLimitRange", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1NamespacedLimitRangeOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeListCoreV1NamespacedLimitRangeParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListCoreV1NamespacedLimitRangeRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ListCoreV1NamespacedLimitRangeOperation, + OperationSummary: "", + OperationID: "listCoreV1NamespacedLimitRange", Body: nil, Params: middleware.Parameters{ { @@ -23587,6 +27917,8 @@ func (s *Server) handleListCoreV1NamespacedLimitRangeRequest(args [1]string, arg // // GET /api/v1/namespaces/{namespace}/persistentvolumeclaims func (s *Server) handleListCoreV1NamespacedPersistentVolumeClaimRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedPersistentVolumeClaim"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23608,7 +27940,16 @@ func (s *Server) handleListCoreV1NamespacedPersistentVolumeClaimRequest(args [1] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23620,8 +27961,27 @@ func (s *Server) handleListCoreV1NamespacedPersistentVolumeClaimRequest(args [1] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23783,6 +28143,8 @@ func (s *Server) handleListCoreV1NamespacedPersistentVolumeClaimRequest(args [1] // // GET /api/v1/namespaces/{namespace}/pods func (s *Server) handleListCoreV1NamespacedPodRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedPod"), semconv.HTTPRequestMethodKey.String("GET"), @@ -23804,7 +28166,16 @@ func (s *Server) handleListCoreV1NamespacedPodRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23816,8 +28187,27 @@ func (s *Server) handleListCoreV1NamespacedPodRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23979,6 +28369,8 @@ func (s *Server) handleListCoreV1NamespacedPodRequest(args [1]string, argsEscape // // GET /api/v1/namespaces/{namespace}/podtemplates func (s *Server) handleListCoreV1NamespacedPodTemplateRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedPodTemplate"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24000,7 +28392,16 @@ func (s *Server) handleListCoreV1NamespacedPodTemplateRequest(args [1]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24012,8 +28413,27 @@ func (s *Server) handleListCoreV1NamespacedPodTemplateRequest(args [1]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24175,6 +28595,8 @@ func (s *Server) handleListCoreV1NamespacedPodTemplateRequest(args [1]string, ar // // GET /api/v1/namespaces/{namespace}/replicationcontrollers func (s *Server) handleListCoreV1NamespacedReplicationControllerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedReplicationController"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24196,7 +28618,16 @@ func (s *Server) handleListCoreV1NamespacedReplicationControllerRequest(args [1] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24208,8 +28639,27 @@ func (s *Server) handleListCoreV1NamespacedReplicationControllerRequest(args [1] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24371,6 +28821,8 @@ func (s *Server) handleListCoreV1NamespacedReplicationControllerRequest(args [1] // // GET /api/v1/namespaces/{namespace}/resourcequotas func (s *Server) handleListCoreV1NamespacedResourceQuotaRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedResourceQuota"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24392,7 +28844,16 @@ func (s *Server) handleListCoreV1NamespacedResourceQuotaRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24404,8 +28865,27 @@ func (s *Server) handleListCoreV1NamespacedResourceQuotaRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24567,6 +29047,8 @@ func (s *Server) handleListCoreV1NamespacedResourceQuotaRequest(args [1]string, // // GET /api/v1/namespaces/{namespace}/secrets func (s *Server) handleListCoreV1NamespacedSecretRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedSecret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24588,7 +29070,16 @@ func (s *Server) handleListCoreV1NamespacedSecretRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24600,8 +29091,27 @@ func (s *Server) handleListCoreV1NamespacedSecretRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24763,6 +29273,8 @@ func (s *Server) handleListCoreV1NamespacedSecretRequest(args [1]string, argsEsc // // GET /api/v1/namespaces/{namespace}/services func (s *Server) handleListCoreV1NamespacedServiceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedService"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24784,7 +29296,16 @@ func (s *Server) handleListCoreV1NamespacedServiceRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24796,8 +29317,27 @@ func (s *Server) handleListCoreV1NamespacedServiceRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24959,6 +29499,8 @@ func (s *Server) handleListCoreV1NamespacedServiceRequest(args [1]string, argsEs // // GET /api/v1/namespaces/{namespace}/serviceaccounts func (s *Server) handleListCoreV1NamespacedServiceAccountRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1NamespacedServiceAccount"), semconv.HTTPRequestMethodKey.String("GET"), @@ -24980,7 +29522,16 @@ func (s *Server) handleListCoreV1NamespacedServiceAccountRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24992,8 +29543,27 @@ func (s *Server) handleListCoreV1NamespacedServiceAccountRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25155,6 +29725,8 @@ func (s *Server) handleListCoreV1NamespacedServiceAccountRequest(args [1]string, // // GET /api/v1/nodes func (s *Server) handleListCoreV1NodeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1Node"), semconv.HTTPRequestMethodKey.String("GET"), @@ -25176,7 +29748,16 @@ func (s *Server) handleListCoreV1NodeRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25188,8 +29769,27 @@ func (s *Server) handleListCoreV1NodeRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25347,6 +29947,8 @@ func (s *Server) handleListCoreV1NodeRequest(args [0]string, argsEscaped bool, w // // GET /api/v1/persistentvolumes func (s *Server) handleListCoreV1PersistentVolumeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1PersistentVolume"), semconv.HTTPRequestMethodKey.String("GET"), @@ -25368,7 +29970,16 @@ func (s *Server) handleListCoreV1PersistentVolumeRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25380,8 +29991,27 @@ func (s *Server) handleListCoreV1PersistentVolumeRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25539,6 +30169,8 @@ func (s *Server) handleListCoreV1PersistentVolumeRequest(args [0]string, argsEsc // // GET /api/v1/persistentvolumeclaims func (s *Server) handleListCoreV1PersistentVolumeClaimForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1PersistentVolumeClaimForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -25560,7 +30192,16 @@ func (s *Server) handleListCoreV1PersistentVolumeClaimForAllNamespacesRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25572,8 +30213,27 @@ func (s *Server) handleListCoreV1PersistentVolumeClaimForAllNamespacesRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25731,6 +30391,8 @@ func (s *Server) handleListCoreV1PersistentVolumeClaimForAllNamespacesRequest(ar // // GET /api/v1/pods func (s *Server) handleListCoreV1PodForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1PodForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -25752,7 +30414,16 @@ func (s *Server) handleListCoreV1PodForAllNamespacesRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25764,8 +30435,27 @@ func (s *Server) handleListCoreV1PodForAllNamespacesRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25923,6 +30613,8 @@ func (s *Server) handleListCoreV1PodForAllNamespacesRequest(args [0]string, args // // GET /api/v1/podtemplates func (s *Server) handleListCoreV1PodTemplateForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1PodTemplateForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -25944,7 +30636,16 @@ func (s *Server) handleListCoreV1PodTemplateForAllNamespacesRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25956,8 +30657,27 @@ func (s *Server) handleListCoreV1PodTemplateForAllNamespacesRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26115,6 +30835,8 @@ func (s *Server) handleListCoreV1PodTemplateForAllNamespacesRequest(args [0]stri // // GET /api/v1/replicationcontrollers func (s *Server) handleListCoreV1ReplicationControllerForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1ReplicationControllerForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26136,7 +30858,16 @@ func (s *Server) handleListCoreV1ReplicationControllerForAllNamespacesRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26148,8 +30879,27 @@ func (s *Server) handleListCoreV1ReplicationControllerForAllNamespacesRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26307,6 +31057,8 @@ func (s *Server) handleListCoreV1ReplicationControllerForAllNamespacesRequest(ar // // GET /api/v1/resourcequotas func (s *Server) handleListCoreV1ResourceQuotaForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1ResourceQuotaForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26328,7 +31080,16 @@ func (s *Server) handleListCoreV1ResourceQuotaForAllNamespacesRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26340,8 +31101,27 @@ func (s *Server) handleListCoreV1ResourceQuotaForAllNamespacesRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26499,6 +31279,8 @@ func (s *Server) handleListCoreV1ResourceQuotaForAllNamespacesRequest(args [0]st // // GET /api/v1/secrets func (s *Server) handleListCoreV1SecretForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listCoreV1SecretForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -26520,7 +31302,16 @@ func (s *Server) handleListCoreV1SecretForAllNamespacesRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26532,212 +31323,39 @@ func (s *Server) handleListCoreV1SecretForAllNamespacesRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1SecretForAllNamespacesOperation, - ID: "listCoreV1SecretForAllNamespaces", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1SecretForAllNamespacesOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeListCoreV1SecretForAllNamespacesParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - var response ListCoreV1SecretForAllNamespacesRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ListCoreV1SecretForAllNamespacesOperation, - OperationSummary: "", - OperationID: "listCoreV1SecretForAllNamespaces", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "pretty", - In: "query", - }: params.Pretty, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ListCoreV1SecretForAllNamespacesParams - Response = ListCoreV1SecretForAllNamespacesRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackListCoreV1SecretForAllNamespacesParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1SecretForAllNamespaces(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ListCoreV1SecretForAllNamespaces(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeListCoreV1SecretForAllNamespacesResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleListCoreV1ServiceAccountForAllNamespacesRequest handles listCoreV1ServiceAccountForAllNamespaces operation. -// -// List or watch objects of kind ServiceAccount. -// -// GET /api/v1/serviceaccounts -func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1ServiceAccountForAllNamespaces"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/serviceaccounts"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1ServiceAccountForAllNamespacesOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1ServiceAccountForAllNamespacesOperation, - ID: "listCoreV1ServiceAccountForAllNamespaces", + Name: ListCoreV1SecretForAllNamespacesOperation, + ID: "listCoreV1SecretForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1ServiceAccountForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1SecretForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -26777,7 +31395,7 @@ func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]s return } } - params, err := decodeListCoreV1ServiceAccountForAllNamespacesParams(args, argsEscaped, r) + params, err := decodeListCoreV1SecretForAllNamespacesParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -26788,13 +31406,13 @@ func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]s return } - var response ListCoreV1ServiceAccountForAllNamespacesRes + var response ListCoreV1SecretForAllNamespacesRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1ServiceAccountForAllNamespacesOperation, + OperationName: ListCoreV1SecretForAllNamespacesOperation, OperationSummary: "", - OperationID: "listCoreV1ServiceAccountForAllNamespaces", + OperationID: "listCoreV1SecretForAllNamespaces", Body: nil, Params: middleware.Parameters{ { @@ -26843,8 +31461,8 @@ func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]s type ( Request = struct{} - Params = ListCoreV1ServiceAccountForAllNamespacesParams - Response = ListCoreV1ServiceAccountForAllNamespacesRes + Params = ListCoreV1SecretForAllNamespacesParams + Response = ListCoreV1SecretForAllNamespacesRes ) response, err = middleware.HookMiddleware[ Request, @@ -26853,14 +31471,14 @@ func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]s ]( m, mreq, - unpackListCoreV1ServiceAccountForAllNamespacesParams, + unpackListCoreV1SecretForAllNamespacesParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1ServiceAccountForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1SecretForAllNamespaces(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1ServiceAccountForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1SecretForAllNamespaces(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -26868,7 +31486,7 @@ func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]s return } - if err := encodeListCoreV1ServiceAccountForAllNamespacesResponse(response, w, span); err != nil { + if err := encodeListCoreV1SecretForAllNamespacesResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -26877,20 +31495,22 @@ func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]s } } -// handleListCoreV1ServiceForAllNamespacesRequest handles listCoreV1ServiceForAllNamespaces operation. +// handleListCoreV1ServiceAccountForAllNamespacesRequest handles listCoreV1ServiceAccountForAllNamespaces operation. // -// List or watch objects of kind Service. +// List or watch objects of kind ServiceAccount. // -// GET /api/v1/services -func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/serviceaccounts +func (s *Server) handleListCoreV1ServiceAccountForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listCoreV1ServiceForAllNamespaces"), + otelogen.OperationID("listCoreV1ServiceAccountForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/services"), + semconv.HTTPRouteKey.String("/api/v1/serviceaccounts"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1ServiceForAllNamespacesOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1ServiceAccountForAllNamespacesOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -26904,7 +31524,16 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26916,20 +31545,39 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListCoreV1ServiceForAllNamespacesOperation, - ID: "listCoreV1ServiceForAllNamespaces", + Name: ListCoreV1ServiceAccountForAllNamespacesOperation, + ID: "listCoreV1ServiceAccountForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1ServiceForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1ServiceAccountForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -26969,7 +31617,7 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, return } } - params, err := decodeListCoreV1ServiceForAllNamespacesParams(args, argsEscaped, r) + params, err := decodeListCoreV1ServiceAccountForAllNamespacesParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -26980,13 +31628,13 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, return } - var response ListCoreV1ServiceForAllNamespacesRes + var response ListCoreV1ServiceAccountForAllNamespacesRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListCoreV1ServiceForAllNamespacesOperation, + OperationName: ListCoreV1ServiceAccountForAllNamespacesOperation, OperationSummary: "", - OperationID: "listCoreV1ServiceForAllNamespaces", + OperationID: "listCoreV1ServiceAccountForAllNamespaces", Body: nil, Params: middleware.Parameters{ { @@ -27035,8 +31683,8 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, type ( Request = struct{} - Params = ListCoreV1ServiceForAllNamespacesParams - Response = ListCoreV1ServiceForAllNamespacesRes + Params = ListCoreV1ServiceAccountForAllNamespacesParams + Response = ListCoreV1ServiceAccountForAllNamespacesRes ) response, err = middleware.HookMiddleware[ Request, @@ -27045,14 +31693,14 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, ]( m, mreq, - unpackListCoreV1ServiceForAllNamespacesParams, + unpackListCoreV1ServiceAccountForAllNamespacesParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListCoreV1ServiceForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1ServiceAccountForAllNamespaces(ctx, params) return response, err }, ) } else { - response, err = s.h.ListCoreV1ServiceForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1ServiceAccountForAllNamespaces(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -27060,7 +31708,7 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, return } - if err := encodeListCoreV1ServiceForAllNamespacesResponse(response, w, span); err != nil { + if err := encodeListCoreV1ServiceAccountForAllNamespacesResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -27069,20 +31717,22 @@ func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, } } -// handleListDiscoveryV1EndpointSliceForAllNamespacesRequest handles listDiscoveryV1EndpointSliceForAllNamespaces operation. +// handleListCoreV1ServiceForAllNamespacesRequest handles listCoreV1ServiceForAllNamespaces operation. // -// List or watch objects of kind EndpointSlice. +// List or watch objects of kind Service. // -// GET /apis/discovery.k8s.io/v1/endpointslices -func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /api/v1/services +func (s *Server) handleListCoreV1ServiceForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listDiscoveryV1EndpointSliceForAllNamespaces"), + otelogen.OperationID("listCoreV1ServiceForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1/endpointslices"), + semconv.HTTPRouteKey.String("/api/v1/services"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1EndpointSliceForAllNamespacesOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListCoreV1ServiceForAllNamespacesOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -27096,7 +31746,16 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27108,20 +31767,39 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListDiscoveryV1EndpointSliceForAllNamespacesOperation, - ID: "listDiscoveryV1EndpointSliceForAllNamespaces", + Name: ListCoreV1ServiceForAllNamespacesOperation, + ID: "listCoreV1ServiceForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1EndpointSliceForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListCoreV1ServiceForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -27161,7 +31839,7 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args return } } - params, err := decodeListDiscoveryV1EndpointSliceForAllNamespacesParams(args, argsEscaped, r) + params, err := decodeListCoreV1ServiceForAllNamespacesParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -27172,13 +31850,13 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args return } - var response ListDiscoveryV1EndpointSliceForAllNamespacesRes + var response ListCoreV1ServiceForAllNamespacesRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListDiscoveryV1EndpointSliceForAllNamespacesOperation, + OperationName: ListCoreV1ServiceForAllNamespacesOperation, OperationSummary: "", - OperationID: "listDiscoveryV1EndpointSliceForAllNamespaces", + OperationID: "listCoreV1ServiceForAllNamespaces", Body: nil, Params: middleware.Parameters{ { @@ -27227,8 +31905,8 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args type ( Request = struct{} - Params = ListDiscoveryV1EndpointSliceForAllNamespacesParams - Response = ListDiscoveryV1EndpointSliceForAllNamespacesRes + Params = ListCoreV1ServiceForAllNamespacesParams + Response = ListCoreV1ServiceForAllNamespacesRes ) response, err = middleware.HookMiddleware[ Request, @@ -27237,14 +31915,14 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args ]( m, mreq, - unpackListDiscoveryV1EndpointSliceForAllNamespacesParams, + unpackListCoreV1ServiceForAllNamespacesParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListDiscoveryV1EndpointSliceForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1ServiceForAllNamespaces(ctx, params) return response, err }, ) } else { - response, err = s.h.ListDiscoveryV1EndpointSliceForAllNamespaces(ctx, params) + response, err = s.h.ListCoreV1ServiceForAllNamespaces(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -27252,7 +31930,7 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args return } - if err := encodeListDiscoveryV1EndpointSliceForAllNamespacesResponse(response, w, span); err != nil { + if err := encodeListCoreV1ServiceForAllNamespacesResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -27261,20 +31939,22 @@ func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args } } -// handleListDiscoveryV1NamespacedEndpointSliceRequest handles listDiscoveryV1NamespacedEndpointSlice operation. +// handleListDiscoveryV1EndpointSliceForAllNamespacesRequest handles listDiscoveryV1EndpointSliceForAllNamespaces operation. // // List or watch objects of kind EndpointSlice. // -// GET /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices -func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /apis/discovery.k8s.io/v1/endpointslices +func (s *Server) handleListDiscoveryV1EndpointSliceForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listDiscoveryV1NamespacedEndpointSlice"), + otelogen.OperationID("listDiscoveryV1EndpointSliceForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices"), + semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1/endpointslices"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1NamespacedEndpointSliceOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1EndpointSliceForAllNamespacesOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -27288,7 +31968,16 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27300,20 +31989,39 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListDiscoveryV1NamespacedEndpointSliceOperation, - ID: "listDiscoveryV1NamespacedEndpointSlice", + Name: ListDiscoveryV1EndpointSliceForAllNamespacesOperation, + ID: "listDiscoveryV1EndpointSliceForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1NamespacedEndpointSliceOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1EndpointSliceForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -27353,7 +32061,7 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str return } } - params, err := decodeListDiscoveryV1NamespacedEndpointSliceParams(args, argsEscaped, r) + params, err := decodeListDiscoveryV1EndpointSliceForAllNamespacesParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -27364,13 +32072,13 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str return } - var response ListDiscoveryV1NamespacedEndpointSliceRes + var response ListDiscoveryV1EndpointSliceForAllNamespacesRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListDiscoveryV1NamespacedEndpointSliceOperation, + OperationName: ListDiscoveryV1EndpointSliceForAllNamespacesOperation, OperationSummary: "", - OperationID: "listDiscoveryV1NamespacedEndpointSlice", + OperationID: "listDiscoveryV1EndpointSliceForAllNamespaces", Body: nil, Params: middleware.Parameters{ { @@ -27393,6 +32101,10 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str Name: "limit", In: "query", }: params.Limit, + { + Name: "pretty", + In: "query", + }: params.Pretty, { Name: "resourceVersion", In: "query", @@ -27409,22 +32121,14 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str Name: "watch", In: "query", }: params.Watch, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "pretty", - In: "query", - }: params.Pretty, }, Raw: r, } type ( Request = struct{} - Params = ListDiscoveryV1NamespacedEndpointSliceParams - Response = ListDiscoveryV1NamespacedEndpointSliceRes + Params = ListDiscoveryV1EndpointSliceForAllNamespacesParams + Response = ListDiscoveryV1EndpointSliceForAllNamespacesRes ) response, err = middleware.HookMiddleware[ Request, @@ -27433,14 +32137,14 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str ]( m, mreq, - unpackListDiscoveryV1NamespacedEndpointSliceParams, + unpackListDiscoveryV1EndpointSliceForAllNamespacesParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListDiscoveryV1NamespacedEndpointSlice(ctx, params) + response, err = s.h.ListDiscoveryV1EndpointSliceForAllNamespaces(ctx, params) return response, err }, ) } else { - response, err = s.h.ListDiscoveryV1NamespacedEndpointSlice(ctx, params) + response, err = s.h.ListDiscoveryV1EndpointSliceForAllNamespaces(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -27448,7 +32152,7 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str return } - if err := encodeListDiscoveryV1NamespacedEndpointSliceResponse(response, w, span); err != nil { + if err := encodeListDiscoveryV1EndpointSliceForAllNamespacesResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -27457,20 +32161,22 @@ func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]str } } -// handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest handles listDiscoveryV1beta1EndpointSliceForAllNamespaces operation. +// handleListDiscoveryV1NamespacedEndpointSliceRequest handles listDiscoveryV1NamespacedEndpointSlice operation. // // List or watch objects of kind EndpointSlice. // -// GET /apis/discovery.k8s.io/v1beta1/endpointslices -func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices +func (s *Server) handleListDiscoveryV1NamespacedEndpointSliceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listDiscoveryV1beta1EndpointSliceForAllNamespaces"), + otelogen.OperationID("listDiscoveryV1NamespacedEndpointSlice"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1beta1/endpointslices"), + semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1NamespacedEndpointSliceOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -27484,7 +32190,16 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27496,20 +32211,39 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, - ID: "listDiscoveryV1beta1EndpointSliceForAllNamespaces", + Name: ListDiscoveryV1NamespacedEndpointSliceOperation, + ID: "listDiscoveryV1NamespacedEndpointSlice", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1NamespacedEndpointSliceOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -27549,7 +32283,7 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( return } } - params, err := decodeListDiscoveryV1beta1EndpointSliceForAllNamespacesParams(args, argsEscaped, r) + params, err := decodeListDiscoveryV1NamespacedEndpointSliceParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ OperationContext: opErrContext, @@ -27560,13 +32294,13 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( return } - var response ListDiscoveryV1beta1EndpointSliceForAllNamespacesRes + var response ListDiscoveryV1NamespacedEndpointSliceRes if m := s.cfg.Middleware; m != nil { mreq := middleware.Request{ Context: ctx, - OperationName: ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, + OperationName: ListDiscoveryV1NamespacedEndpointSliceOperation, OperationSummary: "", - OperationID: "listDiscoveryV1beta1EndpointSliceForAllNamespaces", + OperationID: "listDiscoveryV1NamespacedEndpointSlice", Body: nil, Params: middleware.Parameters{ { @@ -27589,10 +32323,6 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( Name: "limit", In: "query", }: params.Limit, - { - Name: "pretty", - In: "query", - }: params.Pretty, { Name: "resourceVersion", In: "query", @@ -27609,14 +32339,22 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( Name: "watch", In: "query", }: params.Watch, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "pretty", + In: "query", + }: params.Pretty, }, Raw: r, } type ( Request = struct{} - Params = ListDiscoveryV1beta1EndpointSliceForAllNamespacesParams - Response = ListDiscoveryV1beta1EndpointSliceForAllNamespacesRes + Params = ListDiscoveryV1NamespacedEndpointSliceParams + Response = ListDiscoveryV1NamespacedEndpointSliceRes ) response, err = middleware.HookMiddleware[ Request, @@ -27625,14 +32363,14 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( ]( m, mreq, - unpackListDiscoveryV1beta1EndpointSliceForAllNamespacesParams, + unpackListDiscoveryV1NamespacedEndpointSliceParams, func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListDiscoveryV1beta1EndpointSliceForAllNamespaces(ctx, params) + response, err = s.h.ListDiscoveryV1NamespacedEndpointSlice(ctx, params) return response, err }, ) } else { - response, err = s.h.ListDiscoveryV1beta1EndpointSliceForAllNamespaces(ctx, params) + response, err = s.h.ListDiscoveryV1NamespacedEndpointSlice(ctx, params) } if err != nil { defer recordError("Internal", err) @@ -27640,7 +32378,7 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( return } - if err := encodeListDiscoveryV1beta1EndpointSliceForAllNamespacesResponse(response, w, span); err != nil { + if err := encodeListDiscoveryV1NamespacedEndpointSliceResponse(response, w, span); err != nil { defer recordError("EncodeResponse", err) if !errors.Is(err, ht.ErrInternalServerErrorResponse) { s.cfg.ErrorHandler(ctx, w, r, err) @@ -27649,20 +32387,22 @@ func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest( } } -// handleListDiscoveryV1beta1NamespacedEndpointSliceRequest handles listDiscoveryV1beta1NamespacedEndpointSlice operation. +// handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest handles listDiscoveryV1beta1EndpointSliceForAllNamespaces operation. // // List or watch objects of kind EndpointSlice. // -// GET /apis/discovery.k8s.io/v1beta1/namespaces/{namespace}/endpointslices -func (s *Server) handleListDiscoveryV1beta1NamespacedEndpointSliceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { +// GET /apis/discovery.k8s.io/v1beta1/endpointslices +func (s *Server) handleListDiscoveryV1beta1EndpointSliceForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listDiscoveryV1beta1NamespacedEndpointSlice"), + otelogen.OperationID("listDiscoveryV1beta1EndpointSliceForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1beta1/namespaces/{namespace}/endpointslices"), + semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1beta1/endpointslices"), } // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1beta1NamespacedEndpointSliceOperation, + ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, trace.WithAttributes(otelAttrs...), serverSpanKind, ) @@ -27676,7 +32416,16 @@ func (s *Server) handleListDiscoveryV1beta1NamespacedEndpointSliceRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27688,20 +32437,261 @@ func (s *Server) handleListDiscoveryV1beta1NamespacedEndpointSliceRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListDiscoveryV1beta1NamespacedEndpointSliceOperation, - ID: "listDiscoveryV1beta1NamespacedEndpointSlice", + Name: ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, + ID: "listDiscoveryV1beta1EndpointSliceForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1beta1NamespacedEndpointSliceOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeListDiscoveryV1beta1EndpointSliceForAllNamespacesParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListDiscoveryV1beta1EndpointSliceForAllNamespacesRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ListDiscoveryV1beta1EndpointSliceForAllNamespacesOperation, + OperationSummary: "", + OperationID: "listDiscoveryV1beta1EndpointSliceForAllNamespaces", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "pretty", + In: "query", + }: params.Pretty, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListDiscoveryV1beta1EndpointSliceForAllNamespacesParams + Response = ListDiscoveryV1beta1EndpointSliceForAllNamespacesRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListDiscoveryV1beta1EndpointSliceForAllNamespacesParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListDiscoveryV1beta1EndpointSliceForAllNamespaces(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListDiscoveryV1beta1EndpointSliceForAllNamespaces(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListDiscoveryV1beta1EndpointSliceForAllNamespacesResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleListDiscoveryV1beta1NamespacedEndpointSliceRequest handles listDiscoveryV1beta1NamespacedEndpointSlice operation. +// +// List or watch objects of kind EndpointSlice. +// +// GET /apis/discovery.k8s.io/v1beta1/namespaces/{namespace}/endpointslices +func (s *Server) handleListDiscoveryV1beta1NamespacedEndpointSliceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listDiscoveryV1beta1NamespacedEndpointSlice"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/discovery.k8s.io/v1beta1/namespaces/{namespace}/endpointslices"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ListDiscoveryV1beta1NamespacedEndpointSliceOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ListDiscoveryV1beta1NamespacedEndpointSliceOperation, + ID: "listDiscoveryV1beta1NamespacedEndpointSlice", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ListDiscoveryV1beta1NamespacedEndpointSliceOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -27851,6 +32841,8 @@ func (s *Server) handleListDiscoveryV1beta1NamespacedEndpointSliceRequest(args [ // // GET /apis/events.k8s.io/v1/events func (s *Server) handleListEventsV1EventForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listEventsV1EventForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -27872,7 +32864,16 @@ func (s *Server) handleListEventsV1EventForAllNamespacesRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27884,8 +32885,27 @@ func (s *Server) handleListEventsV1EventForAllNamespacesRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28043,6 +33063,8 @@ func (s *Server) handleListEventsV1EventForAllNamespacesRequest(args [0]string, // // GET /apis/events.k8s.io/v1/namespaces/{namespace}/events func (s *Server) handleListEventsV1NamespacedEventRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listEventsV1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -28064,7 +33086,16 @@ func (s *Server) handleListEventsV1NamespacedEventRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28076,8 +33107,27 @@ func (s *Server) handleListEventsV1NamespacedEventRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28239,6 +33289,8 @@ func (s *Server) handleListEventsV1NamespacedEventRequest(args [1]string, argsEs // // GET /apis/events.k8s.io/v1beta1/events func (s *Server) handleListEventsV1beta1EventForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listEventsV1beta1EventForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -28260,7 +33312,16 @@ func (s *Server) handleListEventsV1beta1EventForAllNamespacesRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28272,8 +33333,27 @@ func (s *Server) handleListEventsV1beta1EventForAllNamespacesRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28431,6 +33511,8 @@ func (s *Server) handleListEventsV1beta1EventForAllNamespacesRequest(args [0]str // // GET /apis/events.k8s.io/v1beta1/namespaces/{namespace}/events func (s *Server) handleListEventsV1beta1NamespacedEventRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listEventsV1beta1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -28452,7 +33534,16 @@ func (s *Server) handleListEventsV1beta1NamespacedEventRequest(args [1]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28464,8 +33555,27 @@ func (s *Server) handleListEventsV1beta1NamespacedEventRequest(args [1]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28627,6 +33737,8 @@ func (s *Server) handleListEventsV1beta1NamespacedEventRequest(args [1]string, a // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/flowschemas func (s *Server) handleListFlowcontrolApiserverV1beta1FlowSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFlowcontrolApiserverV1beta1FlowSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -28648,7 +33760,16 @@ func (s *Server) handleListFlowcontrolApiserverV1beta1FlowSchemaRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28660,8 +33781,27 @@ func (s *Server) handleListFlowcontrolApiserverV1beta1FlowSchemaRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28819,6 +33959,8 @@ func (s *Server) handleListFlowcontrolApiserverV1beta1FlowSchemaRequest(args [0] // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/prioritylevelconfigurations func (s *Server) handleListFlowcontrolApiserverV1beta1PriorityLevelConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFlowcontrolApiserverV1beta1PriorityLevelConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -28840,7 +33982,16 @@ func (s *Server) handleListFlowcontrolApiserverV1beta1PriorityLevelConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28852,8 +34003,27 @@ func (s *Server) handleListFlowcontrolApiserverV1beta1PriorityLevelConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29011,6 +34181,8 @@ func (s *Server) handleListFlowcontrolApiserverV1beta1PriorityLevelConfiguration // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/flowschemas func (s *Server) handleListFlowcontrolApiserverV1beta2FlowSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFlowcontrolApiserverV1beta2FlowSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29032,7 +34204,16 @@ func (s *Server) handleListFlowcontrolApiserverV1beta2FlowSchemaRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29044,8 +34225,27 @@ func (s *Server) handleListFlowcontrolApiserverV1beta2FlowSchemaRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29203,6 +34403,8 @@ func (s *Server) handleListFlowcontrolApiserverV1beta2FlowSchemaRequest(args [0] // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/prioritylevelconfigurations func (s *Server) handleListFlowcontrolApiserverV1beta2PriorityLevelConfigurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFlowcontrolApiserverV1beta2PriorityLevelConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29224,7 +34426,16 @@ func (s *Server) handleListFlowcontrolApiserverV1beta2PriorityLevelConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29236,8 +34447,27 @@ func (s *Server) handleListFlowcontrolApiserverV1beta2PriorityLevelConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29395,6 +34625,8 @@ func (s *Server) handleListFlowcontrolApiserverV1beta2PriorityLevelConfiguration // // GET /apis/internal.apiserver.k8s.io/v1alpha1/storageversions func (s *Server) handleListInternalApiserverV1alpha1StorageVersionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listInternalApiserverV1alpha1StorageVersion"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29416,7 +34648,16 @@ func (s *Server) handleListInternalApiserverV1alpha1StorageVersionRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29428,8 +34669,27 @@ func (s *Server) handleListInternalApiserverV1alpha1StorageVersionRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29587,6 +34847,8 @@ func (s *Server) handleListInternalApiserverV1alpha1StorageVersionRequest(args [ // // GET /apis/networking.k8s.io/v1/ingressclasses func (s *Server) handleListNetworkingV1IngressClassRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNetworkingV1IngressClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29608,7 +34870,16 @@ func (s *Server) handleListNetworkingV1IngressClassRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29620,8 +34891,27 @@ func (s *Server) handleListNetworkingV1IngressClassRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29779,6 +35069,8 @@ func (s *Server) handleListNetworkingV1IngressClassRequest(args [0]string, argsE // // GET /apis/networking.k8s.io/v1/ingresses func (s *Server) handleListNetworkingV1IngressForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNetworkingV1IngressForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29800,7 +35092,16 @@ func (s *Server) handleListNetworkingV1IngressForAllNamespacesRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29812,8 +35113,27 @@ func (s *Server) handleListNetworkingV1IngressForAllNamespacesRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29971,6 +35291,8 @@ func (s *Server) handleListNetworkingV1IngressForAllNamespacesRequest(args [0]st // // GET /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses func (s *Server) handleListNetworkingV1NamespacedIngressRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNetworkingV1NamespacedIngress"), semconv.HTTPRequestMethodKey.String("GET"), @@ -29992,7 +35314,16 @@ func (s *Server) handleListNetworkingV1NamespacedIngressRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30004,8 +35335,27 @@ func (s *Server) handleListNetworkingV1NamespacedIngressRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30167,6 +35517,8 @@ func (s *Server) handleListNetworkingV1NamespacedIngressRequest(args [1]string, // // GET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies func (s *Server) handleListNetworkingV1NamespacedNetworkPolicyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNetworkingV1NamespacedNetworkPolicy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30188,7 +35540,16 @@ func (s *Server) handleListNetworkingV1NamespacedNetworkPolicyRequest(args [1]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30200,8 +35561,27 @@ func (s *Server) handleListNetworkingV1NamespacedNetworkPolicyRequest(args [1]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30363,6 +35743,8 @@ func (s *Server) handleListNetworkingV1NamespacedNetworkPolicyRequest(args [1]st // // GET /apis/networking.k8s.io/v1/networkpolicies func (s *Server) handleListNetworkingV1NetworkPolicyForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNetworkingV1NetworkPolicyForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30384,7 +35766,16 @@ func (s *Server) handleListNetworkingV1NetworkPolicyForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30396,8 +35787,27 @@ func (s *Server) handleListNetworkingV1NetworkPolicyForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30555,6 +35965,8 @@ func (s *Server) handleListNetworkingV1NetworkPolicyForAllNamespacesRequest(args // // GET /apis/node.k8s.io/v1/runtimeclasses func (s *Server) handleListNodeV1RuntimeClassRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNodeV1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30576,7 +35988,16 @@ func (s *Server) handleListNodeV1RuntimeClassRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30588,8 +36009,27 @@ func (s *Server) handleListNodeV1RuntimeClassRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30747,6 +36187,8 @@ func (s *Server) handleListNodeV1RuntimeClassRequest(args [0]string, argsEscaped // // GET /apis/node.k8s.io/v1alpha1/runtimeclasses func (s *Server) handleListNodeV1alpha1RuntimeClassRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNodeV1alpha1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30768,7 +36210,16 @@ func (s *Server) handleListNodeV1alpha1RuntimeClassRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30780,8 +36231,27 @@ func (s *Server) handleListNodeV1alpha1RuntimeClassRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30939,6 +36409,8 @@ func (s *Server) handleListNodeV1alpha1RuntimeClassRequest(args [0]string, argsE // // GET /apis/node.k8s.io/v1beta1/runtimeclasses func (s *Server) handleListNodeV1beta1RuntimeClassRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listNodeV1beta1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -30960,7 +36432,16 @@ func (s *Server) handleListNodeV1beta1RuntimeClassRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30972,212 +36453,261 @@ func (s *Server) handleListNodeV1beta1RuntimeClassRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ListNodeV1beta1RuntimeClassOperation, - ID: "listNodeV1beta1RuntimeClass", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ListNodeV1beta1RuntimeClassOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeListNodeV1beta1RuntimeClassParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - var response ListNodeV1beta1RuntimeClassRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ListNodeV1beta1RuntimeClassOperation, - OperationSummary: "", - OperationID: "listNodeV1beta1RuntimeClass", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - { - Name: "pretty", - In: "query", - }: params.Pretty, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ListNodeV1beta1RuntimeClassParams - Response = ListNodeV1beta1RuntimeClassRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackListNodeV1beta1RuntimeClassParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListNodeV1beta1RuntimeClass(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ListNodeV1beta1RuntimeClass(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeListNodeV1beta1RuntimeClassResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleListPolicyV1NamespacedPodDisruptionBudgetRequest handles listPolicyV1NamespacedPodDisruptionBudget operation. -// -// List or watch objects of kind PodDisruptionBudget. -// -// GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets -func (s *Server) handleListPolicyV1NamespacedPodDisruptionBudgetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listPolicyV1NamespacedPodDisruptionBudget"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListPolicyV1NamespacedPodDisruptionBudgetOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListPolicyV1NamespacedPodDisruptionBudgetOperation, - ID: "listPolicyV1NamespacedPodDisruptionBudget", + Name: ListNodeV1beta1RuntimeClassOperation, + ID: "listNodeV1beta1RuntimeClass", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListPolicyV1NamespacedPodDisruptionBudgetOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListNodeV1beta1RuntimeClassOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeListNodeV1beta1RuntimeClassParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListNodeV1beta1RuntimeClassRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ListNodeV1beta1RuntimeClassOperation, + OperationSummary: "", + OperationID: "listNodeV1beta1RuntimeClass", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListNodeV1beta1RuntimeClassParams + Response = ListNodeV1beta1RuntimeClassRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListNodeV1beta1RuntimeClassParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListNodeV1beta1RuntimeClass(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListNodeV1beta1RuntimeClass(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListNodeV1beta1RuntimeClassResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleListPolicyV1NamespacedPodDisruptionBudgetRequest handles listPolicyV1NamespacedPodDisruptionBudget operation. +// +// List or watch objects of kind PodDisruptionBudget. +// +// GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets +func (s *Server) handleListPolicyV1NamespacedPodDisruptionBudgetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listPolicyV1NamespacedPodDisruptionBudget"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ListPolicyV1NamespacedPodDisruptionBudgetOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ListPolicyV1NamespacedPodDisruptionBudgetOperation, + ID: "listPolicyV1NamespacedPodDisruptionBudget", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ListPolicyV1NamespacedPodDisruptionBudgetOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -31327,6 +36857,8 @@ func (s *Server) handleListPolicyV1NamespacedPodDisruptionBudgetRequest(args [1] // // GET /apis/policy/v1/poddisruptionbudgets func (s *Server) handleListPolicyV1PodDisruptionBudgetForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPolicyV1PodDisruptionBudgetForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -31348,7 +36880,16 @@ func (s *Server) handleListPolicyV1PodDisruptionBudgetForAllNamespacesRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31360,8 +36901,27 @@ func (s *Server) handleListPolicyV1PodDisruptionBudgetForAllNamespacesRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31519,6 +37079,8 @@ func (s *Server) handleListPolicyV1PodDisruptionBudgetForAllNamespacesRequest(ar // // GET /apis/policy/v1beta1/namespaces/{namespace}/poddisruptionbudgets func (s *Server) handleListPolicyV1beta1NamespacedPodDisruptionBudgetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPolicyV1beta1NamespacedPodDisruptionBudget"), semconv.HTTPRequestMethodKey.String("GET"), @@ -31540,7 +37102,16 @@ func (s *Server) handleListPolicyV1beta1NamespacedPodDisruptionBudgetRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31552,8 +37123,27 @@ func (s *Server) handleListPolicyV1beta1NamespacedPodDisruptionBudgetRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31715,6 +37305,8 @@ func (s *Server) handleListPolicyV1beta1NamespacedPodDisruptionBudgetRequest(arg // // GET /apis/policy/v1beta1/poddisruptionbudgets func (s *Server) handleListPolicyV1beta1PodDisruptionBudgetForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPolicyV1beta1PodDisruptionBudgetForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -31736,7 +37328,16 @@ func (s *Server) handleListPolicyV1beta1PodDisruptionBudgetForAllNamespacesReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31748,8 +37349,27 @@ func (s *Server) handleListPolicyV1beta1PodDisruptionBudgetForAllNamespacesReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31907,6 +37527,8 @@ func (s *Server) handleListPolicyV1beta1PodDisruptionBudgetForAllNamespacesReque // // GET /apis/policy/v1beta1/podsecuritypolicies func (s *Server) handleListPolicyV1beta1PodSecurityPolicyRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPolicyV1beta1PodSecurityPolicy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -31928,7 +37550,16 @@ func (s *Server) handleListPolicyV1beta1PodSecurityPolicyRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31940,8 +37571,27 @@ func (s *Server) handleListPolicyV1beta1PodSecurityPolicyRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32099,6 +37749,8 @@ func (s *Server) handleListPolicyV1beta1PodSecurityPolicyRequest(args [0]string, // // GET /apis/rbac.authorization.k8s.io/v1/clusterroles func (s *Server) handleListRbacAuthorizationV1ClusterRoleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listRbacAuthorizationV1ClusterRole"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32120,7 +37772,16 @@ func (s *Server) handleListRbacAuthorizationV1ClusterRoleRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32132,8 +37793,27 @@ func (s *Server) handleListRbacAuthorizationV1ClusterRoleRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32291,6 +37971,8 @@ func (s *Server) handleListRbacAuthorizationV1ClusterRoleRequest(args [0]string, // // GET /apis/rbac.authorization.k8s.io/v1/clusterrolebindings func (s *Server) handleListRbacAuthorizationV1ClusterRoleBindingRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listRbacAuthorizationV1ClusterRoleBinding"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32312,7 +37994,16 @@ func (s *Server) handleListRbacAuthorizationV1ClusterRoleBindingRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32324,8 +38015,27 @@ func (s *Server) handleListRbacAuthorizationV1ClusterRoleBindingRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32483,6 +38193,8 @@ func (s *Server) handleListRbacAuthorizationV1ClusterRoleBindingRequest(args [0] // // GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles func (s *Server) handleListRbacAuthorizationV1NamespacedRoleRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listRbacAuthorizationV1NamespacedRole"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32504,7 +38216,16 @@ func (s *Server) handleListRbacAuthorizationV1NamespacedRoleRequest(args [1]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32516,8 +38237,27 @@ func (s *Server) handleListRbacAuthorizationV1NamespacedRoleRequest(args [1]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32679,6 +38419,8 @@ func (s *Server) handleListRbacAuthorizationV1NamespacedRoleRequest(args [1]stri // // GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings func (s *Server) handleListRbacAuthorizationV1NamespacedRoleBindingRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listRbacAuthorizationV1NamespacedRoleBinding"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32700,7 +38442,16 @@ func (s *Server) handleListRbacAuthorizationV1NamespacedRoleBindingRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32712,8 +38463,27 @@ func (s *Server) handleListRbacAuthorizationV1NamespacedRoleBindingRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32875,6 +38645,8 @@ func (s *Server) handleListRbacAuthorizationV1NamespacedRoleBindingRequest(args // // GET /apis/rbac.authorization.k8s.io/v1/rolebindings func (s *Server) handleListRbacAuthorizationV1RoleBindingForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listRbacAuthorizationV1RoleBindingForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -32896,7 +38668,16 @@ func (s *Server) handleListRbacAuthorizationV1RoleBindingForAllNamespacesRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32908,8 +38689,27 @@ func (s *Server) handleListRbacAuthorizationV1RoleBindingForAllNamespacesRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33067,6 +38867,8 @@ func (s *Server) handleListRbacAuthorizationV1RoleBindingForAllNamespacesRequest // // GET /apis/rbac.authorization.k8s.io/v1/roles func (s *Server) handleListRbacAuthorizationV1RoleForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listRbacAuthorizationV1RoleForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33088,7 +38890,16 @@ func (s *Server) handleListRbacAuthorizationV1RoleForAllNamespacesRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33100,8 +38911,27 @@ func (s *Server) handleListRbacAuthorizationV1RoleForAllNamespacesRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33259,6 +39089,8 @@ func (s *Server) handleListRbacAuthorizationV1RoleForAllNamespacesRequest(args [ // // GET /apis/scheduling.k8s.io/v1/priorityclasses func (s *Server) handleListSchedulingV1PriorityClassRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listSchedulingV1PriorityClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33280,7 +39112,16 @@ func (s *Server) handleListSchedulingV1PriorityClassRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33292,8 +39133,27 @@ func (s *Server) handleListSchedulingV1PriorityClassRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33451,6 +39311,8 @@ func (s *Server) handleListSchedulingV1PriorityClassRequest(args [0]string, args // // GET /apis/storage.k8s.io/v1/csidrivers func (s *Server) handleListStorageV1CSIDriverRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1CSIDriver"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33472,7 +39334,16 @@ func (s *Server) handleListStorageV1CSIDriverRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33484,8 +39355,27 @@ func (s *Server) handleListStorageV1CSIDriverRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33643,6 +39533,8 @@ func (s *Server) handleListStorageV1CSIDriverRequest(args [0]string, argsEscaped // // GET /apis/storage.k8s.io/v1/csinodes func (s *Server) handleListStorageV1CSINodeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1CSINode"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33664,7 +39556,16 @@ func (s *Server) handleListStorageV1CSINodeRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33676,8 +39577,27 @@ func (s *Server) handleListStorageV1CSINodeRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33835,6 +39755,8 @@ func (s *Server) handleListStorageV1CSINodeRequest(args [0]string, argsEscaped b // // GET /apis/storage.k8s.io/v1/storageclasses func (s *Server) handleListStorageV1StorageClassRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1StorageClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -33856,7 +39778,16 @@ func (s *Server) handleListStorageV1StorageClassRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33868,8 +39799,27 @@ func (s *Server) handleListStorageV1StorageClassRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34027,6 +39977,8 @@ func (s *Server) handleListStorageV1StorageClassRequest(args [0]string, argsEsca // // GET /apis/storage.k8s.io/v1/volumeattachments func (s *Server) handleListStorageV1VolumeAttachmentRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1VolumeAttachment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34048,7 +40000,16 @@ func (s *Server) handleListStorageV1VolumeAttachmentRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34060,8 +40021,27 @@ func (s *Server) handleListStorageV1VolumeAttachmentRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34219,6 +40199,8 @@ func (s *Server) handleListStorageV1VolumeAttachmentRequest(args [0]string, args // // GET /apis/storage.k8s.io/v1alpha1/csistoragecapacities func (s *Server) handleListStorageV1alpha1CSIStorageCapacityForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1alpha1CSIStorageCapacityForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34240,7 +40222,16 @@ func (s *Server) handleListStorageV1alpha1CSIStorageCapacityForAllNamespacesRequ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34252,8 +40243,27 @@ func (s *Server) handleListStorageV1alpha1CSIStorageCapacityForAllNamespacesRequ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34411,6 +40421,8 @@ func (s *Server) handleListStorageV1alpha1CSIStorageCapacityForAllNamespacesRequ // // GET /apis/storage.k8s.io/v1alpha1/namespaces/{namespace}/csistoragecapacities func (s *Server) handleListStorageV1alpha1NamespacedCSIStorageCapacityRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1alpha1NamespacedCSIStorageCapacity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34432,7 +40444,16 @@ func (s *Server) handleListStorageV1alpha1NamespacedCSIStorageCapacityRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34444,216 +40465,265 @@ func (s *Server) handleListStorageV1alpha1NamespacedCSIStorageCapacityRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ListStorageV1alpha1NamespacedCSIStorageCapacityOperation, - ID: "listStorageV1alpha1NamespacedCSIStorageCapacity", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ListStorageV1alpha1NamespacedCSIStorageCapacityOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeListStorageV1alpha1NamespacedCSIStorageCapacityParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - var response ListStorageV1alpha1NamespacedCSIStorageCapacityRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ListStorageV1alpha1NamespacedCSIStorageCapacityOperation, - OperationSummary: "", - OperationID: "listStorageV1alpha1NamespacedCSIStorageCapacity", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "pretty", - In: "query", - }: params.Pretty, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ListStorageV1alpha1NamespacedCSIStorageCapacityParams - Response = ListStorageV1alpha1NamespacedCSIStorageCapacityRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackListStorageV1alpha1NamespacedCSIStorageCapacityParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ListStorageV1alpha1NamespacedCSIStorageCapacity(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ListStorageV1alpha1NamespacedCSIStorageCapacity(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeListStorageV1alpha1NamespacedCSIStorageCapacityResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleListStorageV1beta1CSIStorageCapacityForAllNamespacesRequest handles listStorageV1beta1CSIStorageCapacityForAllNamespaces operation. -// -// List or watch objects of kind CSIStorageCapacity. -// -// GET /apis/storage.k8s.io/v1beta1/csistoragecapacities -func (s *Server) handleListStorageV1beta1CSIStorageCapacityForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listStorageV1beta1CSIStorageCapacityForAllNamespaces"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/storage.k8s.io/v1beta1/csistoragecapacities"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ListStorageV1beta1CSIStorageCapacityForAllNamespacesOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ListStorageV1beta1CSIStorageCapacityForAllNamespacesOperation, - ID: "listStorageV1beta1CSIStorageCapacityForAllNamespaces", + Name: ListStorageV1alpha1NamespacedCSIStorageCapacityOperation, + ID: "listStorageV1alpha1NamespacedCSIStorageCapacity", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ListStorageV1beta1CSIStorageCapacityForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ListStorageV1alpha1NamespacedCSIStorageCapacityOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeListStorageV1alpha1NamespacedCSIStorageCapacityParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListStorageV1alpha1NamespacedCSIStorageCapacityRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ListStorageV1alpha1NamespacedCSIStorageCapacityOperation, + OperationSummary: "", + OperationID: "listStorageV1alpha1NamespacedCSIStorageCapacity", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListStorageV1alpha1NamespacedCSIStorageCapacityParams + Response = ListStorageV1alpha1NamespacedCSIStorageCapacityRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListStorageV1alpha1NamespacedCSIStorageCapacityParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListStorageV1alpha1NamespacedCSIStorageCapacity(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListStorageV1alpha1NamespacedCSIStorageCapacity(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListStorageV1alpha1NamespacedCSIStorageCapacityResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleListStorageV1beta1CSIStorageCapacityForAllNamespacesRequest handles listStorageV1beta1CSIStorageCapacityForAllNamespaces operation. +// +// List or watch objects of kind CSIStorageCapacity. +// +// GET /apis/storage.k8s.io/v1beta1/csistoragecapacities +func (s *Server) handleListStorageV1beta1CSIStorageCapacityForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listStorageV1beta1CSIStorageCapacityForAllNamespaces"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/storage.k8s.io/v1beta1/csistoragecapacities"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ListStorageV1beta1CSIStorageCapacityForAllNamespacesOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ListStorageV1beta1CSIStorageCapacityForAllNamespacesOperation, + ID: "listStorageV1beta1CSIStorageCapacityForAllNamespaces", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ListStorageV1beta1CSIStorageCapacityForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -34799,6 +40869,8 @@ func (s *Server) handleListStorageV1beta1CSIStorageCapacityForAllNamespacesReque // // GET /apis/storage.k8s.io/v1beta1/namespaces/{namespace}/csistoragecapacities func (s *Server) handleListStorageV1beta1NamespacedCSIStorageCapacityRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listStorageV1beta1NamespacedCSIStorageCapacity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -34820,7 +40892,16 @@ func (s *Server) handleListStorageV1beta1NamespacedCSIStorageCapacityRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34832,8 +40913,27 @@ func (s *Server) handleListStorageV1beta1NamespacedCSIStorageCapacityRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34993,6 +41093,8 @@ func (s *Server) handleListStorageV1beta1NamespacedCSIStorageCapacityRequest(arg // // GET /logs/{logpath} func (s *Server) handleLogFileHandlerRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("logFileHandler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35014,7 +41116,16 @@ func (s *Server) handleLogFileHandlerRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35026,8 +41137,27 @@ func (s *Server) handleLogFileHandlerRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35147,6 +41277,8 @@ func (s *Server) handleLogFileHandlerRequest(args [1]string, argsEscaped bool, w // // GET /logs/ func (s *Server) handleLogFileListHandlerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("logFileListHandler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35168,7 +41300,16 @@ func (s *Server) handleLogFileListHandlerRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35180,8 +41321,27 @@ func (s *Server) handleLogFileListHandlerRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35288,6 +41448,8 @@ func (s *Server) handleLogFileListHandlerRequest(args [0]string, argsEscaped boo // // GET /apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations/{name} func (s *Server) handleReadAdmissionregistrationV1MutatingWebhookConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAdmissionregistrationV1MutatingWebhookConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35309,7 +41471,16 @@ func (s *Server) handleReadAdmissionregistrationV1MutatingWebhookConfigurationRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35321,8 +41492,27 @@ func (s *Server) handleReadAdmissionregistrationV1MutatingWebhookConfigurationRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35448,6 +41638,8 @@ func (s *Server) handleReadAdmissionregistrationV1MutatingWebhookConfigurationRe // // GET /apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations/{name} func (s *Server) handleReadAdmissionregistrationV1ValidatingWebhookConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAdmissionregistrationV1ValidatingWebhookConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35469,7 +41661,16 @@ func (s *Server) handleReadAdmissionregistrationV1ValidatingWebhookConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35481,8 +41682,27 @@ func (s *Server) handleReadAdmissionregistrationV1ValidatingWebhookConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35608,6 +41828,8 @@ func (s *Server) handleReadAdmissionregistrationV1ValidatingWebhookConfiguration // // GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name} func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readApiextensionsV1CustomResourceDefinition"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35629,7 +41851,16 @@ func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35641,8 +41872,27 @@ func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35768,6 +42018,8 @@ func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionRequest(args [ // // GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions/{name}/status func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readApiextensionsV1CustomResourceDefinitionStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35789,7 +42041,16 @@ func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionStatusRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35801,8 +42062,27 @@ func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionStatusRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35928,6 +42208,8 @@ func (s *Server) handleReadApiextensionsV1CustomResourceDefinitionStatusRequest( // // GET /apis/apiregistration.k8s.io/v1/apiservices/{name} func (s *Server) handleReadApiregistrationV1APIServiceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readApiregistrationV1APIService"), semconv.HTTPRequestMethodKey.String("GET"), @@ -35949,7 +42231,16 @@ func (s *Server) handleReadApiregistrationV1APIServiceRequest(args [1]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35961,8 +42252,27 @@ func (s *Server) handleReadApiregistrationV1APIServiceRequest(args [1]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36088,6 +42398,8 @@ func (s *Server) handleReadApiregistrationV1APIServiceRequest(args [1]string, ar // // GET /apis/apiregistration.k8s.io/v1/apiservices/{name}/status func (s *Server) handleReadApiregistrationV1APIServiceStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readApiregistrationV1APIServiceStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36109,7 +42421,16 @@ func (s *Server) handleReadApiregistrationV1APIServiceStatusRequest(args [1]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36121,8 +42442,27 @@ func (s *Server) handleReadApiregistrationV1APIServiceStatusRequest(args [1]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36248,6 +42588,8 @@ func (s *Server) handleReadApiregistrationV1APIServiceStatusRequest(args [1]stri // // GET /apis/apps/v1/namespaces/{namespace}/controllerrevisions/{name} func (s *Server) handleReadAppsV1NamespacedControllerRevisionRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedControllerRevision"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36269,7 +42611,16 @@ func (s *Server) handleReadAppsV1NamespacedControllerRevisionRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36281,8 +42632,27 @@ func (s *Server) handleReadAppsV1NamespacedControllerRevisionRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36412,6 +42782,8 @@ func (s *Server) handleReadAppsV1NamespacedControllerRevisionRequest(args [2]str // // GET /apis/apps/v1/namespaces/{namespace}/daemonsets/{name} func (s *Server) handleReadAppsV1NamespacedDaemonSetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedDaemonSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36433,7 +42805,16 @@ func (s *Server) handleReadAppsV1NamespacedDaemonSetRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36445,8 +42826,27 @@ func (s *Server) handleReadAppsV1NamespacedDaemonSetRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36576,6 +42976,8 @@ func (s *Server) handleReadAppsV1NamespacedDaemonSetRequest(args [2]string, args // // GET /apis/apps/v1/namespaces/{namespace}/daemonsets/{name}/status func (s *Server) handleReadAppsV1NamespacedDaemonSetStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedDaemonSetStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36597,7 +42999,16 @@ func (s *Server) handleReadAppsV1NamespacedDaemonSetStatusRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36609,8 +43020,27 @@ func (s *Server) handleReadAppsV1NamespacedDaemonSetStatusRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36740,6 +43170,8 @@ func (s *Server) handleReadAppsV1NamespacedDaemonSetStatusRequest(args [2]string // // GET /apis/apps/v1/namespaces/{namespace}/deployments/{name} func (s *Server) handleReadAppsV1NamespacedDeploymentRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedDeployment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36761,7 +43193,16 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36773,8 +43214,27 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36904,6 +43364,8 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentRequest(args [2]string, arg // // GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/scale func (s *Server) handleReadAppsV1NamespacedDeploymentScaleRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedDeploymentScale"), semconv.HTTPRequestMethodKey.String("GET"), @@ -36925,7 +43387,16 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentScaleRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36937,8 +43408,27 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentScaleRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37068,6 +43558,8 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentScaleRequest(args [2]string // // GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}/status func (s *Server) handleReadAppsV1NamespacedDeploymentStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedDeploymentStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37089,7 +43581,16 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentStatusRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37101,8 +43602,27 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentStatusRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37232,6 +43752,8 @@ func (s *Server) handleReadAppsV1NamespacedDeploymentStatusRequest(args [2]strin // // GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name} func (s *Server) handleReadAppsV1NamespacedReplicaSetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedReplicaSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37253,7 +43775,16 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37265,8 +43796,27 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37396,6 +43946,8 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetRequest(args [2]string, arg // // GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}/scale func (s *Server) handleReadAppsV1NamespacedReplicaSetScaleRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedReplicaSetScale"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37417,7 +43969,16 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetScaleRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37429,8 +43990,27 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetScaleRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37560,6 +44140,8 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetScaleRequest(args [2]string // // GET /apis/apps/v1/namespaces/{namespace}/replicasets/{name}/status func (s *Server) handleReadAppsV1NamespacedReplicaSetStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedReplicaSetStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37581,7 +44163,16 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetStatusRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37593,8 +44184,27 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetStatusRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37724,6 +44334,8 @@ func (s *Server) handleReadAppsV1NamespacedReplicaSetStatusRequest(args [2]strin // // GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name} func (s *Server) handleReadAppsV1NamespacedStatefulSetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedStatefulSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37745,7 +44357,16 @@ func (s *Server) handleReadAppsV1NamespacedStatefulSetRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37757,8 +44378,27 @@ func (s *Server) handleReadAppsV1NamespacedStatefulSetRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37888,6 +44528,8 @@ func (s *Server) handleReadAppsV1NamespacedStatefulSetRequest(args [2]string, ar // // GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/scale func (s *Server) handleReadAppsV1NamespacedStatefulSetScaleRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAppsV1NamespacedStatefulSetScale"), semconv.HTTPRequestMethodKey.String("GET"), @@ -37909,7 +44551,16 @@ func (s *Server) handleReadAppsV1NamespacedStatefulSetScaleRequest(args [2]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37921,184 +44572,233 @@ func (s *Server) handleReadAppsV1NamespacedStatefulSetScaleRequest(args [2]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ReadAppsV1NamespacedStatefulSetScaleOperation, - ID: "readAppsV1NamespacedStatefulSetScale", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ReadAppsV1NamespacedStatefulSetScaleOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeReadAppsV1NamespacedStatefulSetScaleParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response ReadAppsV1NamespacedStatefulSetScaleRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ReadAppsV1NamespacedStatefulSetScaleOperation, - OperationSummary: "", - OperationID: "readAppsV1NamespacedStatefulSetScale", - Body: nil, - Params: middleware.Parameters{ - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "pretty", - In: "query", - }: params.Pretty, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ReadAppsV1NamespacedStatefulSetScaleParams - Response = ReadAppsV1NamespacedStatefulSetScaleRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackReadAppsV1NamespacedStatefulSetScaleParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ReadAppsV1NamespacedStatefulSetScale(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ReadAppsV1NamespacedStatefulSetScale(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeReadAppsV1NamespacedStatefulSetScaleResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleReadAppsV1NamespacedStatefulSetStatusRequest handles readAppsV1NamespacedStatefulSetStatus operation. -// -// Read status of the specified StatefulSet. -// -// GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status -func (s *Server) handleReadAppsV1NamespacedStatefulSetStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("readAppsV1NamespacedStatefulSetStatus"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status"), - } - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ReadAppsV1NamespacedStatefulSetStatusOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ReadAppsV1NamespacedStatefulSetStatusOperation, - ID: "readAppsV1NamespacedStatefulSetStatus", + Name: ReadAppsV1NamespacedStatefulSetScaleOperation, + ID: "readAppsV1NamespacedStatefulSetScale", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ReadAppsV1NamespacedStatefulSetStatusOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ReadAppsV1NamespacedStatefulSetScaleOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeReadAppsV1NamespacedStatefulSetScaleParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ReadAppsV1NamespacedStatefulSetScaleRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ReadAppsV1NamespacedStatefulSetScaleOperation, + OperationSummary: "", + OperationID: "readAppsV1NamespacedStatefulSetScale", + Body: nil, + Params: middleware.Parameters{ + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ReadAppsV1NamespacedStatefulSetScaleParams + Response = ReadAppsV1NamespacedStatefulSetScaleRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackReadAppsV1NamespacedStatefulSetScaleParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ReadAppsV1NamespacedStatefulSetScale(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ReadAppsV1NamespacedStatefulSetScale(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeReadAppsV1NamespacedStatefulSetScaleResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleReadAppsV1NamespacedStatefulSetStatusRequest handles readAppsV1NamespacedStatefulSetStatus operation. +// +// Read status of the specified StatefulSet. +// +// GET /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status +func (s *Server) handleReadAppsV1NamespacedStatefulSetStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readAppsV1NamespacedStatefulSetStatus"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ReadAppsV1NamespacedStatefulSetStatusOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ReadAppsV1NamespacedStatefulSetStatusOperation, + ID: "readAppsV1NamespacedStatefulSetStatus", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ReadAppsV1NamespacedStatefulSetStatusOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -38216,6 +44916,8 @@ func (s *Server) handleReadAppsV1NamespacedStatefulSetStatusRequest(args [2]stri // // GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name} func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAutoscalingV1NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38237,7 +44939,16 @@ func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38249,8 +44960,27 @@ func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38380,6 +45110,8 @@ func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerRequest // // GET /apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAutoscalingV1NamespacedHorizontalPodAutoscalerStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38401,7 +45133,16 @@ func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerStatusR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38413,8 +45154,27 @@ func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerStatusR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38544,6 +45304,8 @@ func (s *Server) handleReadAutoscalingV1NamespacedHorizontalPodAutoscalerStatusR // // GET /apis/autoscaling/v2beta1/namespaces/{namespace}/horizontalpodautoscalers/{name} func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAutoscalingV2beta1NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38565,7 +45327,16 @@ func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38577,8 +45348,27 @@ func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38708,6 +45498,8 @@ func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRe // // GET /apis/autoscaling/v2beta1/namespaces/{namespace}/horizontalpodautoscalers/{name}/status func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAutoscalingV2beta1NamespacedHorizontalPodAutoscalerStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38729,7 +45521,16 @@ func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerSt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38741,8 +45542,27 @@ func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerSt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38872,6 +45692,8 @@ func (s *Server) handleReadAutoscalingV2beta1NamespacedHorizontalPodAutoscalerSt // // GET /apis/autoscaling/v2beta2/namespaces/{namespace}/horizontalpodautoscalers/{name} func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAutoscalingV2beta2NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -38893,7 +45715,16 @@ func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38905,8 +45736,27 @@ func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39036,6 +45886,8 @@ func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRe // // GET /apis/autoscaling/v2beta2/namespaces/{namespace}/horizontalpodautoscalers/{name}/status func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readAutoscalingV2beta2NamespacedHorizontalPodAutoscalerStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39057,7 +45909,16 @@ func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerSt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39069,8 +45930,27 @@ func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerSt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39200,6 +46080,8 @@ func (s *Server) handleReadAutoscalingV2beta2NamespacedHorizontalPodAutoscalerSt // // GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name} func (s *Server) handleReadBatchV1NamespacedCronJobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readBatchV1NamespacedCronJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39221,7 +46103,16 @@ func (s *Server) handleReadBatchV1NamespacedCronJobRequest(args [2]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39233,8 +46124,27 @@ func (s *Server) handleReadBatchV1NamespacedCronJobRequest(args [2]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39364,6 +46274,8 @@ func (s *Server) handleReadBatchV1NamespacedCronJobRequest(args [2]string, argsE // // GET /apis/batch/v1/namespaces/{namespace}/cronjobs/{name}/status func (s *Server) handleReadBatchV1NamespacedCronJobStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readBatchV1NamespacedCronJobStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39385,7 +46297,16 @@ func (s *Server) handleReadBatchV1NamespacedCronJobStatusRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39397,8 +46318,27 @@ func (s *Server) handleReadBatchV1NamespacedCronJobStatusRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39528,6 +46468,8 @@ func (s *Server) handleReadBatchV1NamespacedCronJobStatusRequest(args [2]string, // // GET /apis/batch/v1/namespaces/{namespace}/jobs/{name} func (s *Server) handleReadBatchV1NamespacedJobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readBatchV1NamespacedJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39549,7 +46491,16 @@ func (s *Server) handleReadBatchV1NamespacedJobRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39561,8 +46512,27 @@ func (s *Server) handleReadBatchV1NamespacedJobRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39692,6 +46662,8 @@ func (s *Server) handleReadBatchV1NamespacedJobRequest(args [2]string, argsEscap // // GET /apis/batch/v1/namespaces/{namespace}/jobs/{name}/status func (s *Server) handleReadBatchV1NamespacedJobStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readBatchV1NamespacedJobStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39713,7 +46685,16 @@ func (s *Server) handleReadBatchV1NamespacedJobStatusRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39725,8 +46706,27 @@ func (s *Server) handleReadBatchV1NamespacedJobStatusRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39856,6 +46856,8 @@ func (s *Server) handleReadBatchV1NamespacedJobStatusRequest(args [2]string, arg // // GET /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name} func (s *Server) handleReadBatchV1beta1NamespacedCronJobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readBatchV1beta1NamespacedCronJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -39877,7 +46879,16 @@ func (s *Server) handleReadBatchV1beta1NamespacedCronJobRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39889,8 +46900,27 @@ func (s *Server) handleReadBatchV1beta1NamespacedCronJobRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40020,6 +47050,8 @@ func (s *Server) handleReadBatchV1beta1NamespacedCronJobRequest(args [2]string, // // GET /apis/batch/v1beta1/namespaces/{namespace}/cronjobs/{name}/status func (s *Server) handleReadBatchV1beta1NamespacedCronJobStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readBatchV1beta1NamespacedCronJobStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40041,7 +47073,16 @@ func (s *Server) handleReadBatchV1beta1NamespacedCronJobStatusRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40053,8 +47094,27 @@ func (s *Server) handleReadBatchV1beta1NamespacedCronJobStatusRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40184,6 +47244,8 @@ func (s *Server) handleReadBatchV1beta1NamespacedCronJobStatusRequest(args [2]st // // GET /apis/certificates.k8s.io/v1/certificatesigningrequests/{name} func (s *Server) handleReadCertificatesV1CertificateSigningRequestRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCertificatesV1CertificateSigningRequest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40205,7 +47267,16 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40217,8 +47288,27 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40344,6 +47434,8 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestRequest(args [ // // GET /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/approval func (s *Server) handleReadCertificatesV1CertificateSigningRequestApprovalRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCertificatesV1CertificateSigningRequestApproval"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40365,7 +47457,16 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestApprovalReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40377,8 +47478,27 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestApprovalReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40504,6 +47624,8 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestApprovalReques // // GET /apis/certificates.k8s.io/v1/certificatesigningrequests/{name}/status func (s *Server) handleReadCertificatesV1CertificateSigningRequestStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCertificatesV1CertificateSigningRequestStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40525,7 +47647,16 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestStatusRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40537,8 +47668,27 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestStatusRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40664,6 +47814,8 @@ func (s *Server) handleReadCertificatesV1CertificateSigningRequestStatusRequest( // // GET /apis/coordination.k8s.io/v1/namespaces/{namespace}/leases/{name} func (s *Server) handleReadCoordinationV1NamespacedLeaseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoordinationV1NamespacedLease"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40685,7 +47837,16 @@ func (s *Server) handleReadCoordinationV1NamespacedLeaseRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40697,8 +47858,27 @@ func (s *Server) handleReadCoordinationV1NamespacedLeaseRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40828,6 +48008,8 @@ func (s *Server) handleReadCoordinationV1NamespacedLeaseRequest(args [2]string, // // GET /api/v1/componentstatuses/{name} func (s *Server) handleReadCoreV1ComponentStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1ComponentStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -40849,7 +48031,16 @@ func (s *Server) handleReadCoreV1ComponentStatusRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40861,8 +48052,27 @@ func (s *Server) handleReadCoreV1ComponentStatusRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40988,6 +48198,8 @@ func (s *Server) handleReadCoreV1ComponentStatusRequest(args [1]string, argsEsca // // GET /api/v1/namespaces/{name} func (s *Server) handleReadCoreV1NamespaceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1Namespace"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41009,7 +48221,16 @@ func (s *Server) handleReadCoreV1NamespaceRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41021,8 +48242,27 @@ func (s *Server) handleReadCoreV1NamespaceRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41148,6 +48388,8 @@ func (s *Server) handleReadCoreV1NamespaceRequest(args [1]string, argsEscaped bo // // GET /api/v1/namespaces/{name}/status func (s *Server) handleReadCoreV1NamespaceStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespaceStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41169,7 +48411,16 @@ func (s *Server) handleReadCoreV1NamespaceStatusRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41181,8 +48432,27 @@ func (s *Server) handleReadCoreV1NamespaceStatusRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41308,6 +48578,8 @@ func (s *Server) handleReadCoreV1NamespaceStatusRequest(args [1]string, argsEsca // // GET /api/v1/namespaces/{namespace}/configmaps/{name} func (s *Server) handleReadCoreV1NamespacedConfigMapRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedConfigMap"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41329,7 +48601,16 @@ func (s *Server) handleReadCoreV1NamespacedConfigMapRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41341,8 +48622,27 @@ func (s *Server) handleReadCoreV1NamespacedConfigMapRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41472,6 +48772,8 @@ func (s *Server) handleReadCoreV1NamespacedConfigMapRequest(args [2]string, args // // GET /api/v1/namespaces/{namespace}/endpoints/{name} func (s *Server) handleReadCoreV1NamespacedEndpointsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedEndpoints"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41493,7 +48795,16 @@ func (s *Server) handleReadCoreV1NamespacedEndpointsRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41505,8 +48816,27 @@ func (s *Server) handleReadCoreV1NamespacedEndpointsRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41636,6 +48966,8 @@ func (s *Server) handleReadCoreV1NamespacedEndpointsRequest(args [2]string, args // // GET /api/v1/namespaces/{namespace}/events/{name} func (s *Server) handleReadCoreV1NamespacedEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41657,7 +48989,16 @@ func (s *Server) handleReadCoreV1NamespacedEventRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41669,8 +49010,27 @@ func (s *Server) handleReadCoreV1NamespacedEventRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41800,6 +49160,8 @@ func (s *Server) handleReadCoreV1NamespacedEventRequest(args [2]string, argsEsca // // GET /api/v1/namespaces/{namespace}/limitranges/{name} func (s *Server) handleReadCoreV1NamespacedLimitRangeRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedLimitRange"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41821,7 +49183,16 @@ func (s *Server) handleReadCoreV1NamespacedLimitRangeRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41833,8 +49204,27 @@ func (s *Server) handleReadCoreV1NamespacedLimitRangeRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41964,6 +49354,8 @@ func (s *Server) handleReadCoreV1NamespacedLimitRangeRequest(args [2]string, arg // // GET /api/v1/namespaces/{namespace}/persistentvolumeclaims/{name} func (s *Server) handleReadCoreV1NamespacedPersistentVolumeClaimRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedPersistentVolumeClaim"), semconv.HTTPRequestMethodKey.String("GET"), @@ -41985,7 +49377,16 @@ func (s *Server) handleReadCoreV1NamespacedPersistentVolumeClaimRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41997,184 +49398,233 @@ func (s *Server) handleReadCoreV1NamespacedPersistentVolumeClaimRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ReadCoreV1NamespacedPersistentVolumeClaimOperation, - ID: "readCoreV1NamespacedPersistentVolumeClaim", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ReadCoreV1NamespacedPersistentVolumeClaimOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeReadCoreV1NamespacedPersistentVolumeClaimParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response ReadCoreV1NamespacedPersistentVolumeClaimRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ReadCoreV1NamespacedPersistentVolumeClaimOperation, - OperationSummary: "", - OperationID: "readCoreV1NamespacedPersistentVolumeClaim", - Body: nil, - Params: middleware.Parameters{ - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "pretty", - In: "query", - }: params.Pretty, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ReadCoreV1NamespacedPersistentVolumeClaimParams - Response = ReadCoreV1NamespacedPersistentVolumeClaimRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackReadCoreV1NamespacedPersistentVolumeClaimParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ReadCoreV1NamespacedPersistentVolumeClaim(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ReadCoreV1NamespacedPersistentVolumeClaim(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeReadCoreV1NamespacedPersistentVolumeClaimResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleReadCoreV1NamespacedPersistentVolumeClaimStatusRequest handles readCoreV1NamespacedPersistentVolumeClaimStatus operation. -// -// Read status of the specified PersistentVolumeClaim. -// -// GET /api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}/status -func (s *Server) handleReadCoreV1NamespacedPersistentVolumeClaimStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("readCoreV1NamespacedPersistentVolumeClaimStatus"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}/status"), - } - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ReadCoreV1NamespacedPersistentVolumeClaimStatusOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ReadCoreV1NamespacedPersistentVolumeClaimStatusOperation, - ID: "readCoreV1NamespacedPersistentVolumeClaimStatus", + Name: ReadCoreV1NamespacedPersistentVolumeClaimOperation, + ID: "readCoreV1NamespacedPersistentVolumeClaim", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ReadCoreV1NamespacedPersistentVolumeClaimStatusOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ReadCoreV1NamespacedPersistentVolumeClaimOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeReadCoreV1NamespacedPersistentVolumeClaimParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ReadCoreV1NamespacedPersistentVolumeClaimRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ReadCoreV1NamespacedPersistentVolumeClaimOperation, + OperationSummary: "", + OperationID: "readCoreV1NamespacedPersistentVolumeClaim", + Body: nil, + Params: middleware.Parameters{ + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ReadCoreV1NamespacedPersistentVolumeClaimParams + Response = ReadCoreV1NamespacedPersistentVolumeClaimRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackReadCoreV1NamespacedPersistentVolumeClaimParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ReadCoreV1NamespacedPersistentVolumeClaim(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ReadCoreV1NamespacedPersistentVolumeClaim(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeReadCoreV1NamespacedPersistentVolumeClaimResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleReadCoreV1NamespacedPersistentVolumeClaimStatusRequest handles readCoreV1NamespacedPersistentVolumeClaimStatus operation. +// +// Read status of the specified PersistentVolumeClaim. +// +// GET /api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}/status +func (s *Server) handleReadCoreV1NamespacedPersistentVolumeClaimStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readCoreV1NamespacedPersistentVolumeClaimStatus"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/v1/namespaces/{namespace}/persistentvolumeclaims/{name}/status"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ReadCoreV1NamespacedPersistentVolumeClaimStatusOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ReadCoreV1NamespacedPersistentVolumeClaimStatusOperation, + ID: "readCoreV1NamespacedPersistentVolumeClaimStatus", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ReadCoreV1NamespacedPersistentVolumeClaimStatusOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -42292,6 +49742,8 @@ func (s *Server) handleReadCoreV1NamespacedPersistentVolumeClaimStatusRequest(ar // // GET /api/v1/namespaces/{namespace}/pods/{name} func (s *Server) handleReadCoreV1NamespacedPodRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedPod"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42313,7 +49765,16 @@ func (s *Server) handleReadCoreV1NamespacedPodRequest(args [2]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42325,8 +49786,27 @@ func (s *Server) handleReadCoreV1NamespacedPodRequest(args [2]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42456,6 +49936,8 @@ func (s *Server) handleReadCoreV1NamespacedPodRequest(args [2]string, argsEscape // // GET /api/v1/namespaces/{namespace}/pods/{name}/ephemeralcontainers func (s *Server) handleReadCoreV1NamespacedPodEphemeralcontainersRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedPodEphemeralcontainers"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42477,7 +49959,16 @@ func (s *Server) handleReadCoreV1NamespacedPodEphemeralcontainersRequest(args [2 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42489,8 +49980,27 @@ func (s *Server) handleReadCoreV1NamespacedPodEphemeralcontainersRequest(args [2 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42620,6 +50130,8 @@ func (s *Server) handleReadCoreV1NamespacedPodEphemeralcontainersRequest(args [2 // // GET /api/v1/namespaces/{namespace}/pods/{name}/log func (s *Server) handleReadCoreV1NamespacedPodLogRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedPodLog"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42641,7 +50153,16 @@ func (s *Server) handleReadCoreV1NamespacedPodLogRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42653,8 +50174,27 @@ func (s *Server) handleReadCoreV1NamespacedPodLogRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42816,6 +50356,8 @@ func (s *Server) handleReadCoreV1NamespacedPodLogRequest(args [2]string, argsEsc // // GET /api/v1/namespaces/{namespace}/pods/{name}/status func (s *Server) handleReadCoreV1NamespacedPodStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedPodStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -42837,7 +50379,16 @@ func (s *Server) handleReadCoreV1NamespacedPodStatusRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42849,8 +50400,27 @@ func (s *Server) handleReadCoreV1NamespacedPodStatusRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42980,6 +50550,8 @@ func (s *Server) handleReadCoreV1NamespacedPodStatusRequest(args [2]string, args // // GET /api/v1/namespaces/{namespace}/podtemplates/{name} func (s *Server) handleReadCoreV1NamespacedPodTemplateRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedPodTemplate"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43001,7 +50573,16 @@ func (s *Server) handleReadCoreV1NamespacedPodTemplateRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43013,8 +50594,27 @@ func (s *Server) handleReadCoreV1NamespacedPodTemplateRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43144,6 +50744,8 @@ func (s *Server) handleReadCoreV1NamespacedPodTemplateRequest(args [2]string, ar // // GET /api/v1/namespaces/{namespace}/replicationcontrollers/{name} func (s *Server) handleReadCoreV1NamespacedReplicationControllerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedReplicationController"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43165,7 +50767,16 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43177,8 +50788,27 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43308,6 +50938,8 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerRequest(args [2] // // GET /api/v1/namespaces/{namespace}/replicationcontrollers/{name}/scale func (s *Server) handleReadCoreV1NamespacedReplicationControllerScaleRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedReplicationControllerScale"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43329,7 +50961,16 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerScaleRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43341,8 +50982,27 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerScaleRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43472,6 +51132,8 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerScaleRequest(arg // // GET /api/v1/namespaces/{namespace}/replicationcontrollers/{name}/status func (s *Server) handleReadCoreV1NamespacedReplicationControllerStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedReplicationControllerStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43493,7 +51155,16 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerStatusRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43505,8 +51176,27 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerStatusRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43636,6 +51326,8 @@ func (s *Server) handleReadCoreV1NamespacedReplicationControllerStatusRequest(ar // // GET /api/v1/namespaces/{namespace}/resourcequotas/{name} func (s *Server) handleReadCoreV1NamespacedResourceQuotaRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedResourceQuota"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43657,7 +51349,16 @@ func (s *Server) handleReadCoreV1NamespacedResourceQuotaRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43669,8 +51370,27 @@ func (s *Server) handleReadCoreV1NamespacedResourceQuotaRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43800,6 +51520,8 @@ func (s *Server) handleReadCoreV1NamespacedResourceQuotaRequest(args [2]string, // // GET /api/v1/namespaces/{namespace}/resourcequotas/{name}/status func (s *Server) handleReadCoreV1NamespacedResourceQuotaStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedResourceQuotaStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43821,7 +51543,16 @@ func (s *Server) handleReadCoreV1NamespacedResourceQuotaStatusRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43833,8 +51564,27 @@ func (s *Server) handleReadCoreV1NamespacedResourceQuotaStatusRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43964,6 +51714,8 @@ func (s *Server) handleReadCoreV1NamespacedResourceQuotaStatusRequest(args [2]st // // GET /api/v1/namespaces/{namespace}/secrets/{name} func (s *Server) handleReadCoreV1NamespacedSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedSecret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -43985,7 +51737,16 @@ func (s *Server) handleReadCoreV1NamespacedSecretRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43997,8 +51758,27 @@ func (s *Server) handleReadCoreV1NamespacedSecretRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44128,6 +51908,8 @@ func (s *Server) handleReadCoreV1NamespacedSecretRequest(args [2]string, argsEsc // // GET /api/v1/namespaces/{namespace}/services/{name} func (s *Server) handleReadCoreV1NamespacedServiceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedService"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44149,7 +51931,16 @@ func (s *Server) handleReadCoreV1NamespacedServiceRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44161,8 +51952,27 @@ func (s *Server) handleReadCoreV1NamespacedServiceRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44292,6 +52102,8 @@ func (s *Server) handleReadCoreV1NamespacedServiceRequest(args [2]string, argsEs // // GET /api/v1/namespaces/{namespace}/serviceaccounts/{name} func (s *Server) handleReadCoreV1NamespacedServiceAccountRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedServiceAccount"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44313,7 +52125,16 @@ func (s *Server) handleReadCoreV1NamespacedServiceAccountRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44325,8 +52146,27 @@ func (s *Server) handleReadCoreV1NamespacedServiceAccountRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44456,6 +52296,8 @@ func (s *Server) handleReadCoreV1NamespacedServiceAccountRequest(args [2]string, // // GET /api/v1/namespaces/{namespace}/services/{name}/status func (s *Server) handleReadCoreV1NamespacedServiceStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NamespacedServiceStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44477,7 +52319,16 @@ func (s *Server) handleReadCoreV1NamespacedServiceStatusRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44489,8 +52340,27 @@ func (s *Server) handleReadCoreV1NamespacedServiceStatusRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44620,6 +52490,8 @@ func (s *Server) handleReadCoreV1NamespacedServiceStatusRequest(args [2]string, // // GET /api/v1/nodes/{name} func (s *Server) handleReadCoreV1NodeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1Node"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44641,7 +52513,16 @@ func (s *Server) handleReadCoreV1NodeRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44653,8 +52534,27 @@ func (s *Server) handleReadCoreV1NodeRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44780,6 +52680,8 @@ func (s *Server) handleReadCoreV1NodeRequest(args [1]string, argsEscaped bool, w // // GET /api/v1/nodes/{name}/status func (s *Server) handleReadCoreV1NodeStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1NodeStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44801,7 +52703,16 @@ func (s *Server) handleReadCoreV1NodeStatusRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44813,8 +52724,27 @@ func (s *Server) handleReadCoreV1NodeStatusRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44940,6 +52870,8 @@ func (s *Server) handleReadCoreV1NodeStatusRequest(args [1]string, argsEscaped b // // GET /api/v1/persistentvolumes/{name} func (s *Server) handleReadCoreV1PersistentVolumeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1PersistentVolume"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44961,7 +52893,16 @@ func (s *Server) handleReadCoreV1PersistentVolumeRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44973,8 +52914,27 @@ func (s *Server) handleReadCoreV1PersistentVolumeRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45100,6 +53060,8 @@ func (s *Server) handleReadCoreV1PersistentVolumeRequest(args [1]string, argsEsc // // GET /api/v1/persistentvolumes/{name}/status func (s *Server) handleReadCoreV1PersistentVolumeStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readCoreV1PersistentVolumeStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45121,7 +53083,16 @@ func (s *Server) handleReadCoreV1PersistentVolumeStatusRequest(args [1]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45133,8 +53104,27 @@ func (s *Server) handleReadCoreV1PersistentVolumeStatusRequest(args [1]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45260,6 +53250,8 @@ func (s *Server) handleReadCoreV1PersistentVolumeStatusRequest(args [1]string, a // // GET /apis/discovery.k8s.io/v1/namespaces/{namespace}/endpointslices/{name} func (s *Server) handleReadDiscoveryV1NamespacedEndpointSliceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readDiscoveryV1NamespacedEndpointSlice"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45281,7 +53273,16 @@ func (s *Server) handleReadDiscoveryV1NamespacedEndpointSliceRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45293,8 +53294,27 @@ func (s *Server) handleReadDiscoveryV1NamespacedEndpointSliceRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45424,6 +53444,8 @@ func (s *Server) handleReadDiscoveryV1NamespacedEndpointSliceRequest(args [2]str // // GET /apis/discovery.k8s.io/v1beta1/namespaces/{namespace}/endpointslices/{name} func (s *Server) handleReadDiscoveryV1beta1NamespacedEndpointSliceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readDiscoveryV1beta1NamespacedEndpointSlice"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45445,7 +53467,16 @@ func (s *Server) handleReadDiscoveryV1beta1NamespacedEndpointSliceRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45457,8 +53488,27 @@ func (s *Server) handleReadDiscoveryV1beta1NamespacedEndpointSliceRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45588,6 +53638,8 @@ func (s *Server) handleReadDiscoveryV1beta1NamespacedEndpointSliceRequest(args [ // // GET /apis/events.k8s.io/v1/namespaces/{namespace}/events/{name} func (s *Server) handleReadEventsV1NamespacedEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readEventsV1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45609,7 +53661,16 @@ func (s *Server) handleReadEventsV1NamespacedEventRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45621,8 +53682,27 @@ func (s *Server) handleReadEventsV1NamespacedEventRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45752,6 +53832,8 @@ func (s *Server) handleReadEventsV1NamespacedEventRequest(args [2]string, argsEs // // GET /apis/events.k8s.io/v1beta1/namespaces/{namespace}/events/{name} func (s *Server) handleReadEventsV1beta1NamespacedEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readEventsV1beta1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45773,7 +53855,16 @@ func (s *Server) handleReadEventsV1beta1NamespacedEventRequest(args [2]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45785,8 +53876,27 @@ func (s *Server) handleReadEventsV1beta1NamespacedEventRequest(args [2]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45916,6 +54026,8 @@ func (s *Server) handleReadEventsV1beta1NamespacedEventRequest(args [2]string, a // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/flowschemas/{name} func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta1FlowSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45937,7 +54049,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45949,8 +54070,27 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46076,6 +54216,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1] // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/flowschemas/{name}/status func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta1FlowSchemaStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46097,7 +54239,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaStatusRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46109,180 +54260,229 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1FlowSchemaStatusRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ReadFlowcontrolApiserverV1beta1FlowSchemaStatusOperation, - ID: "readFlowcontrolApiserverV1beta1FlowSchemaStatus", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ReadFlowcontrolApiserverV1beta1FlowSchemaStatusOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeReadFlowcontrolApiserverV1beta1FlowSchemaStatusParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response ReadFlowcontrolApiserverV1beta1FlowSchemaStatusRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ReadFlowcontrolApiserverV1beta1FlowSchemaStatusOperation, - OperationSummary: "", - OperationID: "readFlowcontrolApiserverV1beta1FlowSchemaStatus", - Body: nil, - Params: middleware.Parameters{ - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "pretty", - In: "query", - }: params.Pretty, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ReadFlowcontrolApiserverV1beta1FlowSchemaStatusParams - Response = ReadFlowcontrolApiserverV1beta1FlowSchemaStatusRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackReadFlowcontrolApiserverV1beta1FlowSchemaStatusParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ReadFlowcontrolApiserverV1beta1FlowSchemaStatus(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ReadFlowcontrolApiserverV1beta1FlowSchemaStatus(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeReadFlowcontrolApiserverV1beta1FlowSchemaStatusResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationRequest handles readFlowcontrolApiserverV1beta1PriorityLevelConfiguration operation. -// -// Read the specified PriorityLevelConfiguration. -// -// GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/prioritylevelconfigurations/{name} -func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("readFlowcontrolApiserverV1beta1PriorityLevelConfiguration"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/flowcontrol.apiserver.k8s.io/v1beta1/prioritylevelconfigurations/{name}"), - } - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationOperation, - ID: "readFlowcontrolApiserverV1beta1PriorityLevelConfiguration", + Name: ReadFlowcontrolApiserverV1beta1FlowSchemaStatusOperation, + ID: "readFlowcontrolApiserverV1beta1FlowSchemaStatus", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ReadFlowcontrolApiserverV1beta1FlowSchemaStatusOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeReadFlowcontrolApiserverV1beta1FlowSchemaStatusParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ReadFlowcontrolApiserverV1beta1FlowSchemaStatusRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ReadFlowcontrolApiserverV1beta1FlowSchemaStatusOperation, + OperationSummary: "", + OperationID: "readFlowcontrolApiserverV1beta1FlowSchemaStatus", + Body: nil, + Params: middleware.Parameters{ + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ReadFlowcontrolApiserverV1beta1FlowSchemaStatusParams + Response = ReadFlowcontrolApiserverV1beta1FlowSchemaStatusRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackReadFlowcontrolApiserverV1beta1FlowSchemaStatusParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ReadFlowcontrolApiserverV1beta1FlowSchemaStatus(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ReadFlowcontrolApiserverV1beta1FlowSchemaStatus(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeReadFlowcontrolApiserverV1beta1FlowSchemaStatusResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationRequest handles readFlowcontrolApiserverV1beta1PriorityLevelConfiguration operation. +// +// Read the specified PriorityLevelConfiguration. +// +// GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/prioritylevelconfigurations/{name} +func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readFlowcontrolApiserverV1beta1PriorityLevelConfiguration"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/flowcontrol.apiserver.k8s.io/v1beta1/prioritylevelconfigurations/{name}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationOperation, + ID: "readFlowcontrolApiserverV1beta1PriorityLevelConfiguration", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -46396,6 +54596,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfiguration // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/prioritylevelconfigurations/{name}/status func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfigurationStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta1PriorityLevelConfigurationStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46417,7 +54619,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46429,8 +54640,27 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46556,6 +54786,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta1PriorityLevelConfiguration // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/flowschemas/{name} func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta2FlowSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46577,7 +54809,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46589,8 +54830,27 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46716,6 +54976,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1] // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/flowschemas/{name}/status func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta2FlowSchemaStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46737,7 +54999,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaStatusRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46749,8 +55020,27 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaStatusRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46876,6 +55166,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2FlowSchemaStatusRequest(ar // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/prioritylevelconfigurations/{name} func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta2PriorityLevelConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46897,7 +55189,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46909,8 +55210,27 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47036,6 +55356,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfiguration // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/prioritylevelconfigurations/{name}/status func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfigurationStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readFlowcontrolApiserverV1beta2PriorityLevelConfigurationStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47057,7 +55379,16 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfiguration startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47069,8 +55400,27 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfiguration var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47196,6 +55546,8 @@ func (s *Server) handleReadFlowcontrolApiserverV1beta2PriorityLevelConfiguration // // GET /apis/internal.apiserver.k8s.io/v1alpha1/storageversions/{name} func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readInternalApiserverV1alpha1StorageVersion"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47217,7 +55569,16 @@ func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47229,8 +55590,27 @@ func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47356,6 +55736,8 @@ func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionRequest(args [ // // GET /apis/internal.apiserver.k8s.io/v1alpha1/storageversions/{name}/status func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readInternalApiserverV1alpha1StorageVersionStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47377,7 +55759,16 @@ func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionStatusRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47389,8 +55780,27 @@ func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionStatusRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47516,6 +55926,8 @@ func (s *Server) handleReadInternalApiserverV1alpha1StorageVersionStatusRequest( // // GET /apis/networking.k8s.io/v1/ingressclasses/{name} func (s *Server) handleReadNetworkingV1IngressClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNetworkingV1IngressClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47537,7 +55949,16 @@ func (s *Server) handleReadNetworkingV1IngressClassRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47549,8 +55970,27 @@ func (s *Server) handleReadNetworkingV1IngressClassRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47676,6 +56116,8 @@ func (s *Server) handleReadNetworkingV1IngressClassRequest(args [1]string, argsE // // GET /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name} func (s *Server) handleReadNetworkingV1NamespacedIngressRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNetworkingV1NamespacedIngress"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47697,7 +56139,16 @@ func (s *Server) handleReadNetworkingV1NamespacedIngressRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47709,8 +56160,27 @@ func (s *Server) handleReadNetworkingV1NamespacedIngressRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47840,6 +56310,8 @@ func (s *Server) handleReadNetworkingV1NamespacedIngressRequest(args [2]string, // // GET /apis/networking.k8s.io/v1/namespaces/{namespace}/ingresses/{name}/status func (s *Server) handleReadNetworkingV1NamespacedIngressStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNetworkingV1NamespacedIngressStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47861,7 +56333,16 @@ func (s *Server) handleReadNetworkingV1NamespacedIngressStatusRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47873,8 +56354,27 @@ func (s *Server) handleReadNetworkingV1NamespacedIngressStatusRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48004,6 +56504,8 @@ func (s *Server) handleReadNetworkingV1NamespacedIngressStatusRequest(args [2]st // // GET /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name} func (s *Server) handleReadNetworkingV1NamespacedNetworkPolicyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNetworkingV1NamespacedNetworkPolicy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48025,7 +56527,16 @@ func (s *Server) handleReadNetworkingV1NamespacedNetworkPolicyRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48037,8 +56548,27 @@ func (s *Server) handleReadNetworkingV1NamespacedNetworkPolicyRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48168,6 +56698,8 @@ func (s *Server) handleReadNetworkingV1NamespacedNetworkPolicyRequest(args [2]st // // GET /apis/node.k8s.io/v1/runtimeclasses/{name} func (s *Server) handleReadNodeV1RuntimeClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNodeV1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48189,7 +56721,16 @@ func (s *Server) handleReadNodeV1RuntimeClassRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48201,8 +56742,27 @@ func (s *Server) handleReadNodeV1RuntimeClassRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48328,6 +56888,8 @@ func (s *Server) handleReadNodeV1RuntimeClassRequest(args [1]string, argsEscaped // // GET /apis/node.k8s.io/v1alpha1/runtimeclasses/{name} func (s *Server) handleReadNodeV1alpha1RuntimeClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNodeV1alpha1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48349,7 +56911,16 @@ func (s *Server) handleReadNodeV1alpha1RuntimeClassRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48361,8 +56932,27 @@ func (s *Server) handleReadNodeV1alpha1RuntimeClassRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48488,6 +57078,8 @@ func (s *Server) handleReadNodeV1alpha1RuntimeClassRequest(args [1]string, argsE // // GET /apis/node.k8s.io/v1beta1/runtimeclasses/{name} func (s *Server) handleReadNodeV1beta1RuntimeClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readNodeV1beta1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48509,7 +57101,16 @@ func (s *Server) handleReadNodeV1beta1RuntimeClassRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48521,8 +57122,27 @@ func (s *Server) handleReadNodeV1beta1RuntimeClassRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48648,6 +57268,8 @@ func (s *Server) handleReadNodeV1beta1RuntimeClassRequest(args [1]string, argsEs // // GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name} func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPolicyV1NamespacedPodDisruptionBudget"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48669,7 +57291,16 @@ func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetRequest(args [2] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48681,8 +57312,27 @@ func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetRequest(args [2] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48812,6 +57462,8 @@ func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetRequest(args [2] // // GET /apis/policy/v1/namespaces/{namespace}/poddisruptionbudgets/{name}/status func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPolicyV1NamespacedPodDisruptionBudgetStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48833,7 +57485,16 @@ func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetStatusRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48845,8 +57506,27 @@ func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetStatusRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48976,6 +57656,8 @@ func (s *Server) handleReadPolicyV1NamespacedPodDisruptionBudgetStatusRequest(ar // // GET /apis/policy/v1beta1/namespaces/{namespace}/poddisruptionbudgets/{name} func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPolicyV1beta1NamespacedPodDisruptionBudget"), semconv.HTTPRequestMethodKey.String("GET"), @@ -48997,7 +57679,16 @@ func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49009,8 +57700,27 @@ func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49140,6 +57850,8 @@ func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetRequest(arg // // GET /apis/policy/v1beta1/namespaces/{namespace}/poddisruptionbudgets/{name}/status func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetStatusRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPolicyV1beta1NamespacedPodDisruptionBudgetStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49161,7 +57873,16 @@ func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetStatusReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49173,8 +57894,27 @@ func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetStatusReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49304,6 +58044,8 @@ func (s *Server) handleReadPolicyV1beta1NamespacedPodDisruptionBudgetStatusReque // // GET /apis/policy/v1beta1/podsecuritypolicies/{name} func (s *Server) handleReadPolicyV1beta1PodSecurityPolicyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readPolicyV1beta1PodSecurityPolicy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49325,7 +58067,16 @@ func (s *Server) handleReadPolicyV1beta1PodSecurityPolicyRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49337,8 +58088,27 @@ func (s *Server) handleReadPolicyV1beta1PodSecurityPolicyRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49464,6 +58234,8 @@ func (s *Server) handleReadPolicyV1beta1PodSecurityPolicyRequest(args [1]string, // // GET /apis/rbac.authorization.k8s.io/v1/clusterroles/{name} func (s *Server) handleReadRbacAuthorizationV1ClusterRoleRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readRbacAuthorizationV1ClusterRole"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49485,7 +58257,16 @@ func (s *Server) handleReadRbacAuthorizationV1ClusterRoleRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49497,8 +58278,27 @@ func (s *Server) handleReadRbacAuthorizationV1ClusterRoleRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49624,6 +58424,8 @@ func (s *Server) handleReadRbacAuthorizationV1ClusterRoleRequest(args [1]string, // // GET /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/{name} func (s *Server) handleReadRbacAuthorizationV1ClusterRoleBindingRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readRbacAuthorizationV1ClusterRoleBinding"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49645,7 +58447,16 @@ func (s *Server) handleReadRbacAuthorizationV1ClusterRoleBindingRequest(args [1] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49657,8 +58468,27 @@ func (s *Server) handleReadRbacAuthorizationV1ClusterRoleBindingRequest(args [1] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49784,6 +58614,8 @@ func (s *Server) handleReadRbacAuthorizationV1ClusterRoleBindingRequest(args [1] // // GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/roles/{name} func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readRbacAuthorizationV1NamespacedRole"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49805,7 +58637,16 @@ func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleRequest(args [2]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49817,8 +58658,27 @@ func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleRequest(args [2]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49948,6 +58808,8 @@ func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleRequest(args [2]stri // // GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name} func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleBindingRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readRbacAuthorizationV1NamespacedRoleBinding"), semconv.HTTPRequestMethodKey.String("GET"), @@ -49969,7 +58831,16 @@ func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleBindingRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49981,8 +58852,27 @@ func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleBindingRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50112,6 +59002,8 @@ func (s *Server) handleReadRbacAuthorizationV1NamespacedRoleBindingRequest(args // // GET /apis/scheduling.k8s.io/v1/priorityclasses/{name} func (s *Server) handleReadSchedulingV1PriorityClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readSchedulingV1PriorityClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50133,7 +59025,16 @@ func (s *Server) handleReadSchedulingV1PriorityClassRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50145,8 +59046,27 @@ func (s *Server) handleReadSchedulingV1PriorityClassRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50272,6 +59192,8 @@ func (s *Server) handleReadSchedulingV1PriorityClassRequest(args [1]string, args // // GET /apis/storage.k8s.io/v1/csidrivers/{name} func (s *Server) handleReadStorageV1CSIDriverRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readStorageV1CSIDriver"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50293,7 +59215,16 @@ func (s *Server) handleReadStorageV1CSIDriverRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50305,180 +59236,229 @@ func (s *Server) handleReadStorageV1CSIDriverRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: ReadStorageV1CSIDriverOperation, - ID: "readStorageV1CSIDriver", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, ReadStorageV1CSIDriverOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeReadStorageV1CSIDriverParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response ReadStorageV1CSIDriverRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: ReadStorageV1CSIDriverOperation, - OperationSummary: "", - OperationID: "readStorageV1CSIDriver", - Body: nil, - Params: middleware.Parameters{ - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "pretty", - In: "query", - }: params.Pretty, - }, - Raw: r, - } - - type ( - Request = struct{} - Params = ReadStorageV1CSIDriverParams - Response = ReadStorageV1CSIDriverRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackReadStorageV1CSIDriverParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.ReadStorageV1CSIDriver(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.ReadStorageV1CSIDriver(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeReadStorageV1CSIDriverResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleReadStorageV1CSINodeRequest handles readStorageV1CSINode operation. -// -// Read the specified CSINode. -// -// GET /apis/storage.k8s.io/v1/csinodes/{name} -func (s *Server) handleReadStorageV1CSINodeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("readStorageV1CSINode"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/storage.k8s.io/v1/csinodes/{name}"), - } - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), ReadStorageV1CSINodeOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: ReadStorageV1CSINodeOperation, - ID: "readStorageV1CSINode", + Name: ReadStorageV1CSIDriverOperation, + ID: "readStorageV1CSIDriver", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, ReadStorageV1CSINodeOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, ReadStorageV1CSIDriverOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeReadStorageV1CSIDriverParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ReadStorageV1CSIDriverRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: ReadStorageV1CSIDriverOperation, + OperationSummary: "", + OperationID: "readStorageV1CSIDriver", + Body: nil, + Params: middleware.Parameters{ + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "pretty", + In: "query", + }: params.Pretty, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ReadStorageV1CSIDriverParams + Response = ReadStorageV1CSIDriverRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackReadStorageV1CSIDriverParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ReadStorageV1CSIDriver(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ReadStorageV1CSIDriver(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeReadStorageV1CSIDriverResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleReadStorageV1CSINodeRequest handles readStorageV1CSINode operation. +// +// Read the specified CSINode. +// +// GET /apis/storage.k8s.io/v1/csinodes/{name} +func (s *Server) handleReadStorageV1CSINodeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("readStorageV1CSINode"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/storage.k8s.io/v1/csinodes/{name}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), ReadStorageV1CSINodeOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: ReadStorageV1CSINodeOperation, + ID: "readStorageV1CSINode", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, ReadStorageV1CSINodeOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -50592,6 +59572,8 @@ func (s *Server) handleReadStorageV1CSINodeRequest(args [1]string, argsEscaped b // // GET /apis/storage.k8s.io/v1/storageclasses/{name} func (s *Server) handleReadStorageV1StorageClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readStorageV1StorageClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50613,7 +59595,16 @@ func (s *Server) handleReadStorageV1StorageClassRequest(args [1]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50625,8 +59616,27 @@ func (s *Server) handleReadStorageV1StorageClassRequest(args [1]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50752,6 +59762,8 @@ func (s *Server) handleReadStorageV1StorageClassRequest(args [1]string, argsEsca // // GET /apis/storage.k8s.io/v1/volumeattachments/{name} func (s *Server) handleReadStorageV1VolumeAttachmentRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readStorageV1VolumeAttachment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50773,7 +59785,16 @@ func (s *Server) handleReadStorageV1VolumeAttachmentRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50785,8 +59806,27 @@ func (s *Server) handleReadStorageV1VolumeAttachmentRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50912,6 +59952,8 @@ func (s *Server) handleReadStorageV1VolumeAttachmentRequest(args [1]string, args // // GET /apis/storage.k8s.io/v1/volumeattachments/{name}/status func (s *Server) handleReadStorageV1VolumeAttachmentStatusRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readStorageV1VolumeAttachmentStatus"), semconv.HTTPRequestMethodKey.String("GET"), @@ -50933,7 +59975,16 @@ func (s *Server) handleReadStorageV1VolumeAttachmentStatusRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50945,8 +59996,27 @@ func (s *Server) handleReadStorageV1VolumeAttachmentStatusRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51072,6 +60142,8 @@ func (s *Server) handleReadStorageV1VolumeAttachmentStatusRequest(args [1]string // // GET /apis/storage.k8s.io/v1alpha1/namespaces/{namespace}/csistoragecapacities/{name} func (s *Server) handleReadStorageV1alpha1NamespacedCSIStorageCapacityRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readStorageV1alpha1NamespacedCSIStorageCapacity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51093,7 +60165,16 @@ func (s *Server) handleReadStorageV1alpha1NamespacedCSIStorageCapacityRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51105,8 +60186,27 @@ func (s *Server) handleReadStorageV1alpha1NamespacedCSIStorageCapacityRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51236,6 +60336,8 @@ func (s *Server) handleReadStorageV1alpha1NamespacedCSIStorageCapacityRequest(ar // // GET /apis/storage.k8s.io/v1beta1/namespaces/{namespace}/csistoragecapacities/{name} func (s *Server) handleReadStorageV1beta1NamespacedCSIStorageCapacityRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("readStorageV1beta1NamespacedCSIStorageCapacity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51257,7 +60359,16 @@ func (s *Server) handleReadStorageV1beta1NamespacedCSIStorageCapacityRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51269,8 +60380,27 @@ func (s *Server) handleReadStorageV1beta1NamespacedCSIStorageCapacityRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51402,6 +60532,8 @@ func (s *Server) handleReadStorageV1beta1NamespacedCSIStorageCapacityRequest(arg // // GET /apis/admissionregistration.k8s.io/v1/watch/mutatingwebhookconfigurations/{name} func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAdmissionregistrationV1MutatingWebhookConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51423,7 +60555,16 @@ func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51435,8 +60576,27 @@ func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51599,6 +60759,8 @@ func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationR // // GET /apis/admissionregistration.k8s.io/v1/watch/mutatingwebhookconfigurations func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAdmissionregistrationV1MutatingWebhookConfigurationList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51620,7 +60782,16 @@ func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationL startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51632,8 +60803,27 @@ func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationL var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51793,6 +60983,8 @@ func (s *Server) handleWatchAdmissionregistrationV1MutatingWebhookConfigurationL // // GET /apis/admissionregistration.k8s.io/v1/watch/validatingwebhookconfigurations/{name} func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAdmissionregistrationV1ValidatingWebhookConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -51814,7 +61006,16 @@ func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfiguratio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51826,8 +61027,27 @@ func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfiguratio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51990,6 +61210,8 @@ func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfiguratio // // GET /apis/admissionregistration.k8s.io/v1/watch/validatingwebhookconfigurations func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfigurationListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAdmissionregistrationV1ValidatingWebhookConfigurationList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52011,7 +61233,16 @@ func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfiguratio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52023,8 +61254,27 @@ func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfiguratio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52183,6 +61433,8 @@ func (s *Server) handleWatchAdmissionregistrationV1ValidatingWebhookConfiguratio // // GET /apis/apiextensions.k8s.io/v1/watch/customresourcedefinitions/{name} func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchApiextensionsV1CustomResourceDefinition"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52204,7 +61456,16 @@ func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52216,8 +61477,27 @@ func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52380,6 +61660,8 @@ func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionRequest(args // // GET /apis/apiextensions.k8s.io/v1/watch/customresourcedefinitions func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchApiextensionsV1CustomResourceDefinitionList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52401,7 +61683,16 @@ func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionListRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52413,8 +61704,27 @@ func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionListRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52573,6 +61883,8 @@ func (s *Server) handleWatchApiextensionsV1CustomResourceDefinitionListRequest(a // // GET /apis/apiregistration.k8s.io/v1/watch/apiservices/{name} func (s *Server) handleWatchApiregistrationV1APIServiceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchApiregistrationV1APIService"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52594,7 +61906,16 @@ func (s *Server) handleWatchApiregistrationV1APIServiceRequest(args [1]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52606,8 +61927,27 @@ func (s *Server) handleWatchApiregistrationV1APIServiceRequest(args [1]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52770,6 +62110,8 @@ func (s *Server) handleWatchApiregistrationV1APIServiceRequest(args [1]string, a // // GET /apis/apiregistration.k8s.io/v1/watch/apiservices func (s *Server) handleWatchApiregistrationV1APIServiceListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchApiregistrationV1APIServiceList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52791,7 +62133,16 @@ func (s *Server) handleWatchApiregistrationV1APIServiceListRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52803,8 +62154,27 @@ func (s *Server) handleWatchApiregistrationV1APIServiceListRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52963,6 +62333,8 @@ func (s *Server) handleWatchApiregistrationV1APIServiceListRequest(args [0]strin // // GET /apis/apps/v1/watch/controllerrevisions func (s *Server) handleWatchAppsV1ControllerRevisionListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1ControllerRevisionListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52984,7 +62356,16 @@ func (s *Server) handleWatchAppsV1ControllerRevisionListForAllNamespacesRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52996,8 +62377,27 @@ func (s *Server) handleWatchAppsV1ControllerRevisionListForAllNamespacesRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53156,6 +62556,8 @@ func (s *Server) handleWatchAppsV1ControllerRevisionListForAllNamespacesRequest( // // GET /apis/apps/v1/watch/daemonsets func (s *Server) handleWatchAppsV1DaemonSetListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1DaemonSetListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53177,7 +62579,16 @@ func (s *Server) handleWatchAppsV1DaemonSetListForAllNamespacesRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53189,8 +62600,27 @@ func (s *Server) handleWatchAppsV1DaemonSetListForAllNamespacesRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53349,6 +62779,8 @@ func (s *Server) handleWatchAppsV1DaemonSetListForAllNamespacesRequest(args [0]s // // GET /apis/apps/v1/watch/deployments func (s *Server) handleWatchAppsV1DeploymentListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1DeploymentListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53370,7 +62802,16 @@ func (s *Server) handleWatchAppsV1DeploymentListForAllNamespacesRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53382,8 +62823,27 @@ func (s *Server) handleWatchAppsV1DeploymentListForAllNamespacesRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53542,6 +63002,8 @@ func (s *Server) handleWatchAppsV1DeploymentListForAllNamespacesRequest(args [0] // // GET /apis/apps/v1/watch/namespaces/{namespace}/controllerrevisions/{name} func (s *Server) handleWatchAppsV1NamespacedControllerRevisionRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedControllerRevision"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53563,7 +63025,16 @@ func (s *Server) handleWatchAppsV1NamespacedControllerRevisionRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53575,8 +63046,27 @@ func (s *Server) handleWatchAppsV1NamespacedControllerRevisionRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53743,6 +63233,8 @@ func (s *Server) handleWatchAppsV1NamespacedControllerRevisionRequest(args [2]st // // GET /apis/apps/v1/watch/namespaces/{namespace}/controllerrevisions func (s *Server) handleWatchAppsV1NamespacedControllerRevisionListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedControllerRevisionList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53764,7 +63256,16 @@ func (s *Server) handleWatchAppsV1NamespacedControllerRevisionListRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53776,8 +63277,27 @@ func (s *Server) handleWatchAppsV1NamespacedControllerRevisionListRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53940,6 +63460,8 @@ func (s *Server) handleWatchAppsV1NamespacedControllerRevisionListRequest(args [ // // GET /apis/apps/v1/watch/namespaces/{namespace}/daemonsets/{name} func (s *Server) handleWatchAppsV1NamespacedDaemonSetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedDaemonSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -53961,7 +63483,16 @@ func (s *Server) handleWatchAppsV1NamespacedDaemonSetRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53973,8 +63504,27 @@ func (s *Server) handleWatchAppsV1NamespacedDaemonSetRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54141,6 +63691,8 @@ func (s *Server) handleWatchAppsV1NamespacedDaemonSetRequest(args [2]string, arg // // GET /apis/apps/v1/watch/namespaces/{namespace}/daemonsets func (s *Server) handleWatchAppsV1NamespacedDaemonSetListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedDaemonSetList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54162,7 +63714,16 @@ func (s *Server) handleWatchAppsV1NamespacedDaemonSetListRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54174,8 +63735,27 @@ func (s *Server) handleWatchAppsV1NamespacedDaemonSetListRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54338,6 +63918,8 @@ func (s *Server) handleWatchAppsV1NamespacedDaemonSetListRequest(args [1]string, // // GET /apis/apps/v1/watch/namespaces/{namespace}/deployments/{name} func (s *Server) handleWatchAppsV1NamespacedDeploymentRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedDeployment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54359,7 +63941,16 @@ func (s *Server) handleWatchAppsV1NamespacedDeploymentRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54371,8 +63962,27 @@ func (s *Server) handleWatchAppsV1NamespacedDeploymentRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54539,6 +64149,8 @@ func (s *Server) handleWatchAppsV1NamespacedDeploymentRequest(args [2]string, ar // // GET /apis/apps/v1/watch/namespaces/{namespace}/deployments func (s *Server) handleWatchAppsV1NamespacedDeploymentListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedDeploymentList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54560,7 +64172,16 @@ func (s *Server) handleWatchAppsV1NamespacedDeploymentListRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54572,8 +64193,27 @@ func (s *Server) handleWatchAppsV1NamespacedDeploymentListRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54736,6 +64376,8 @@ func (s *Server) handleWatchAppsV1NamespacedDeploymentListRequest(args [1]string // // GET /apis/apps/v1/watch/namespaces/{namespace}/replicasets/{name} func (s *Server) handleWatchAppsV1NamespacedReplicaSetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedReplicaSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54757,7 +64399,16 @@ func (s *Server) handleWatchAppsV1NamespacedReplicaSetRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54769,8 +64420,27 @@ func (s *Server) handleWatchAppsV1NamespacedReplicaSetRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54937,6 +64607,8 @@ func (s *Server) handleWatchAppsV1NamespacedReplicaSetRequest(args [2]string, ar // // GET /apis/apps/v1/watch/namespaces/{namespace}/replicasets func (s *Server) handleWatchAppsV1NamespacedReplicaSetListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedReplicaSetList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -54958,7 +64630,16 @@ func (s *Server) handleWatchAppsV1NamespacedReplicaSetListRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54970,8 +64651,27 @@ func (s *Server) handleWatchAppsV1NamespacedReplicaSetListRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55134,6 +64834,8 @@ func (s *Server) handleWatchAppsV1NamespacedReplicaSetListRequest(args [1]string // // GET /apis/apps/v1/watch/namespaces/{namespace}/statefulsets/{name} func (s *Server) handleWatchAppsV1NamespacedStatefulSetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedStatefulSet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -55155,7 +64857,16 @@ func (s *Server) handleWatchAppsV1NamespacedStatefulSetRequest(args [2]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55167,8 +64878,27 @@ func (s *Server) handleWatchAppsV1NamespacedStatefulSetRequest(args [2]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55335,6 +65065,8 @@ func (s *Server) handleWatchAppsV1NamespacedStatefulSetRequest(args [2]string, a // // GET /apis/apps/v1/watch/namespaces/{namespace}/statefulsets func (s *Server) handleWatchAppsV1NamespacedStatefulSetListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1NamespacedStatefulSetList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -55356,7 +65088,16 @@ func (s *Server) handleWatchAppsV1NamespacedStatefulSetListRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55368,8 +65109,27 @@ func (s *Server) handleWatchAppsV1NamespacedStatefulSetListRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55532,6 +65292,8 @@ func (s *Server) handleWatchAppsV1NamespacedStatefulSetListRequest(args [1]strin // // GET /apis/apps/v1/watch/replicasets func (s *Server) handleWatchAppsV1ReplicaSetListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1ReplicaSetListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -55553,7 +65315,16 @@ func (s *Server) handleWatchAppsV1ReplicaSetListForAllNamespacesRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55565,8 +65336,27 @@ func (s *Server) handleWatchAppsV1ReplicaSetListForAllNamespacesRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55725,6 +65515,8 @@ func (s *Server) handleWatchAppsV1ReplicaSetListForAllNamespacesRequest(args [0] // // GET /apis/apps/v1/watch/statefulsets func (s *Server) handleWatchAppsV1StatefulSetListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAppsV1StatefulSetListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -55746,7 +65538,16 @@ func (s *Server) handleWatchAppsV1StatefulSetListForAllNamespacesRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55758,8 +65559,27 @@ func (s *Server) handleWatchAppsV1StatefulSetListForAllNamespacesRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55918,6 +65738,8 @@ func (s *Server) handleWatchAppsV1StatefulSetListForAllNamespacesRequest(args [0 // // GET /apis/autoscaling/v1/watch/horizontalpodautoscalers func (s *Server) handleWatchAutoscalingV1HorizontalPodAutoscalerListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV1HorizontalPodAutoscalerListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -55939,7 +65761,16 @@ func (s *Server) handleWatchAutoscalingV1HorizontalPodAutoscalerListForAllNamesp startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55951,8 +65782,27 @@ func (s *Server) handleWatchAutoscalingV1HorizontalPodAutoscalerListForAllNamesp var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56111,6 +65961,8 @@ func (s *Server) handleWatchAutoscalingV1HorizontalPodAutoscalerListForAllNamesp // // GET /apis/autoscaling/v1/watch/namespaces/{namespace}/horizontalpodautoscalers/{name} func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV1NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -56132,7 +65984,16 @@ func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56144,8 +66005,27 @@ func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56312,6 +66192,8 @@ func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerReques // // GET /apis/autoscaling/v1/watch/namespaces/{namespace}/horizontalpodautoscalers func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV1NamespacedHorizontalPodAutoscalerList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -56333,7 +66215,16 @@ func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerListRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56345,8 +66236,27 @@ func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerListRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56509,6 +66419,8 @@ func (s *Server) handleWatchAutoscalingV1NamespacedHorizontalPodAutoscalerListRe // // GET /apis/autoscaling/v2beta1/watch/horizontalpodautoscalers func (s *Server) handleWatchAutoscalingV2beta1HorizontalPodAutoscalerListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV2beta1HorizontalPodAutoscalerListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -56530,7 +66442,16 @@ func (s *Server) handleWatchAutoscalingV2beta1HorizontalPodAutoscalerListForAllN startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56542,8 +66463,27 @@ func (s *Server) handleWatchAutoscalingV2beta1HorizontalPodAutoscalerListForAllN var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56702,6 +66642,8 @@ func (s *Server) handleWatchAutoscalingV2beta1HorizontalPodAutoscalerListForAllN // // GET /apis/autoscaling/v2beta1/watch/namespaces/{namespace}/horizontalpodautoscalers/{name} func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV2beta1NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -56723,7 +66665,16 @@ func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56735,8 +66686,27 @@ func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56903,6 +66873,8 @@ func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerR // // GET /apis/autoscaling/v2beta1/watch/namespaces/{namespace}/horizontalpodautoscalers func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -56924,7 +66896,16 @@ func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerL startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56936,8 +66917,27 @@ func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerL var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57100,6 +67100,8 @@ func (s *Server) handleWatchAutoscalingV2beta1NamespacedHorizontalPodAutoscalerL // // GET /apis/autoscaling/v2beta2/watch/horizontalpodautoscalers func (s *Server) handleWatchAutoscalingV2beta2HorizontalPodAutoscalerListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV2beta2HorizontalPodAutoscalerListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57121,7 +67123,16 @@ func (s *Server) handleWatchAutoscalingV2beta2HorizontalPodAutoscalerListForAllN startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57133,8 +67144,27 @@ func (s *Server) handleWatchAutoscalingV2beta2HorizontalPodAutoscalerListForAllN var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57293,6 +67323,8 @@ func (s *Server) handleWatchAutoscalingV2beta2HorizontalPodAutoscalerListForAllN // // GET /apis/autoscaling/v2beta2/watch/namespaces/{namespace}/horizontalpodautoscalers/{name} func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV2beta2NamespacedHorizontalPodAutoscaler"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57314,7 +67346,16 @@ func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerR startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57326,8 +67367,27 @@ func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerR var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57494,6 +67554,8 @@ func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerR // // GET /apis/autoscaling/v2beta2/watch/namespaces/{namespace}/horizontalpodautoscalers func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57515,7 +67577,16 @@ func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerL startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57527,8 +67598,27 @@ func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerL var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57691,6 +67781,8 @@ func (s *Server) handleWatchAutoscalingV2beta2NamespacedHorizontalPodAutoscalerL // // GET /apis/batch/v1/watch/cronjobs func (s *Server) handleWatchBatchV1CronJobListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1CronJobListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57712,7 +67804,16 @@ func (s *Server) handleWatchBatchV1CronJobListForAllNamespacesRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57724,8 +67825,27 @@ func (s *Server) handleWatchBatchV1CronJobListForAllNamespacesRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57884,6 +68004,8 @@ func (s *Server) handleWatchBatchV1CronJobListForAllNamespacesRequest(args [0]st // // GET /apis/batch/v1/watch/jobs func (s *Server) handleWatchBatchV1JobListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1JobListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -57905,7 +68027,16 @@ func (s *Server) handleWatchBatchV1JobListForAllNamespacesRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57917,8 +68048,27 @@ func (s *Server) handleWatchBatchV1JobListForAllNamespacesRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58077,6 +68227,8 @@ func (s *Server) handleWatchBatchV1JobListForAllNamespacesRequest(args [0]string // // GET /apis/batch/v1/watch/namespaces/{namespace}/cronjobs/{name} func (s *Server) handleWatchBatchV1NamespacedCronJobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1NamespacedCronJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58098,7 +68250,16 @@ func (s *Server) handleWatchBatchV1NamespacedCronJobRequest(args [2]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58110,8 +68271,27 @@ func (s *Server) handleWatchBatchV1NamespacedCronJobRequest(args [2]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58278,6 +68458,8 @@ func (s *Server) handleWatchBatchV1NamespacedCronJobRequest(args [2]string, args // // GET /apis/batch/v1/watch/namespaces/{namespace}/cronjobs func (s *Server) handleWatchBatchV1NamespacedCronJobListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1NamespacedCronJobList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58299,7 +68481,16 @@ func (s *Server) handleWatchBatchV1NamespacedCronJobListRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58311,8 +68502,27 @@ func (s *Server) handleWatchBatchV1NamespacedCronJobListRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58475,6 +68685,8 @@ func (s *Server) handleWatchBatchV1NamespacedCronJobListRequest(args [1]string, // // GET /apis/batch/v1/watch/namespaces/{namespace}/jobs/{name} func (s *Server) handleWatchBatchV1NamespacedJobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1NamespacedJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58496,7 +68708,16 @@ func (s *Server) handleWatchBatchV1NamespacedJobRequest(args [2]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58508,8 +68729,27 @@ func (s *Server) handleWatchBatchV1NamespacedJobRequest(args [2]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58676,6 +68916,8 @@ func (s *Server) handleWatchBatchV1NamespacedJobRequest(args [2]string, argsEsca // // GET /apis/batch/v1/watch/namespaces/{namespace}/jobs func (s *Server) handleWatchBatchV1NamespacedJobListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1NamespacedJobList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58697,7 +68939,16 @@ func (s *Server) handleWatchBatchV1NamespacedJobListRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58709,8 +68960,27 @@ func (s *Server) handleWatchBatchV1NamespacedJobListRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58873,6 +69143,8 @@ func (s *Server) handleWatchBatchV1NamespacedJobListRequest(args [1]string, args // // GET /apis/batch/v1beta1/watch/cronjobs func (s *Server) handleWatchBatchV1beta1CronJobListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1beta1CronJobListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -58894,7 +69166,16 @@ func (s *Server) handleWatchBatchV1beta1CronJobListForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58906,8 +69187,27 @@ func (s *Server) handleWatchBatchV1beta1CronJobListForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59066,6 +69366,8 @@ func (s *Server) handleWatchBatchV1beta1CronJobListForAllNamespacesRequest(args // // GET /apis/batch/v1beta1/watch/namespaces/{namespace}/cronjobs/{name} func (s *Server) handleWatchBatchV1beta1NamespacedCronJobRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1beta1NamespacedCronJob"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59087,7 +69389,16 @@ func (s *Server) handleWatchBatchV1beta1NamespacedCronJobRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59099,8 +69410,27 @@ func (s *Server) handleWatchBatchV1beta1NamespacedCronJobRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59267,6 +69597,8 @@ func (s *Server) handleWatchBatchV1beta1NamespacedCronJobRequest(args [2]string, // // GET /apis/batch/v1beta1/watch/namespaces/{namespace}/cronjobs func (s *Server) handleWatchBatchV1beta1NamespacedCronJobListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchBatchV1beta1NamespacedCronJobList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59288,7 +69620,16 @@ func (s *Server) handleWatchBatchV1beta1NamespacedCronJobListRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59300,8 +69641,27 @@ func (s *Server) handleWatchBatchV1beta1NamespacedCronJobListRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59465,6 +69825,8 @@ func (s *Server) handleWatchBatchV1beta1NamespacedCronJobListRequest(args [1]str // // GET /apis/certificates.k8s.io/v1/watch/certificatesigningrequests/{name} func (s *Server) handleWatchCertificatesV1CertificateSigningRequestRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCertificatesV1CertificateSigningRequest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59486,7 +69848,16 @@ func (s *Server) handleWatchCertificatesV1CertificateSigningRequestRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59498,8 +69869,27 @@ func (s *Server) handleWatchCertificatesV1CertificateSigningRequestRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59662,6 +70052,8 @@ func (s *Server) handleWatchCertificatesV1CertificateSigningRequestRequest(args // // GET /apis/certificates.k8s.io/v1/watch/certificatesigningrequests func (s *Server) handleWatchCertificatesV1CertificateSigningRequestListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCertificatesV1CertificateSigningRequestList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59683,7 +70075,16 @@ func (s *Server) handleWatchCertificatesV1CertificateSigningRequestListRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59695,8 +70096,27 @@ func (s *Server) handleWatchCertificatesV1CertificateSigningRequestListRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59855,6 +70275,8 @@ func (s *Server) handleWatchCertificatesV1CertificateSigningRequestListRequest(a // // GET /apis/coordination.k8s.io/v1/watch/leases func (s *Server) handleWatchCoordinationV1LeaseListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoordinationV1LeaseListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -59876,7 +70298,16 @@ func (s *Server) handleWatchCoordinationV1LeaseListForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59888,8 +70319,27 @@ func (s *Server) handleWatchCoordinationV1LeaseListForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60048,6 +70498,8 @@ func (s *Server) handleWatchCoordinationV1LeaseListForAllNamespacesRequest(args // // GET /apis/coordination.k8s.io/v1/watch/namespaces/{namespace}/leases/{name} func (s *Server) handleWatchCoordinationV1NamespacedLeaseRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoordinationV1NamespacedLease"), semconv.HTTPRequestMethodKey.String("GET"), @@ -60069,7 +70521,16 @@ func (s *Server) handleWatchCoordinationV1NamespacedLeaseRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60081,8 +70542,27 @@ func (s *Server) handleWatchCoordinationV1NamespacedLeaseRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60249,6 +70729,8 @@ func (s *Server) handleWatchCoordinationV1NamespacedLeaseRequest(args [2]string, // // GET /apis/coordination.k8s.io/v1/watch/namespaces/{namespace}/leases func (s *Server) handleWatchCoordinationV1NamespacedLeaseListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoordinationV1NamespacedLeaseList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -60270,7 +70752,16 @@ func (s *Server) handleWatchCoordinationV1NamespacedLeaseListRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60282,8 +70773,27 @@ func (s *Server) handleWatchCoordinationV1NamespacedLeaseListRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60446,6 +70956,8 @@ func (s *Server) handleWatchCoordinationV1NamespacedLeaseListRequest(args [1]str // // GET /api/v1/watch/configmaps func (s *Server) handleWatchCoreV1ConfigMapListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1ConfigMapListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -60467,7 +70979,16 @@ func (s *Server) handleWatchCoreV1ConfigMapListForAllNamespacesRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60479,8 +71000,27 @@ func (s *Server) handleWatchCoreV1ConfigMapListForAllNamespacesRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60639,6 +71179,8 @@ func (s *Server) handleWatchCoreV1ConfigMapListForAllNamespacesRequest(args [0]s // // GET /api/v1/watch/endpoints func (s *Server) handleWatchCoreV1EndpointsListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1EndpointsListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -60660,7 +71202,16 @@ func (s *Server) handleWatchCoreV1EndpointsListForAllNamespacesRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60672,8 +71223,27 @@ func (s *Server) handleWatchCoreV1EndpointsListForAllNamespacesRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60832,6 +71402,8 @@ func (s *Server) handleWatchCoreV1EndpointsListForAllNamespacesRequest(args [0]s // // GET /api/v1/watch/events func (s *Server) handleWatchCoreV1EventListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1EventListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -60853,7 +71425,16 @@ func (s *Server) handleWatchCoreV1EventListForAllNamespacesRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60865,213 +71446,262 @@ func (s *Server) handleWatchCoreV1EventListForAllNamespacesRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: WatchCoreV1EventListForAllNamespacesOperation, - ID: "watchCoreV1EventListForAllNamespaces", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, WatchCoreV1EventListForAllNamespacesOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeWatchCoreV1EventListForAllNamespacesParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response WatchCoreV1EventListForAllNamespacesRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: WatchCoreV1EventListForAllNamespacesOperation, - OperationSummary: "", - OperationID: "watchCoreV1EventListForAllNamespaces", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "pretty", - In: "query", - }: params.Pretty, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - }, - Raw: r, - } - type ( - Request = struct{} - Params = WatchCoreV1EventListForAllNamespacesParams - Response = WatchCoreV1EventListForAllNamespacesRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackWatchCoreV1EventListForAllNamespacesParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.WatchCoreV1EventListForAllNamespaces(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.WatchCoreV1EventListForAllNamespaces(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeWatchCoreV1EventListForAllNamespacesResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleWatchCoreV1LimitRangeListForAllNamespacesRequest handles watchCoreV1LimitRangeListForAllNamespaces operation. -// -// Watch individual changes to a list of LimitRange. deprecated: use the 'watch' parameter with a -// list operation instead. -// -// GET /api/v1/watch/limitranges -func (s *Server) handleWatchCoreV1LimitRangeListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("watchCoreV1LimitRangeListForAllNamespaces"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/v1/watch/limitranges"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), WatchCoreV1LimitRangeListForAllNamespacesOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: WatchCoreV1LimitRangeListForAllNamespacesOperation, - ID: "watchCoreV1LimitRangeListForAllNamespaces", + Name: WatchCoreV1EventListForAllNamespacesOperation, + ID: "watchCoreV1EventListForAllNamespaces", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, WatchCoreV1LimitRangeListForAllNamespacesOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, WatchCoreV1EventListForAllNamespacesOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeWatchCoreV1EventListForAllNamespacesParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response WatchCoreV1EventListForAllNamespacesRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: WatchCoreV1EventListForAllNamespacesOperation, + OperationSummary: "", + OperationID: "watchCoreV1EventListForAllNamespaces", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "pretty", + In: "query", + }: params.Pretty, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = WatchCoreV1EventListForAllNamespacesParams + Response = WatchCoreV1EventListForAllNamespacesRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackWatchCoreV1EventListForAllNamespacesParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.WatchCoreV1EventListForAllNamespaces(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.WatchCoreV1EventListForAllNamespaces(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeWatchCoreV1EventListForAllNamespacesResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleWatchCoreV1LimitRangeListForAllNamespacesRequest handles watchCoreV1LimitRangeListForAllNamespaces operation. +// +// Watch individual changes to a list of LimitRange. deprecated: use the 'watch' parameter with a +// list operation instead. +// +// GET /api/v1/watch/limitranges +func (s *Server) handleWatchCoreV1LimitRangeListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("watchCoreV1LimitRangeListForAllNamespaces"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/v1/watch/limitranges"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), WatchCoreV1LimitRangeListForAllNamespacesOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: WatchCoreV1LimitRangeListForAllNamespacesOperation, + ID: "watchCoreV1LimitRangeListForAllNamespaces", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, WatchCoreV1LimitRangeListForAllNamespacesOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -61218,6 +71848,8 @@ func (s *Server) handleWatchCoreV1LimitRangeListForAllNamespacesRequest(args [0] // // GET /api/v1/watch/namespaces/{name} func (s *Server) handleWatchCoreV1NamespaceRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1Namespace"), semconv.HTTPRequestMethodKey.String("GET"), @@ -61239,7 +71871,16 @@ func (s *Server) handleWatchCoreV1NamespaceRequest(args [1]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61251,8 +71892,27 @@ func (s *Server) handleWatchCoreV1NamespaceRequest(args [1]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61415,6 +72075,8 @@ func (s *Server) handleWatchCoreV1NamespaceRequest(args [1]string, argsEscaped b // // GET /api/v1/watch/namespaces func (s *Server) handleWatchCoreV1NamespaceListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespaceList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -61436,7 +72098,16 @@ func (s *Server) handleWatchCoreV1NamespaceListRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61448,8 +72119,27 @@ func (s *Server) handleWatchCoreV1NamespaceListRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61608,6 +72298,8 @@ func (s *Server) handleWatchCoreV1NamespaceListRequest(args [0]string, argsEscap // // GET /api/v1/watch/namespaces/{namespace}/configmaps/{name} func (s *Server) handleWatchCoreV1NamespacedConfigMapRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedConfigMap"), semconv.HTTPRequestMethodKey.String("GET"), @@ -61629,7 +72321,16 @@ func (s *Server) handleWatchCoreV1NamespacedConfigMapRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61641,8 +72342,27 @@ func (s *Server) handleWatchCoreV1NamespacedConfigMapRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61809,6 +72529,8 @@ func (s *Server) handleWatchCoreV1NamespacedConfigMapRequest(args [2]string, arg // // GET /api/v1/watch/namespaces/{namespace}/configmaps func (s *Server) handleWatchCoreV1NamespacedConfigMapListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedConfigMapList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -61830,7 +72552,16 @@ func (s *Server) handleWatchCoreV1NamespacedConfigMapListRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61842,8 +72573,27 @@ func (s *Server) handleWatchCoreV1NamespacedConfigMapListRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62006,6 +72756,8 @@ func (s *Server) handleWatchCoreV1NamespacedConfigMapListRequest(args [1]string, // // GET /api/v1/watch/namespaces/{namespace}/endpoints/{name} func (s *Server) handleWatchCoreV1NamespacedEndpointsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedEndpoints"), semconv.HTTPRequestMethodKey.String("GET"), @@ -62027,7 +72779,16 @@ func (s *Server) handleWatchCoreV1NamespacedEndpointsRequest(args [2]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62039,8 +72800,27 @@ func (s *Server) handleWatchCoreV1NamespacedEndpointsRequest(args [2]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62207,6 +72987,8 @@ func (s *Server) handleWatchCoreV1NamespacedEndpointsRequest(args [2]string, arg // // GET /api/v1/watch/namespaces/{namespace}/endpoints func (s *Server) handleWatchCoreV1NamespacedEndpointsListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedEndpointsList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -62228,7 +73010,16 @@ func (s *Server) handleWatchCoreV1NamespacedEndpointsListRequest(args [1]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62240,8 +73031,27 @@ func (s *Server) handleWatchCoreV1NamespacedEndpointsListRequest(args [1]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62404,6 +73214,8 @@ func (s *Server) handleWatchCoreV1NamespacedEndpointsListRequest(args [1]string, // // GET /api/v1/watch/namespaces/{namespace}/events/{name} func (s *Server) handleWatchCoreV1NamespacedEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -62425,7 +73237,16 @@ func (s *Server) handleWatchCoreV1NamespacedEventRequest(args [2]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62437,8 +73258,27 @@ func (s *Server) handleWatchCoreV1NamespacedEventRequest(args [2]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62605,6 +73445,8 @@ func (s *Server) handleWatchCoreV1NamespacedEventRequest(args [2]string, argsEsc // // GET /api/v1/watch/namespaces/{namespace}/events func (s *Server) handleWatchCoreV1NamespacedEventListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedEventList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -62626,7 +73468,16 @@ func (s *Server) handleWatchCoreV1NamespacedEventListRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62638,8 +73489,27 @@ func (s *Server) handleWatchCoreV1NamespacedEventListRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62802,6 +73672,8 @@ func (s *Server) handleWatchCoreV1NamespacedEventListRequest(args [1]string, arg // // GET /api/v1/watch/namespaces/{namespace}/limitranges/{name} func (s *Server) handleWatchCoreV1NamespacedLimitRangeRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedLimitRange"), semconv.HTTPRequestMethodKey.String("GET"), @@ -62823,7 +73695,16 @@ func (s *Server) handleWatchCoreV1NamespacedLimitRangeRequest(args [2]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62835,8 +73716,27 @@ func (s *Server) handleWatchCoreV1NamespacedLimitRangeRequest(args [2]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63003,6 +73903,8 @@ func (s *Server) handleWatchCoreV1NamespacedLimitRangeRequest(args [2]string, ar // // GET /api/v1/watch/namespaces/{namespace}/limitranges func (s *Server) handleWatchCoreV1NamespacedLimitRangeListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedLimitRangeList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -63024,7 +73926,16 @@ func (s *Server) handleWatchCoreV1NamespacedLimitRangeListRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63036,8 +73947,27 @@ func (s *Server) handleWatchCoreV1NamespacedLimitRangeListRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63200,6 +74130,8 @@ func (s *Server) handleWatchCoreV1NamespacedLimitRangeListRequest(args [1]string // // GET /api/v1/watch/namespaces/{namespace}/persistentvolumeclaims/{name} func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedPersistentVolumeClaim"), semconv.HTTPRequestMethodKey.String("GET"), @@ -63221,7 +74153,16 @@ func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimRequest(args [2 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63233,8 +74174,27 @@ func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimRequest(args [2 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63401,6 +74361,8 @@ func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimRequest(args [2 // // GET /api/v1/watch/namespaces/{namespace}/persistentvolumeclaims func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedPersistentVolumeClaimList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -63422,7 +74384,16 @@ func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimListRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63434,8 +74405,27 @@ func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimListRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63598,6 +74588,8 @@ func (s *Server) handleWatchCoreV1NamespacedPersistentVolumeClaimListRequest(arg // // GET /api/v1/watch/namespaces/{namespace}/pods/{name} func (s *Server) handleWatchCoreV1NamespacedPodRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedPod"), semconv.HTTPRequestMethodKey.String("GET"), @@ -63619,7 +74611,16 @@ func (s *Server) handleWatchCoreV1NamespacedPodRequest(args [2]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63631,8 +74632,27 @@ func (s *Server) handleWatchCoreV1NamespacedPodRequest(args [2]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63799,6 +74819,8 @@ func (s *Server) handleWatchCoreV1NamespacedPodRequest(args [2]string, argsEscap // // GET /api/v1/watch/namespaces/{namespace}/pods func (s *Server) handleWatchCoreV1NamespacedPodListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedPodList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -63820,7 +74842,16 @@ func (s *Server) handleWatchCoreV1NamespacedPodListRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63832,8 +74863,27 @@ func (s *Server) handleWatchCoreV1NamespacedPodListRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63996,6 +75046,8 @@ func (s *Server) handleWatchCoreV1NamespacedPodListRequest(args [1]string, argsE // // GET /api/v1/watch/namespaces/{namespace}/podtemplates/{name} func (s *Server) handleWatchCoreV1NamespacedPodTemplateRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedPodTemplate"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64017,7 +75069,16 @@ func (s *Server) handleWatchCoreV1NamespacedPodTemplateRequest(args [2]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64029,8 +75090,27 @@ func (s *Server) handleWatchCoreV1NamespacedPodTemplateRequest(args [2]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64197,6 +75277,8 @@ func (s *Server) handleWatchCoreV1NamespacedPodTemplateRequest(args [2]string, a // // GET /api/v1/watch/namespaces/{namespace}/podtemplates func (s *Server) handleWatchCoreV1NamespacedPodTemplateListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedPodTemplateList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64218,7 +75300,16 @@ func (s *Server) handleWatchCoreV1NamespacedPodTemplateListRequest(args [1]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64230,8 +75321,27 @@ func (s *Server) handleWatchCoreV1NamespacedPodTemplateListRequest(args [1]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64394,6 +75504,8 @@ func (s *Server) handleWatchCoreV1NamespacedPodTemplateListRequest(args [1]strin // // GET /api/v1/watch/namespaces/{namespace}/replicationcontrollers/{name} func (s *Server) handleWatchCoreV1NamespacedReplicationControllerRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedReplicationController"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64415,7 +75527,16 @@ func (s *Server) handleWatchCoreV1NamespacedReplicationControllerRequest(args [2 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64427,8 +75548,27 @@ func (s *Server) handleWatchCoreV1NamespacedReplicationControllerRequest(args [2 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64595,6 +75735,8 @@ func (s *Server) handleWatchCoreV1NamespacedReplicationControllerRequest(args [2 // // GET /api/v1/watch/namespaces/{namespace}/replicationcontrollers func (s *Server) handleWatchCoreV1NamespacedReplicationControllerListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedReplicationControllerList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64616,7 +75758,16 @@ func (s *Server) handleWatchCoreV1NamespacedReplicationControllerListRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64628,8 +75779,27 @@ func (s *Server) handleWatchCoreV1NamespacedReplicationControllerListRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64792,6 +75962,8 @@ func (s *Server) handleWatchCoreV1NamespacedReplicationControllerListRequest(arg // // GET /api/v1/watch/namespaces/{namespace}/resourcequotas/{name} func (s *Server) handleWatchCoreV1NamespacedResourceQuotaRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedResourceQuota"), semconv.HTTPRequestMethodKey.String("GET"), @@ -64813,7 +75985,16 @@ func (s *Server) handleWatchCoreV1NamespacedResourceQuotaRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64825,8 +76006,27 @@ func (s *Server) handleWatchCoreV1NamespacedResourceQuotaRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64993,6 +76193,8 @@ func (s *Server) handleWatchCoreV1NamespacedResourceQuotaRequest(args [2]string, // // GET /api/v1/watch/namespaces/{namespace}/resourcequotas func (s *Server) handleWatchCoreV1NamespacedResourceQuotaListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedResourceQuotaList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65014,7 +76216,16 @@ func (s *Server) handleWatchCoreV1NamespacedResourceQuotaListRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65026,8 +76237,27 @@ func (s *Server) handleWatchCoreV1NamespacedResourceQuotaListRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65190,6 +76420,8 @@ func (s *Server) handleWatchCoreV1NamespacedResourceQuotaListRequest(args [1]str // // GET /api/v1/watch/namespaces/{namespace}/secrets/{name} func (s *Server) handleWatchCoreV1NamespacedSecretRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedSecret"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65211,7 +76443,16 @@ func (s *Server) handleWatchCoreV1NamespacedSecretRequest(args [2]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65223,8 +76464,27 @@ func (s *Server) handleWatchCoreV1NamespacedSecretRequest(args [2]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65391,6 +76651,8 @@ func (s *Server) handleWatchCoreV1NamespacedSecretRequest(args [2]string, argsEs // // GET /api/v1/watch/namespaces/{namespace}/secrets func (s *Server) handleWatchCoreV1NamespacedSecretListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedSecretList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65412,7 +76674,16 @@ func (s *Server) handleWatchCoreV1NamespacedSecretListRequest(args [1]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65424,8 +76695,27 @@ func (s *Server) handleWatchCoreV1NamespacedSecretListRequest(args [1]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65588,6 +76878,8 @@ func (s *Server) handleWatchCoreV1NamespacedSecretListRequest(args [1]string, ar // // GET /api/v1/watch/namespaces/{namespace}/services/{name} func (s *Server) handleWatchCoreV1NamespacedServiceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedService"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65609,7 +76901,16 @@ func (s *Server) handleWatchCoreV1NamespacedServiceRequest(args [2]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65621,8 +76922,27 @@ func (s *Server) handleWatchCoreV1NamespacedServiceRequest(args [2]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65789,6 +77109,8 @@ func (s *Server) handleWatchCoreV1NamespacedServiceRequest(args [2]string, argsE // // GET /api/v1/watch/namespaces/{namespace}/serviceaccounts/{name} func (s *Server) handleWatchCoreV1NamespacedServiceAccountRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedServiceAccount"), semconv.HTTPRequestMethodKey.String("GET"), @@ -65810,7 +77132,16 @@ func (s *Server) handleWatchCoreV1NamespacedServiceAccountRequest(args [2]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65822,8 +77153,27 @@ func (s *Server) handleWatchCoreV1NamespacedServiceAccountRequest(args [2]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65990,6 +77340,8 @@ func (s *Server) handleWatchCoreV1NamespacedServiceAccountRequest(args [2]string // // GET /api/v1/watch/namespaces/{namespace}/serviceaccounts func (s *Server) handleWatchCoreV1NamespacedServiceAccountListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedServiceAccountList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66011,7 +77363,16 @@ func (s *Server) handleWatchCoreV1NamespacedServiceAccountListRequest(args [1]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66023,8 +77384,27 @@ func (s *Server) handleWatchCoreV1NamespacedServiceAccountListRequest(args [1]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66187,6 +77567,8 @@ func (s *Server) handleWatchCoreV1NamespacedServiceAccountListRequest(args [1]st // // GET /api/v1/watch/namespaces/{namespace}/services func (s *Server) handleWatchCoreV1NamespacedServiceListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NamespacedServiceList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66208,7 +77590,16 @@ func (s *Server) handleWatchCoreV1NamespacedServiceListRequest(args [1]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66220,8 +77611,27 @@ func (s *Server) handleWatchCoreV1NamespacedServiceListRequest(args [1]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66384,6 +77794,8 @@ func (s *Server) handleWatchCoreV1NamespacedServiceListRequest(args [1]string, a // // GET /api/v1/watch/nodes/{name} func (s *Server) handleWatchCoreV1NodeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1Node"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66405,7 +77817,16 @@ func (s *Server) handleWatchCoreV1NodeRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66417,8 +77838,27 @@ func (s *Server) handleWatchCoreV1NodeRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66581,6 +78021,8 @@ func (s *Server) handleWatchCoreV1NodeRequest(args [1]string, argsEscaped bool, // // GET /api/v1/watch/nodes func (s *Server) handleWatchCoreV1NodeListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1NodeList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66602,7 +78044,16 @@ func (s *Server) handleWatchCoreV1NodeListRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66614,8 +78065,27 @@ func (s *Server) handleWatchCoreV1NodeListRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66774,6 +78244,8 @@ func (s *Server) handleWatchCoreV1NodeListRequest(args [0]string, argsEscaped bo // // GET /api/v1/watch/persistentvolumes/{name} func (s *Server) handleWatchCoreV1PersistentVolumeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1PersistentVolume"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66795,7 +78267,16 @@ func (s *Server) handleWatchCoreV1PersistentVolumeRequest(args [1]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66807,8 +78288,27 @@ func (s *Server) handleWatchCoreV1PersistentVolumeRequest(args [1]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66971,6 +78471,8 @@ func (s *Server) handleWatchCoreV1PersistentVolumeRequest(args [1]string, argsEs // // GET /api/v1/watch/persistentvolumeclaims func (s *Server) handleWatchCoreV1PersistentVolumeClaimListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1PersistentVolumeClaimListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -66992,7 +78494,16 @@ func (s *Server) handleWatchCoreV1PersistentVolumeClaimListForAllNamespacesReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67004,8 +78515,27 @@ func (s *Server) handleWatchCoreV1PersistentVolumeClaimListForAllNamespacesReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67164,6 +78694,8 @@ func (s *Server) handleWatchCoreV1PersistentVolumeClaimListForAllNamespacesReque // // GET /api/v1/watch/persistentvolumes func (s *Server) handleWatchCoreV1PersistentVolumeListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1PersistentVolumeList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67185,7 +78717,16 @@ func (s *Server) handleWatchCoreV1PersistentVolumeListRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67197,8 +78738,27 @@ func (s *Server) handleWatchCoreV1PersistentVolumeListRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67357,6 +78917,8 @@ func (s *Server) handleWatchCoreV1PersistentVolumeListRequest(args [0]string, ar // // GET /api/v1/watch/pods func (s *Server) handleWatchCoreV1PodListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1PodListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67378,7 +78940,16 @@ func (s *Server) handleWatchCoreV1PodListForAllNamespacesRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67390,8 +78961,27 @@ func (s *Server) handleWatchCoreV1PodListForAllNamespacesRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67550,6 +79140,8 @@ func (s *Server) handleWatchCoreV1PodListForAllNamespacesRequest(args [0]string, // // GET /api/v1/watch/podtemplates func (s *Server) handleWatchCoreV1PodTemplateListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1PodTemplateListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67571,7 +79163,16 @@ func (s *Server) handleWatchCoreV1PodTemplateListForAllNamespacesRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67583,8 +79184,27 @@ func (s *Server) handleWatchCoreV1PodTemplateListForAllNamespacesRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67743,6 +79363,8 @@ func (s *Server) handleWatchCoreV1PodTemplateListForAllNamespacesRequest(args [0 // // GET /api/v1/watch/replicationcontrollers func (s *Server) handleWatchCoreV1ReplicationControllerListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1ReplicationControllerListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67764,7 +79386,16 @@ func (s *Server) handleWatchCoreV1ReplicationControllerListForAllNamespacesReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67776,8 +79407,27 @@ func (s *Server) handleWatchCoreV1ReplicationControllerListForAllNamespacesReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67936,6 +79586,8 @@ func (s *Server) handleWatchCoreV1ReplicationControllerListForAllNamespacesReque // // GET /api/v1/watch/resourcequotas func (s *Server) handleWatchCoreV1ResourceQuotaListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1ResourceQuotaListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -67957,7 +79609,16 @@ func (s *Server) handleWatchCoreV1ResourceQuotaListForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67969,8 +79630,27 @@ func (s *Server) handleWatchCoreV1ResourceQuotaListForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68129,6 +79809,8 @@ func (s *Server) handleWatchCoreV1ResourceQuotaListForAllNamespacesRequest(args // // GET /api/v1/watch/secrets func (s *Server) handleWatchCoreV1SecretListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1SecretListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68150,7 +79832,16 @@ func (s *Server) handleWatchCoreV1SecretListForAllNamespacesRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68162,8 +79853,27 @@ func (s *Server) handleWatchCoreV1SecretListForAllNamespacesRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68322,6 +80032,8 @@ func (s *Server) handleWatchCoreV1SecretListForAllNamespacesRequest(args [0]stri // // GET /api/v1/watch/serviceaccounts func (s *Server) handleWatchCoreV1ServiceAccountListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1ServiceAccountListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68343,7 +80055,16 @@ func (s *Server) handleWatchCoreV1ServiceAccountListForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68355,8 +80076,27 @@ func (s *Server) handleWatchCoreV1ServiceAccountListForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68515,6 +80255,8 @@ func (s *Server) handleWatchCoreV1ServiceAccountListForAllNamespacesRequest(args // // GET /api/v1/watch/services func (s *Server) handleWatchCoreV1ServiceListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchCoreV1ServiceListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68536,7 +80278,16 @@ func (s *Server) handleWatchCoreV1ServiceListForAllNamespacesRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68548,8 +80299,27 @@ func (s *Server) handleWatchCoreV1ServiceListForAllNamespacesRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68708,6 +80478,8 @@ func (s *Server) handleWatchCoreV1ServiceListForAllNamespacesRequest(args [0]str // // GET /apis/discovery.k8s.io/v1/watch/endpointslices func (s *Server) handleWatchDiscoveryV1EndpointSliceListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchDiscoveryV1EndpointSliceListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68729,7 +80501,16 @@ func (s *Server) handleWatchDiscoveryV1EndpointSliceListForAllNamespacesRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68741,8 +80522,27 @@ func (s *Server) handleWatchDiscoveryV1EndpointSliceListForAllNamespacesRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68901,6 +80701,8 @@ func (s *Server) handleWatchDiscoveryV1EndpointSliceListForAllNamespacesRequest( // // GET /apis/discovery.k8s.io/v1/watch/namespaces/{namespace}/endpointslices/{name} func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchDiscoveryV1NamespacedEndpointSlice"), semconv.HTTPRequestMethodKey.String("GET"), @@ -68922,7 +80724,16 @@ func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceRequest(args [2]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68934,8 +80745,27 @@ func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceRequest(args [2]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69102,6 +80932,8 @@ func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceRequest(args [2]st // // GET /apis/discovery.k8s.io/v1/watch/namespaces/{namespace}/endpointslices func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchDiscoveryV1NamespacedEndpointSliceList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69123,7 +80955,16 @@ func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceListRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69135,8 +80976,27 @@ func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceListRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69299,6 +81159,8 @@ func (s *Server) handleWatchDiscoveryV1NamespacedEndpointSliceListRequest(args [ // // GET /apis/discovery.k8s.io/v1beta1/watch/endpointslices func (s *Server) handleWatchDiscoveryV1beta1EndpointSliceListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchDiscoveryV1beta1EndpointSliceListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69320,7 +81182,16 @@ func (s *Server) handleWatchDiscoveryV1beta1EndpointSliceListForAllNamespacesReq startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69332,8 +81203,27 @@ func (s *Server) handleWatchDiscoveryV1beta1EndpointSliceListForAllNamespacesReq var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69492,6 +81382,8 @@ func (s *Server) handleWatchDiscoveryV1beta1EndpointSliceListForAllNamespacesReq // // GET /apis/discovery.k8s.io/v1beta1/watch/namespaces/{namespace}/endpointslices/{name} func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchDiscoveryV1beta1NamespacedEndpointSlice"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69513,7 +81405,16 @@ func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69525,8 +81426,27 @@ func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69693,6 +81613,8 @@ func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceRequest(args // // GET /apis/discovery.k8s.io/v1beta1/watch/namespaces/{namespace}/endpointslices func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchDiscoveryV1beta1NamespacedEndpointSliceList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69714,7 +81636,16 @@ func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceListRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69726,8 +81657,27 @@ func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceListRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69890,6 +81840,8 @@ func (s *Server) handleWatchDiscoveryV1beta1NamespacedEndpointSliceListRequest(a // // GET /apis/events.k8s.io/v1/watch/events func (s *Server) handleWatchEventsV1EventListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchEventsV1EventListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -69911,7 +81863,16 @@ func (s *Server) handleWatchEventsV1EventListForAllNamespacesRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69923,8 +81884,27 @@ func (s *Server) handleWatchEventsV1EventListForAllNamespacesRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70083,6 +82063,8 @@ func (s *Server) handleWatchEventsV1EventListForAllNamespacesRequest(args [0]str // // GET /apis/events.k8s.io/v1/watch/namespaces/{namespace}/events/{name} func (s *Server) handleWatchEventsV1NamespacedEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchEventsV1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70104,7 +82086,16 @@ func (s *Server) handleWatchEventsV1NamespacedEventRequest(args [2]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70116,8 +82107,27 @@ func (s *Server) handleWatchEventsV1NamespacedEventRequest(args [2]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70284,6 +82294,8 @@ func (s *Server) handleWatchEventsV1NamespacedEventRequest(args [2]string, argsE // // GET /apis/events.k8s.io/v1/watch/namespaces/{namespace}/events func (s *Server) handleWatchEventsV1NamespacedEventListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchEventsV1NamespacedEventList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70305,7 +82317,16 @@ func (s *Server) handleWatchEventsV1NamespacedEventListRequest(args [1]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70317,8 +82338,27 @@ func (s *Server) handleWatchEventsV1NamespacedEventListRequest(args [1]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70481,6 +82521,8 @@ func (s *Server) handleWatchEventsV1NamespacedEventListRequest(args [1]string, a // // GET /apis/events.k8s.io/v1beta1/watch/events func (s *Server) handleWatchEventsV1beta1EventListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchEventsV1beta1EventListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70502,7 +82544,16 @@ func (s *Server) handleWatchEventsV1beta1EventListForAllNamespacesRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70514,8 +82565,27 @@ func (s *Server) handleWatchEventsV1beta1EventListForAllNamespacesRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70674,6 +82744,8 @@ func (s *Server) handleWatchEventsV1beta1EventListForAllNamespacesRequest(args [ // // GET /apis/events.k8s.io/v1beta1/watch/namespaces/{namespace}/events/{name} func (s *Server) handleWatchEventsV1beta1NamespacedEventRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchEventsV1beta1NamespacedEvent"), semconv.HTTPRequestMethodKey.String("GET"), @@ -70695,7 +82767,16 @@ func (s *Server) handleWatchEventsV1beta1NamespacedEventRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70707,221 +82788,270 @@ func (s *Server) handleWatchEventsV1beta1NamespacedEventRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) - } - err error - opErrContext = ogenerrors.OperationContext{ - Name: WatchEventsV1beta1NamespacedEventOperation, - ID: "watchEventsV1beta1NamespacedEvent", - } - ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityBearerToken(ctx, WatchEventsV1beta1NamespacedEventOperation, r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "BearerToken", - Err: err, - } - defer recordError("Security:BearerToken", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + if setStatus { + span.SetStatus(codes.Error, stage) } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } - params, err := decodeWatchEventsV1beta1NamespacedEventParams(args, argsEscaped, r) - if err != nil { - err = &ogenerrors.DecodeParamsError{ - OperationContext: opErrContext, - Err: err, - } - defer recordError("DecodeParams", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - var response WatchEventsV1beta1NamespacedEventRes - if m := s.cfg.Middleware; m != nil { - mreq := middleware.Request{ - Context: ctx, - OperationName: WatchEventsV1beta1NamespacedEventOperation, - OperationSummary: "", - OperationID: "watchEventsV1beta1NamespacedEvent", - Body: nil, - Params: middleware.Parameters{ - { - Name: "allowWatchBookmarks", - In: "query", - }: params.AllowWatchBookmarks, - { - Name: "continue", - In: "query", - }: params.Continue, - { - Name: "fieldSelector", - In: "query", - }: params.FieldSelector, - { - Name: "labelSelector", - In: "query", - }: params.LabelSelector, - { - Name: "limit", - In: "query", - }: params.Limit, - { - Name: "name", - In: "path", - }: params.Name, - { - Name: "namespace", - In: "path", - }: params.Namespace, - { - Name: "pretty", - In: "query", - }: params.Pretty, - { - Name: "resourceVersion", - In: "query", - }: params.ResourceVersion, - { - Name: "resourceVersionMatch", - In: "query", - }: params.ResourceVersionMatch, - { - Name: "timeoutSeconds", - In: "query", - }: params.TimeoutSeconds, - { - Name: "watch", - In: "query", - }: params.Watch, - }, - Raw: r, - } - type ( - Request = struct{} - Params = WatchEventsV1beta1NamespacedEventParams - Response = WatchEventsV1beta1NamespacedEventRes - ) - response, err = middleware.HookMiddleware[ - Request, - Params, - Response, - ]( - m, - mreq, - unpackWatchEventsV1beta1NamespacedEventParams, - func(ctx context.Context, request Request, params Params) (response Response, err error) { - response, err = s.h.WatchEventsV1beta1NamespacedEvent(ctx, params) - return response, err - }, - ) - } else { - response, err = s.h.WatchEventsV1beta1NamespacedEvent(ctx, params) - } - if err != nil { - defer recordError("Internal", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - - if err := encodeWatchEventsV1beta1NamespacedEventResponse(response, w, span); err != nil { - defer recordError("EncodeResponse", err) - if !errors.Is(err, ht.ErrInternalServerErrorResponse) { - s.cfg.ErrorHandler(ctx, w, r, err) - } - return - } -} - -// handleWatchEventsV1beta1NamespacedEventListRequest handles watchEventsV1beta1NamespacedEventList operation. -// -// Watch individual changes to a list of Event. deprecated: use the 'watch' parameter with a list -// operation instead. -// -// GET /apis/events.k8s.io/v1beta1/watch/namespaces/{namespace}/events -func (s *Server) handleWatchEventsV1beta1NamespacedEventListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("watchEventsV1beta1NamespacedEventList"), - semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/apis/events.k8s.io/v1beta1/watch/namespaces/{namespace}/events"), - } - - // Start a span for this request. - ctx, span := s.cfg.Tracer.Start(r.Context(), WatchEventsV1beta1NamespacedEventListOperation, - trace.WithAttributes(otelAttrs...), - serverSpanKind, - ) - defer span.End() - - // Add Labeler to context. - labeler := &Labeler{attrs: otelAttrs} - ctx = contextWithLabeler(ctx, labeler) - - // Run stopwatch. - startTime := time.Now() - defer func() { - elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) - - // Increment request counter. - s.requests.Add(ctx, 1, attrOpt) - - // Use floating point division here for higher precision (instead of Millisecond method). - s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) - }() + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } - var ( - recordError = func(stage string, err error) { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ - Name: WatchEventsV1beta1NamespacedEventListOperation, - ID: "watchEventsV1beta1NamespacedEventList", + Name: WatchEventsV1beta1NamespacedEventOperation, + ID: "watchEventsV1beta1NamespacedEvent", } ) { type bitset = [1]uint8 var satisfied bitset { - sctx, ok, err := s.securityBearerToken(ctx, WatchEventsV1beta1NamespacedEventListOperation, r) + sctx, ok, err := s.securityBearerToken(ctx, WatchEventsV1beta1NamespacedEventOperation, r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerToken", + Err: err, + } + defer recordError("Security:BearerToken", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodeWatchEventsV1beta1NamespacedEventParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response WatchEventsV1beta1NamespacedEventRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: WatchEventsV1beta1NamespacedEventOperation, + OperationSummary: "", + OperationID: "watchEventsV1beta1NamespacedEvent", + Body: nil, + Params: middleware.Parameters{ + { + Name: "allowWatchBookmarks", + In: "query", + }: params.AllowWatchBookmarks, + { + Name: "continue", + In: "query", + }: params.Continue, + { + Name: "fieldSelector", + In: "query", + }: params.FieldSelector, + { + Name: "labelSelector", + In: "query", + }: params.LabelSelector, + { + Name: "limit", + In: "query", + }: params.Limit, + { + Name: "name", + In: "path", + }: params.Name, + { + Name: "namespace", + In: "path", + }: params.Namespace, + { + Name: "pretty", + In: "query", + }: params.Pretty, + { + Name: "resourceVersion", + In: "query", + }: params.ResourceVersion, + { + Name: "resourceVersionMatch", + In: "query", + }: params.ResourceVersionMatch, + { + Name: "timeoutSeconds", + In: "query", + }: params.TimeoutSeconds, + { + Name: "watch", + In: "query", + }: params.Watch, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = WatchEventsV1beta1NamespacedEventParams + Response = WatchEventsV1beta1NamespacedEventRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackWatchEventsV1beta1NamespacedEventParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.WatchEventsV1beta1NamespacedEvent(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.WatchEventsV1beta1NamespacedEvent(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeWatchEventsV1beta1NamespacedEventResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + +// handleWatchEventsV1beta1NamespacedEventListRequest handles watchEventsV1beta1NamespacedEventList operation. +// +// Watch individual changes to a list of Event. deprecated: use the 'watch' parameter with a list +// operation instead. +// +// GET /apis/events.k8s.io/v1beta1/watch/namespaces/{namespace}/events +func (s *Server) handleWatchEventsV1beta1NamespacedEventListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("watchEventsV1beta1NamespacedEventList"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/apis/events.k8s.io/v1beta1/watch/namespaces/{namespace}/events"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), WatchEventsV1beta1NamespacedEventListOperation, + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: WatchEventsV1beta1NamespacedEventListOperation, + ID: "watchEventsV1beta1NamespacedEventList", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerToken(ctx, WatchEventsV1beta1NamespacedEventListOperation, r) if err != nil { err = &ogenerrors.SecurityError{ OperationContext: opErrContext, @@ -71072,6 +83202,8 @@ func (s *Server) handleWatchEventsV1beta1NamespacedEventListRequest(args [1]stri // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/watch/flowschemas/{name} func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta1FlowSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71093,7 +83225,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71105,8 +83246,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71269,6 +83429,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaRequest(args [1 // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/watch/flowschemas func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta1FlowSchemaList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71290,7 +83452,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaListRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71302,8 +83473,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaListRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71463,6 +83653,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1FlowSchemaListRequest(arg // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/watch/prioritylevelconfigurations/{name} func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta1PriorityLevelConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71484,7 +83676,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfiguratio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71496,8 +83697,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfiguratio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71660,6 +83880,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfiguratio // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta1/watch/prioritylevelconfigurations func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfigurationListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta1PriorityLevelConfigurationList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71681,7 +83903,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfiguratio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71693,8 +83924,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfiguratio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71853,6 +84103,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta1PriorityLevelConfiguratio // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/watch/flowschemas/{name} func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta2FlowSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -71874,7 +84126,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71886,8 +84147,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72050,6 +84330,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaRequest(args [1 // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/watch/flowschemas func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta2FlowSchemaList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72071,7 +84353,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaListRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72083,8 +84374,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaListRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72244,6 +84554,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2FlowSchemaListRequest(arg // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/watch/prioritylevelconfigurations/{name} func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfigurationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta2PriorityLevelConfiguration"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72265,7 +84577,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfiguratio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72277,8 +84598,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfiguratio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72441,6 +84781,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfiguratio // // GET /apis/flowcontrol.apiserver.k8s.io/v1beta2/watch/prioritylevelconfigurations func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfigurationListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchFlowcontrolApiserverV1beta2PriorityLevelConfigurationList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72462,7 +84804,16 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfiguratio startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72474,8 +84825,27 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfiguratio var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72634,6 +85004,8 @@ func (s *Server) handleWatchFlowcontrolApiserverV1beta2PriorityLevelConfiguratio // // GET /apis/internal.apiserver.k8s.io/v1alpha1/watch/storageversions/{name} func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchInternalApiserverV1alpha1StorageVersion"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72655,7 +85027,16 @@ func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72667,8 +85048,27 @@ func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72831,6 +85231,8 @@ func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionRequest(args // // GET /apis/internal.apiserver.k8s.io/v1alpha1/watch/storageversions func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchInternalApiserverV1alpha1StorageVersionList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -72852,7 +85254,16 @@ func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionListRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72864,8 +85275,27 @@ func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionListRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73024,6 +85454,8 @@ func (s *Server) handleWatchInternalApiserverV1alpha1StorageVersionListRequest(a // // GET /apis/networking.k8s.io/v1/watch/ingressclasses/{name} func (s *Server) handleWatchNetworkingV1IngressClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1IngressClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73045,7 +85477,16 @@ func (s *Server) handleWatchNetworkingV1IngressClassRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73057,8 +85498,27 @@ func (s *Server) handleWatchNetworkingV1IngressClassRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73221,6 +85681,8 @@ func (s *Server) handleWatchNetworkingV1IngressClassRequest(args [1]string, args // // GET /apis/networking.k8s.io/v1/watch/ingressclasses func (s *Server) handleWatchNetworkingV1IngressClassListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1IngressClassList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73242,7 +85704,16 @@ func (s *Server) handleWatchNetworkingV1IngressClassListRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73254,8 +85725,27 @@ func (s *Server) handleWatchNetworkingV1IngressClassListRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73414,6 +85904,8 @@ func (s *Server) handleWatchNetworkingV1IngressClassListRequest(args [0]string, // // GET /apis/networking.k8s.io/v1/watch/ingresses func (s *Server) handleWatchNetworkingV1IngressListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1IngressListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73435,7 +85927,16 @@ func (s *Server) handleWatchNetworkingV1IngressListForAllNamespacesRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73447,8 +85948,27 @@ func (s *Server) handleWatchNetworkingV1IngressListForAllNamespacesRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73607,6 +86127,8 @@ func (s *Server) handleWatchNetworkingV1IngressListForAllNamespacesRequest(args // // GET /apis/networking.k8s.io/v1/watch/namespaces/{namespace}/ingresses/{name} func (s *Server) handleWatchNetworkingV1NamespacedIngressRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1NamespacedIngress"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73628,7 +86150,16 @@ func (s *Server) handleWatchNetworkingV1NamespacedIngressRequest(args [2]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73640,8 +86171,27 @@ func (s *Server) handleWatchNetworkingV1NamespacedIngressRequest(args [2]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73808,6 +86358,8 @@ func (s *Server) handleWatchNetworkingV1NamespacedIngressRequest(args [2]string, // // GET /apis/networking.k8s.io/v1/watch/namespaces/{namespace}/ingresses func (s *Server) handleWatchNetworkingV1NamespacedIngressListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1NamespacedIngressList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -73829,7 +86381,16 @@ func (s *Server) handleWatchNetworkingV1NamespacedIngressListRequest(args [1]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73841,8 +86402,27 @@ func (s *Server) handleWatchNetworkingV1NamespacedIngressListRequest(args [1]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74005,6 +86585,8 @@ func (s *Server) handleWatchNetworkingV1NamespacedIngressListRequest(args [1]str // // GET /apis/networking.k8s.io/v1/watch/namespaces/{namespace}/networkpolicies/{name} func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1NamespacedNetworkPolicy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74026,7 +86608,16 @@ func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyRequest(args [2]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74038,8 +86629,27 @@ func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyRequest(args [2]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74206,6 +86816,8 @@ func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyRequest(args [2]s // // GET /apis/networking.k8s.io/v1/watch/namespaces/{namespace}/networkpolicies func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1NamespacedNetworkPolicyList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74227,7 +86839,16 @@ func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyListRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74239,8 +86860,27 @@ func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyListRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74403,6 +87043,8 @@ func (s *Server) handleWatchNetworkingV1NamespacedNetworkPolicyListRequest(args // // GET /apis/networking.k8s.io/v1/watch/networkpolicies func (s *Server) handleWatchNetworkingV1NetworkPolicyListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNetworkingV1NetworkPolicyListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74424,7 +87066,16 @@ func (s *Server) handleWatchNetworkingV1NetworkPolicyListForAllNamespacesRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74436,8 +87087,27 @@ func (s *Server) handleWatchNetworkingV1NetworkPolicyListForAllNamespacesRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74596,6 +87266,8 @@ func (s *Server) handleWatchNetworkingV1NetworkPolicyListForAllNamespacesRequest // // GET /apis/node.k8s.io/v1/watch/runtimeclasses/{name} func (s *Server) handleWatchNodeV1RuntimeClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNodeV1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74617,7 +87289,16 @@ func (s *Server) handleWatchNodeV1RuntimeClassRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74629,8 +87310,27 @@ func (s *Server) handleWatchNodeV1RuntimeClassRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74793,6 +87493,8 @@ func (s *Server) handleWatchNodeV1RuntimeClassRequest(args [1]string, argsEscape // // GET /apis/node.k8s.io/v1/watch/runtimeclasses func (s *Server) handleWatchNodeV1RuntimeClassListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNodeV1RuntimeClassList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -74814,7 +87516,16 @@ func (s *Server) handleWatchNodeV1RuntimeClassListRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74826,8 +87537,27 @@ func (s *Server) handleWatchNodeV1RuntimeClassListRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74986,6 +87716,8 @@ func (s *Server) handleWatchNodeV1RuntimeClassListRequest(args [0]string, argsEs // // GET /apis/node.k8s.io/v1alpha1/watch/runtimeclasses/{name} func (s *Server) handleWatchNodeV1alpha1RuntimeClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNodeV1alpha1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -75007,7 +87739,16 @@ func (s *Server) handleWatchNodeV1alpha1RuntimeClassRequest(args [1]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75019,8 +87760,27 @@ func (s *Server) handleWatchNodeV1alpha1RuntimeClassRequest(args [1]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75183,6 +87943,8 @@ func (s *Server) handleWatchNodeV1alpha1RuntimeClassRequest(args [1]string, args // // GET /apis/node.k8s.io/v1alpha1/watch/runtimeclasses func (s *Server) handleWatchNodeV1alpha1RuntimeClassListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNodeV1alpha1RuntimeClassList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -75204,7 +87966,16 @@ func (s *Server) handleWatchNodeV1alpha1RuntimeClassListRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75216,8 +87987,27 @@ func (s *Server) handleWatchNodeV1alpha1RuntimeClassListRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75376,6 +88166,8 @@ func (s *Server) handleWatchNodeV1alpha1RuntimeClassListRequest(args [0]string, // // GET /apis/node.k8s.io/v1beta1/watch/runtimeclasses/{name} func (s *Server) handleWatchNodeV1beta1RuntimeClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNodeV1beta1RuntimeClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -75397,7 +88189,16 @@ func (s *Server) handleWatchNodeV1beta1RuntimeClassRequest(args [1]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75409,8 +88210,27 @@ func (s *Server) handleWatchNodeV1beta1RuntimeClassRequest(args [1]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75573,6 +88393,8 @@ func (s *Server) handleWatchNodeV1beta1RuntimeClassRequest(args [1]string, argsE // // GET /apis/node.k8s.io/v1beta1/watch/runtimeclasses func (s *Server) handleWatchNodeV1beta1RuntimeClassListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchNodeV1beta1RuntimeClassList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -75594,7 +88416,16 @@ func (s *Server) handleWatchNodeV1beta1RuntimeClassListRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75606,8 +88437,27 @@ func (s *Server) handleWatchNodeV1beta1RuntimeClassListRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75766,6 +88616,8 @@ func (s *Server) handleWatchNodeV1beta1RuntimeClassListRequest(args [0]string, a // // GET /apis/policy/v1/watch/namespaces/{namespace}/poddisruptionbudgets/{name} func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1NamespacedPodDisruptionBudget"), semconv.HTTPRequestMethodKey.String("GET"), @@ -75787,7 +88639,16 @@ func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetRequest(args [2 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75799,8 +88660,27 @@ func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetRequest(args [2 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75967,6 +88847,8 @@ func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetRequest(args [2 // // GET /apis/policy/v1/watch/namespaces/{namespace}/poddisruptionbudgets func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1NamespacedPodDisruptionBudgetList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -75988,7 +88870,16 @@ func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetListRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76000,8 +88891,27 @@ func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetListRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76164,6 +89074,8 @@ func (s *Server) handleWatchPolicyV1NamespacedPodDisruptionBudgetListRequest(arg // // GET /apis/policy/v1/watch/poddisruptionbudgets func (s *Server) handleWatchPolicyV1PodDisruptionBudgetListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1PodDisruptionBudgetListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -76185,7 +89097,16 @@ func (s *Server) handleWatchPolicyV1PodDisruptionBudgetListForAllNamespacesReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76197,8 +89118,27 @@ func (s *Server) handleWatchPolicyV1PodDisruptionBudgetListForAllNamespacesReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76357,6 +89297,8 @@ func (s *Server) handleWatchPolicyV1PodDisruptionBudgetListForAllNamespacesReque // // GET /apis/policy/v1beta1/watch/namespaces/{namespace}/poddisruptionbudgets/{name} func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1beta1NamespacedPodDisruptionBudget"), semconv.HTTPRequestMethodKey.String("GET"), @@ -76378,7 +89320,16 @@ func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76390,8 +89341,27 @@ func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76558,6 +89528,8 @@ func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetRequest(ar // // GET /apis/policy/v1beta1/watch/namespaces/{namespace}/poddisruptionbudgets func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1beta1NamespacedPodDisruptionBudgetList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -76579,7 +89551,16 @@ func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetListReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76591,8 +89572,27 @@ func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetListReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76755,6 +89755,8 @@ func (s *Server) handleWatchPolicyV1beta1NamespacedPodDisruptionBudgetListReques // // GET /apis/policy/v1beta1/watch/poddisruptionbudgets func (s *Server) handleWatchPolicyV1beta1PodDisruptionBudgetListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1beta1PodDisruptionBudgetListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -76776,7 +89778,16 @@ func (s *Server) handleWatchPolicyV1beta1PodDisruptionBudgetListForAllNamespaces startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76788,8 +89799,27 @@ func (s *Server) handleWatchPolicyV1beta1PodDisruptionBudgetListForAllNamespaces var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76948,6 +89978,8 @@ func (s *Server) handleWatchPolicyV1beta1PodDisruptionBudgetListForAllNamespaces // // GET /apis/policy/v1beta1/watch/podsecuritypolicies/{name} func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1beta1PodSecurityPolicy"), semconv.HTTPRequestMethodKey.String("GET"), @@ -76969,7 +90001,16 @@ func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76981,8 +90022,27 @@ func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77145,6 +90205,8 @@ func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyRequest(args [1]string // // GET /apis/policy/v1beta1/watch/podsecuritypolicies func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchPolicyV1beta1PodSecurityPolicyList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -77166,7 +90228,16 @@ func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyListRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77178,8 +90249,27 @@ func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyListRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77338,6 +90428,8 @@ func (s *Server) handleWatchPolicyV1beta1PodSecurityPolicyListRequest(args [0]st // // GET /apis/rbac.authorization.k8s.io/v1/watch/clusterroles/{name} func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1ClusterRole"), semconv.HTTPRequestMethodKey.String("GET"), @@ -77359,7 +90451,16 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleRequest(args [1]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77371,8 +90472,27 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleRequest(args [1]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77535,6 +90655,8 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleRequest(args [1]string // // GET /apis/rbac.authorization.k8s.io/v1/watch/clusterrolebindings/{name} func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1ClusterRoleBinding"), semconv.HTTPRequestMethodKey.String("GET"), @@ -77556,7 +90678,16 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingRequest(args [1 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77568,8 +90699,27 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingRequest(args [1 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77732,6 +90882,8 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingRequest(args [1 // // GET /apis/rbac.authorization.k8s.io/v1/watch/clusterrolebindings func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1ClusterRoleBindingList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -77753,7 +90905,16 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingListRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77765,8 +90926,27 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingListRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77925,6 +91105,8 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleBindingListRequest(arg // // GET /apis/rbac.authorization.k8s.io/v1/watch/clusterroles func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1ClusterRoleList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -77946,7 +91128,16 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleListRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77958,8 +91149,27 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleListRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78118,6 +91328,8 @@ func (s *Server) handleWatchRbacAuthorizationV1ClusterRoleListRequest(args [0]st // // GET /apis/rbac.authorization.k8s.io/v1/watch/namespaces/{namespace}/roles/{name} func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1NamespacedRole"), semconv.HTTPRequestMethodKey.String("GET"), @@ -78139,7 +91351,16 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleRequest(args [2]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78151,8 +91372,27 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleRequest(args [2]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78319,6 +91559,8 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleRequest(args [2]str // // GET /apis/rbac.authorization.k8s.io/v1/watch/namespaces/{namespace}/rolebindings/{name} func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1NamespacedRoleBinding"), semconv.HTTPRequestMethodKey.String("GET"), @@ -78340,7 +91582,16 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78352,8 +91603,27 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78520,6 +91790,8 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingRequest(args // // GET /apis/rbac.authorization.k8s.io/v1/watch/namespaces/{namespace}/rolebindings func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1NamespacedRoleBindingList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -78541,7 +91813,16 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingListRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78553,8 +91834,27 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingListRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78717,6 +92017,8 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleBindingListRequest( // // GET /apis/rbac.authorization.k8s.io/v1/watch/namespaces/{namespace}/roles func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1NamespacedRoleList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -78738,7 +92040,16 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleListRequest(args [1 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78750,8 +92061,27 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleListRequest(args [1 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78914,6 +92244,8 @@ func (s *Server) handleWatchRbacAuthorizationV1NamespacedRoleListRequest(args [1 // // GET /apis/rbac.authorization.k8s.io/v1/watch/rolebindings func (s *Server) handleWatchRbacAuthorizationV1RoleBindingListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1RoleBindingListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -78935,7 +92267,16 @@ func (s *Server) handleWatchRbacAuthorizationV1RoleBindingListForAllNamespacesRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78947,8 +92288,27 @@ func (s *Server) handleWatchRbacAuthorizationV1RoleBindingListForAllNamespacesRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79107,6 +92467,8 @@ func (s *Server) handleWatchRbacAuthorizationV1RoleBindingListForAllNamespacesRe // // GET /apis/rbac.authorization.k8s.io/v1/watch/roles func (s *Server) handleWatchRbacAuthorizationV1RoleListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchRbacAuthorizationV1RoleListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79128,7 +92490,16 @@ func (s *Server) handleWatchRbacAuthorizationV1RoleListForAllNamespacesRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79140,8 +92511,27 @@ func (s *Server) handleWatchRbacAuthorizationV1RoleListForAllNamespacesRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79300,6 +92690,8 @@ func (s *Server) handleWatchRbacAuthorizationV1RoleListForAllNamespacesRequest(a // // GET /apis/scheduling.k8s.io/v1/watch/priorityclasses/{name} func (s *Server) handleWatchSchedulingV1PriorityClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchSchedulingV1PriorityClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79321,7 +92713,16 @@ func (s *Server) handleWatchSchedulingV1PriorityClassRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79333,8 +92734,27 @@ func (s *Server) handleWatchSchedulingV1PriorityClassRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79497,6 +92917,8 @@ func (s *Server) handleWatchSchedulingV1PriorityClassRequest(args [1]string, arg // // GET /apis/scheduling.k8s.io/v1/watch/priorityclasses func (s *Server) handleWatchSchedulingV1PriorityClassListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchSchedulingV1PriorityClassList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79518,7 +92940,16 @@ func (s *Server) handleWatchSchedulingV1PriorityClassListRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79530,8 +92961,27 @@ func (s *Server) handleWatchSchedulingV1PriorityClassListRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79690,6 +93140,8 @@ func (s *Server) handleWatchSchedulingV1PriorityClassListRequest(args [0]string, // // GET /apis/storage.k8s.io/v1/watch/csidrivers/{name} func (s *Server) handleWatchStorageV1CSIDriverRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1CSIDriver"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79711,7 +93163,16 @@ func (s *Server) handleWatchStorageV1CSIDriverRequest(args [1]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79723,8 +93184,27 @@ func (s *Server) handleWatchStorageV1CSIDriverRequest(args [1]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79887,6 +93367,8 @@ func (s *Server) handleWatchStorageV1CSIDriverRequest(args [1]string, argsEscape // // GET /apis/storage.k8s.io/v1/watch/csidrivers func (s *Server) handleWatchStorageV1CSIDriverListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1CSIDriverList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -79908,7 +93390,16 @@ func (s *Server) handleWatchStorageV1CSIDriverListRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79920,8 +93411,27 @@ func (s *Server) handleWatchStorageV1CSIDriverListRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80080,6 +93590,8 @@ func (s *Server) handleWatchStorageV1CSIDriverListRequest(args [0]string, argsEs // // GET /apis/storage.k8s.io/v1/watch/csinodes/{name} func (s *Server) handleWatchStorageV1CSINodeRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1CSINode"), semconv.HTTPRequestMethodKey.String("GET"), @@ -80101,7 +93613,16 @@ func (s *Server) handleWatchStorageV1CSINodeRequest(args [1]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80113,8 +93634,27 @@ func (s *Server) handleWatchStorageV1CSINodeRequest(args [1]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80277,6 +93817,8 @@ func (s *Server) handleWatchStorageV1CSINodeRequest(args [1]string, argsEscaped // // GET /apis/storage.k8s.io/v1/watch/csinodes func (s *Server) handleWatchStorageV1CSINodeListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1CSINodeList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -80298,7 +93840,16 @@ func (s *Server) handleWatchStorageV1CSINodeListRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80310,8 +93861,27 @@ func (s *Server) handleWatchStorageV1CSINodeListRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80470,6 +94040,8 @@ func (s *Server) handleWatchStorageV1CSINodeListRequest(args [0]string, argsEsca // // GET /apis/storage.k8s.io/v1/watch/storageclasses/{name} func (s *Server) handleWatchStorageV1StorageClassRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1StorageClass"), semconv.HTTPRequestMethodKey.String("GET"), @@ -80491,7 +94063,16 @@ func (s *Server) handleWatchStorageV1StorageClassRequest(args [1]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80503,8 +94084,27 @@ func (s *Server) handleWatchStorageV1StorageClassRequest(args [1]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80667,6 +94267,8 @@ func (s *Server) handleWatchStorageV1StorageClassRequest(args [1]string, argsEsc // // GET /apis/storage.k8s.io/v1/watch/storageclasses func (s *Server) handleWatchStorageV1StorageClassListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1StorageClassList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -80688,7 +94290,16 @@ func (s *Server) handleWatchStorageV1StorageClassListRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80700,8 +94311,27 @@ func (s *Server) handleWatchStorageV1StorageClassListRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80860,6 +94490,8 @@ func (s *Server) handleWatchStorageV1StorageClassListRequest(args [0]string, arg // // GET /apis/storage.k8s.io/v1/watch/volumeattachments/{name} func (s *Server) handleWatchStorageV1VolumeAttachmentRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1VolumeAttachment"), semconv.HTTPRequestMethodKey.String("GET"), @@ -80881,7 +94513,16 @@ func (s *Server) handleWatchStorageV1VolumeAttachmentRequest(args [1]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80893,8 +94534,27 @@ func (s *Server) handleWatchStorageV1VolumeAttachmentRequest(args [1]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81057,6 +94717,8 @@ func (s *Server) handleWatchStorageV1VolumeAttachmentRequest(args [1]string, arg // // GET /apis/storage.k8s.io/v1/watch/volumeattachments func (s *Server) handleWatchStorageV1VolumeAttachmentListRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1VolumeAttachmentList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81078,7 +94740,16 @@ func (s *Server) handleWatchStorageV1VolumeAttachmentListRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81090,8 +94761,27 @@ func (s *Server) handleWatchStorageV1VolumeAttachmentListRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81250,6 +94940,8 @@ func (s *Server) handleWatchStorageV1VolumeAttachmentListRequest(args [0]string, // // GET /apis/storage.k8s.io/v1alpha1/watch/csistoragecapacities func (s *Server) handleWatchStorageV1alpha1CSIStorageCapacityListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1alpha1CSIStorageCapacityListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81271,7 +94963,16 @@ func (s *Server) handleWatchStorageV1alpha1CSIStorageCapacityListForAllNamespace startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81283,8 +94984,27 @@ func (s *Server) handleWatchStorageV1alpha1CSIStorageCapacityListForAllNamespace var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81443,6 +95163,8 @@ func (s *Server) handleWatchStorageV1alpha1CSIStorageCapacityListForAllNamespace // // GET /apis/storage.k8s.io/v1alpha1/watch/namespaces/{namespace}/csistoragecapacities/{name} func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1alpha1NamespacedCSIStorageCapacity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81464,7 +95186,16 @@ func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81476,8 +95207,27 @@ func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81644,6 +95394,8 @@ func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityRequest(a // // GET /apis/storage.k8s.io/v1alpha1/watch/namespaces/{namespace}/csistoragecapacities func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1alpha1NamespacedCSIStorageCapacityList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81665,7 +95417,16 @@ func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityListReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81677,8 +95438,27 @@ func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityListReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81841,6 +95621,8 @@ func (s *Server) handleWatchStorageV1alpha1NamespacedCSIStorageCapacityListReque // // GET /apis/storage.k8s.io/v1beta1/watch/csistoragecapacities func (s *Server) handleWatchStorageV1beta1CSIStorageCapacityListForAllNamespacesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1beta1CSIStorageCapacityListForAllNamespaces"), semconv.HTTPRequestMethodKey.String("GET"), @@ -81862,7 +95644,16 @@ func (s *Server) handleWatchStorageV1beta1CSIStorageCapacityListForAllNamespaces startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81874,8 +95665,27 @@ func (s *Server) handleWatchStorageV1beta1CSIStorageCapacityListForAllNamespaces var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82034,6 +95844,8 @@ func (s *Server) handleWatchStorageV1beta1CSIStorageCapacityListForAllNamespaces // // GET /apis/storage.k8s.io/v1beta1/watch/namespaces/{namespace}/csistoragecapacities/{name} func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1beta1NamespacedCSIStorageCapacity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -82055,7 +95867,16 @@ func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82067,8 +95888,27 @@ func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82235,6 +96075,8 @@ func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityRequest(ar // // GET /apis/storage.k8s.io/v1beta1/watch/namespaces/{namespace}/csistoragecapacities func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityListRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("watchStorageV1beta1NamespacedCSIStorageCapacityList"), semconv.HTTPRequestMethodKey.String("GET"), @@ -82256,7 +96098,16 @@ func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityListReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82268,8 +96119,27 @@ func (s *Server) handleWatchStorageV1beta1NamespacedCSIStorageCapacityListReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_manga/oas_handlers_gen.go b/examples/ex_manga/oas_handlers_gen.go index 8020e9b25..cd488b567 100644 --- a/examples/ex_manga/oas_handlers_gen.go +++ b/examples/ex_manga/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleGetBookRequest handles getBook operation. // // Gets metadata of book. // // GET /api/gallery/{book_id} func (s *Server) handleGetBookRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getBook"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47,7 +59,16 @@ func (s *Server) handleGetBookRequest(args [1]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleGetBookRequest(args [1]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -138,6 +178,8 @@ func (s *Server) handleGetBookRequest(args [1]string, argsEscaped bool, w http.R // // GET /galleries/{media_id}/cover.{format} func (s *Server) handleGetPageCoverImageRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPageCoverImage"), semconv.HTTPRequestMethodKey.String("GET"), @@ -159,7 +201,16 @@ func (s *Server) handleGetPageCoverImageRequest(args [2]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -171,8 +222,27 @@ func (s *Server) handleGetPageCoverImageRequest(args [2]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -254,6 +324,8 @@ func (s *Server) handleGetPageCoverImageRequest(args [2]string, argsEscaped bool // // GET /galleries/{media_id}/{page}.{format} func (s *Server) handleGetPageImageRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPageImage"), semconv.HTTPRequestMethodKey.String("GET"), @@ -275,7 +347,16 @@ func (s *Server) handleGetPageImageRequest(args [3]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -287,8 +368,27 @@ func (s *Server) handleGetPageImageRequest(args [3]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -374,6 +474,8 @@ func (s *Server) handleGetPageImageRequest(args [3]string, argsEscaped bool, w h // // GET /galleries/{media_id}/{page}t.{format} func (s *Server) handleGetPageThumbnailImageRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPageThumbnailImage"), semconv.HTTPRequestMethodKey.String("GET"), @@ -395,7 +497,16 @@ func (s *Server) handleGetPageThumbnailImageRequest(args [3]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -407,8 +518,27 @@ func (s *Server) handleGetPageThumbnailImageRequest(args [3]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -494,6 +624,8 @@ func (s *Server) handleGetPageThumbnailImageRequest(args [3]string, argsEscaped // // GET /api/galleries/search func (s *Server) handleSearchRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("search"), semconv.HTTPRequestMethodKey.String("GET"), @@ -515,7 +647,16 @@ func (s *Server) handleSearchRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -527,8 +668,27 @@ func (s *Server) handleSearchRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -610,6 +770,8 @@ func (s *Server) handleSearchRequest(args [0]string, argsEscaped bool, w http.Re // // GET /api/galleries/tagged func (s *Server) handleSearchByTagIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("searchByTagID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -631,7 +793,16 @@ func (s *Server) handleSearchByTagIDRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -643,8 +814,27 @@ func (s *Server) handleSearchByTagIDRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_oauth2/oas_handlers_gen.go b/examples/ex_oauth2/oas_handlers_gen.go index 3144882ee..bad95fb04 100644 --- a/examples/ex_oauth2/oas_handlers_gen.go +++ b/examples/ex_oauth2/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAddPetRequest handles addPet operation. // // Creates a new pet in the store. Duplicates are allowed. // // POST /pets func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("addPet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -195,6 +235,8 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re // // DELETE /pets/{id} func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deletePet"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -216,7 +258,16 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -228,8 +279,27 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -364,6 +434,8 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http // // GET /pets/{id} func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("find pet by id"), semconv.HTTPRequestMethodKey.String("GET"), @@ -385,7 +457,16 @@ func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -397,8 +478,27 @@ func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -551,6 +651,8 @@ func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w ht // // GET /pets func (s *Server) handleFindPetsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("findPets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -572,7 +674,16 @@ func (s *Server) handleFindPetsRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -584,8 +695,27 @@ func (s *Server) handleFindPetsRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_openai/oas_handlers_gen.go b/examples/ex_openai/oas_handlers_gen.go index 4ee3f4507..203b5bb6d 100644 --- a/examples/ex_openai/oas_handlers_gen.go +++ b/examples/ex_openai/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCancelFineTuneRequest handles cancelFineTune operation. // // Immediately cancel a fine-tune job. // // POST /fine-tunes/{fine_tune_id}/cancel func (s *Server) handleCancelFineTuneRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("cancelFineTune"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleCancelFineTuneRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleCancelFineTuneRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -143,6 +183,8 @@ func (s *Server) handleCancelFineTuneRequest(args [1]string, argsEscaped bool, w // // POST /answers func (s *Server) handleCreateAnswerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createAnswer"), semconv.HTTPRequestMethodKey.String("POST"), @@ -164,7 +206,16 @@ func (s *Server) handleCreateAnswerRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -176,8 +227,27 @@ func (s *Server) handleCreateAnswerRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -255,6 +325,8 @@ func (s *Server) handleCreateAnswerRequest(args [0]string, argsEscaped bool, w h // // POST /chat/completions func (s *Server) handleCreateChatCompletionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createChatCompletion"), semconv.HTTPRequestMethodKey.String("POST"), @@ -276,7 +348,16 @@ func (s *Server) handleCreateChatCompletionRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -288,8 +369,27 @@ func (s *Server) handleCreateChatCompletionRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -375,6 +475,8 @@ func (s *Server) handleCreateChatCompletionRequest(args [0]string, argsEscaped b // // POST /classifications func (s *Server) handleCreateClassificationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createClassification"), semconv.HTTPRequestMethodKey.String("POST"), @@ -396,7 +498,16 @@ func (s *Server) handleCreateClassificationRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -408,8 +519,27 @@ func (s *Server) handleCreateClassificationRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -487,6 +617,8 @@ func (s *Server) handleCreateClassificationRequest(args [0]string, argsEscaped b // // POST /completions func (s *Server) handleCreateCompletionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createCompletion"), semconv.HTTPRequestMethodKey.String("POST"), @@ -508,7 +640,16 @@ func (s *Server) handleCreateCompletionRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -520,8 +661,27 @@ func (s *Server) handleCreateCompletionRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -599,6 +759,8 @@ func (s *Server) handleCreateCompletionRequest(args [0]string, argsEscaped bool, // // POST /edits func (s *Server) handleCreateEditRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createEdit"), semconv.HTTPRequestMethodKey.String("POST"), @@ -620,7 +782,16 @@ func (s *Server) handleCreateEditRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -632,8 +803,27 @@ func (s *Server) handleCreateEditRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -711,6 +901,8 @@ func (s *Server) handleCreateEditRequest(args [0]string, argsEscaped bool, w htt // // POST /embeddings func (s *Server) handleCreateEmbeddingRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createEmbedding"), semconv.HTTPRequestMethodKey.String("POST"), @@ -732,7 +924,16 @@ func (s *Server) handleCreateEmbeddingRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -744,8 +945,27 @@ func (s *Server) handleCreateEmbeddingRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -825,6 +1045,8 @@ func (s *Server) handleCreateEmbeddingRequest(args [0]string, argsEscaped bool, // // POST /files func (s *Server) handleCreateFileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createFile"), semconv.HTTPRequestMethodKey.String("POST"), @@ -846,7 +1068,16 @@ func (s *Server) handleCreateFileRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -858,8 +1089,27 @@ func (s *Server) handleCreateFileRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -940,6 +1190,8 @@ func (s *Server) handleCreateFileRequest(args [0]string, argsEscaped bool, w htt // // POST /fine-tunes func (s *Server) handleCreateFineTuneRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createFineTune"), semconv.HTTPRequestMethodKey.String("POST"), @@ -961,7 +1213,16 @@ func (s *Server) handleCreateFineTuneRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -973,8 +1234,27 @@ func (s *Server) handleCreateFineTuneRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1052,6 +1332,8 @@ func (s *Server) handleCreateFineTuneRequest(args [0]string, argsEscaped bool, w // // POST /images/generations func (s *Server) handleCreateImageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createImage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1073,7 +1355,16 @@ func (s *Server) handleCreateImageRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1085,8 +1376,27 @@ func (s *Server) handleCreateImageRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1164,6 +1474,8 @@ func (s *Server) handleCreateImageRequest(args [0]string, argsEscaped bool, w ht // // POST /images/edits func (s *Server) handleCreateImageEditRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createImageEdit"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1185,7 +1497,16 @@ func (s *Server) handleCreateImageEditRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1197,8 +1518,27 @@ func (s *Server) handleCreateImageEditRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1276,6 +1616,8 @@ func (s *Server) handleCreateImageEditRequest(args [0]string, argsEscaped bool, // // POST /images/variations func (s *Server) handleCreateImageVariationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createImageVariation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1297,7 +1639,16 @@ func (s *Server) handleCreateImageVariationRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1309,8 +1660,27 @@ func (s *Server) handleCreateImageVariationRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1388,6 +1758,8 @@ func (s *Server) handleCreateImageVariationRequest(args [0]string, argsEscaped b // // POST /moderations func (s *Server) handleCreateModerationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createModeration"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1409,7 +1781,16 @@ func (s *Server) handleCreateModerationRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1421,8 +1802,27 @@ func (s *Server) handleCreateModerationRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1509,6 +1909,8 @@ func (s *Server) handleCreateModerationRequest(args [0]string, argsEscaped bool, // // POST /engines/{engine_id}/search func (s *Server) handleCreateSearchRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createSearch"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1530,7 +1932,16 @@ func (s *Server) handleCreateSearchRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1542,8 +1953,27 @@ func (s *Server) handleCreateSearchRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1636,6 +2066,8 @@ func (s *Server) handleCreateSearchRequest(args [1]string, argsEscaped bool, w h // // POST /audio/transcriptions func (s *Server) handleCreateTranscriptionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createTranscription"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1657,7 +2089,16 @@ func (s *Server) handleCreateTranscriptionRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1669,8 +2110,27 @@ func (s *Server) handleCreateTranscriptionRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1748,6 +2208,8 @@ func (s *Server) handleCreateTranscriptionRequest(args [0]string, argsEscaped bo // // POST /audio/translations func (s *Server) handleCreateTranslationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createTranslation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1769,7 +2231,16 @@ func (s *Server) handleCreateTranslationRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1781,8 +2252,27 @@ func (s *Server) handleCreateTranslationRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1860,6 +2350,8 @@ func (s *Server) handleCreateTranslationRequest(args [0]string, argsEscaped bool // // DELETE /files/{file_id} func (s *Server) handleDeleteFileRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteFile"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -1881,7 +2373,16 @@ func (s *Server) handleDeleteFileRequest(args [1]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1893,8 +2394,27 @@ func (s *Server) handleDeleteFileRequest(args [1]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1972,6 +2492,8 @@ func (s *Server) handleDeleteFileRequest(args [1]string, argsEscaped bool, w htt // // DELETE /models/{model} func (s *Server) handleDeleteModelRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteModel"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -1993,7 +2515,16 @@ func (s *Server) handleDeleteModelRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2005,8 +2536,27 @@ func (s *Server) handleDeleteModelRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2084,6 +2634,8 @@ func (s *Server) handleDeleteModelRequest(args [1]string, argsEscaped bool, w ht // // GET /files/{file_id}/content func (s *Server) handleDownloadFileRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("downloadFile"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2105,7 +2657,16 @@ func (s *Server) handleDownloadFileRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2117,8 +2678,27 @@ func (s *Server) handleDownloadFileRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2199,6 +2779,8 @@ func (s *Server) handleDownloadFileRequest(args [1]string, argsEscaped bool, w h // // GET /engines func (s *Server) handleListEnginesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listEngines"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2220,7 +2802,16 @@ func (s *Server) handleListEnginesRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2232,8 +2823,27 @@ func (s *Server) handleListEnginesRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2292,6 +2902,8 @@ func (s *Server) handleListEnginesRequest(args [0]string, argsEscaped bool, w ht // // GET /files func (s *Server) handleListFilesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFiles"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2313,7 +2925,16 @@ func (s *Server) handleListFilesRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2325,8 +2946,27 @@ func (s *Server) handleListFilesRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2385,6 +3025,8 @@ func (s *Server) handleListFilesRequest(args [0]string, argsEscaped bool, w http // // GET /fine-tunes/{fine_tune_id}/events func (s *Server) handleListFineTuneEventsRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFineTuneEvents"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2406,7 +3048,16 @@ func (s *Server) handleListFineTuneEventsRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2418,8 +3069,27 @@ func (s *Server) handleListFineTuneEventsRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2501,6 +3171,8 @@ func (s *Server) handleListFineTuneEventsRequest(args [1]string, argsEscaped boo // // GET /fine-tunes func (s *Server) handleListFineTunesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listFineTunes"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2522,7 +3194,16 @@ func (s *Server) handleListFineTunesRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2534,8 +3215,27 @@ func (s *Server) handleListFineTunesRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2595,6 +3295,8 @@ func (s *Server) handleListFineTunesRequest(args [0]string, argsEscaped bool, w // // GET /models func (s *Server) handleListModelsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listModels"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2616,7 +3318,16 @@ func (s *Server) handleListModelsRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2628,8 +3339,27 @@ func (s *Server) handleListModelsRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2691,6 +3421,8 @@ func (s *Server) handleListModelsRequest(args [0]string, argsEscaped bool, w htt // // GET /engines/{engine_id} func (s *Server) handleRetrieveEngineRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("retrieveEngine"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2712,7 +3444,16 @@ func (s *Server) handleRetrieveEngineRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2724,8 +3465,27 @@ func (s *Server) handleRetrieveEngineRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2803,6 +3563,8 @@ func (s *Server) handleRetrieveEngineRequest(args [1]string, argsEscaped bool, w // // GET /files/{file_id} func (s *Server) handleRetrieveFileRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("retrieveFile"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2824,7 +3586,16 @@ func (s *Server) handleRetrieveFileRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2836,8 +3607,27 @@ func (s *Server) handleRetrieveFileRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2916,6 +3706,8 @@ func (s *Server) handleRetrieveFileRequest(args [1]string, argsEscaped bool, w h // // GET /fine-tunes/{fine_tune_id} func (s *Server) handleRetrieveFineTuneRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("retrieveFineTune"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2937,7 +3729,16 @@ func (s *Server) handleRetrieveFineTuneRequest(args [1]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2949,8 +3750,27 @@ func (s *Server) handleRetrieveFineTuneRequest(args [1]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3029,6 +3849,8 @@ func (s *Server) handleRetrieveFineTuneRequest(args [1]string, argsEscaped bool, // // GET /models/{model} func (s *Server) handleRetrieveModelRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("retrieveModel"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3050,7 +3872,16 @@ func (s *Server) handleRetrieveModelRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3062,8 +3893,27 @@ func (s *Server) handleRetrieveModelRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_petstore/oas_handlers_gen.go b/examples/ex_petstore/oas_handlers_gen.go index 7cb5f0328..8c818a844 100644 --- a/examples/ex_petstore/oas_handlers_gen.go +++ b/examples/ex_petstore/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCreatePetsRequest handles createPets operation. // // Create a pet. // // POST /pets func (s *Server) handleCreatePetsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createPets"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleCreatePetsRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleCreatePetsRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -130,6 +170,8 @@ func (s *Server) handleCreatePetsRequest(args [0]string, argsEscaped bool, w htt // // GET /pets func (s *Server) handleListPetsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("listPets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -151,7 +193,16 @@ func (s *Server) handleListPetsRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -163,8 +214,27 @@ func (s *Server) handleListPetsRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -253,6 +323,8 @@ func (s *Server) handleListPetsRequest(args [0]string, argsEscaped bool, w http. // // GET /pets/{petId} func (s *Server) handleShowPetByIdRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("showPetById"), semconv.HTTPRequestMethodKey.String("GET"), @@ -274,7 +346,16 @@ func (s *Server) handleShowPetByIdRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -286,8 +367,27 @@ func (s *Server) handleShowPetByIdRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_petstore_expanded/oas_handlers_gen.go b/examples/ex_petstore_expanded/oas_handlers_gen.go index 794f518e0..04bcb5ade 100644 --- a/examples/ex_petstore_expanded/oas_handlers_gen.go +++ b/examples/ex_petstore_expanded/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAddPetRequest handles addPet operation. // // Creates a new pet in the store. Duplicates are allowed. // // POST /pets func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("addPet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -149,6 +189,8 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re // // DELETE /pets/{id} func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deletePet"), semconv.HTTPRequestMethodKey.String("DELETE"), @@ -170,7 +212,16 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -182,8 +233,27 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -272,6 +342,8 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http // // GET /pets/{id} func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("find pet by id"), semconv.HTTPRequestMethodKey.String("GET"), @@ -293,7 +365,16 @@ func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -305,8 +386,27 @@ func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -413,6 +513,8 @@ func (s *Server) handleFindPetByIDRequest(args [1]string, argsEscaped bool, w ht // // GET /pets func (s *Server) handleFindPetsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("findPets"), semconv.HTTPRequestMethodKey.String("GET"), @@ -434,7 +536,16 @@ func (s *Server) handleFindPetsRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -446,8 +557,27 @@ func (s *Server) handleFindPetsRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_route_params/oas_handlers_gen.go b/examples/ex_route_params/oas_handlers_gen.go index c53123878..ed7f7223b 100644 --- a/examples/ex_route_params/oas_handlers_gen.go +++ b/examples/ex_route_params/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleDataGetRequest handles dataGet operation. // // Retrieve data. // // GET /name/{id}/{key} func (s *Server) handleDataGetRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47,7 +59,16 @@ func (s *Server) handleDataGetRequest(args [2]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleDataGetRequest(args [2]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -142,6 +182,8 @@ func (s *Server) handleDataGetRequest(args [2]string, argsEscaped bool, w http.R // // GET /name func (s *Server) handleDataGetAnyRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataGetAny"), semconv.HTTPRequestMethodKey.String("GET"), @@ -163,7 +205,16 @@ func (s *Server) handleDataGetAnyRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -175,8 +226,27 @@ func (s *Server) handleDataGetAnyRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -235,6 +305,8 @@ func (s *Server) handleDataGetAnyRequest(args [0]string, argsEscaped bool, w htt // // GET /name/{id} func (s *Server) handleDataGetIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataGetID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -256,7 +328,16 @@ func (s *Server) handleDataGetIDRequest(args [1]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -268,8 +349,27 @@ func (s *Server) handleDataGetIDRequest(args [1]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_telegram/oas_handlers_gen.go b/examples/ex_telegram/oas_handlers_gen.go index d746bfbca..a5a6fcfe9 100644 --- a/examples/ex_telegram/oas_handlers_gen.go +++ b/examples/ex_telegram/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAddStickerToSetRequest handles addStickerToSet operation. // // POST /addStickerToSet func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("addStickerToSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45,7 +57,16 @@ func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -145,6 +185,8 @@ func (s *Server) handleAddStickerToSetRequest(args [0]string, argsEscaped bool, // // POST /answerCallbackQuery func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerCallbackQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -166,7 +208,16 @@ func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -178,8 +229,27 @@ func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -266,6 +336,8 @@ func (s *Server) handleAnswerCallbackQueryRequest(args [0]string, argsEscaped bo // // POST /answerInlineQuery func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerInlineQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -287,7 +359,16 @@ func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -299,8 +380,27 @@ func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -387,6 +487,8 @@ func (s *Server) handleAnswerInlineQueryRequest(args [0]string, argsEscaped bool // // POST /answerPreCheckoutQuery func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerPreCheckoutQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -408,7 +510,16 @@ func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -420,8 +531,27 @@ func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -508,6 +638,8 @@ func (s *Server) handleAnswerPreCheckoutQueryRequest(args [0]string, argsEscaped // // POST /answerShippingQuery func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("answerShippingQuery"), semconv.HTTPRequestMethodKey.String("POST"), @@ -529,7 +661,16 @@ func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -541,8 +682,27 @@ func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -629,6 +789,8 @@ func (s *Server) handleAnswerShippingQueryRequest(args [0]string, argsEscaped bo // // POST /approveChatJoinRequest func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("approveChatJoinRequest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -650,7 +812,16 @@ func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -662,8 +833,27 @@ func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -750,6 +940,8 @@ func (s *Server) handleApproveChatJoinRequestRequest(args [0]string, argsEscaped // // POST /banChatMember func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("banChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -771,7 +963,16 @@ func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -783,8 +984,27 @@ func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -871,6 +1091,8 @@ func (s *Server) handleBanChatMemberRequest(args [0]string, argsEscaped bool, w // // POST /banChatSenderChat func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("banChatSenderChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -892,7 +1114,16 @@ func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -904,8 +1135,27 @@ func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -992,6 +1242,8 @@ func (s *Server) handleBanChatSenderChatRequest(args [0]string, argsEscaped bool // // POST /close func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("close"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1013,7 +1265,16 @@ func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.Res startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1025,8 +1286,27 @@ func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.Res var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1094,6 +1374,8 @@ func (s *Server) handleCloseRequest(args [0]string, argsEscaped bool, w http.Res // // POST /copyMessage func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("copyMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1115,7 +1397,16 @@ func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1127,8 +1418,27 @@ func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1215,6 +1525,8 @@ func (s *Server) handleCopyMessageRequest(args [0]string, argsEscaped bool, w ht // // POST /createChatInviteLink func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1236,7 +1548,16 @@ func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1248,8 +1569,27 @@ func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1336,6 +1676,8 @@ func (s *Server) handleCreateChatInviteLinkRequest(args [0]string, argsEscaped b // // POST /createNewStickerSet func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("createNewStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1357,7 +1699,16 @@ func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1369,8 +1720,27 @@ func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1457,6 +1827,8 @@ func (s *Server) handleCreateNewStickerSetRequest(args [0]string, argsEscaped bo // // POST /declineChatJoinRequest func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("declineChatJoinRequest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1478,7 +1850,16 @@ func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1490,8 +1871,27 @@ func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1578,6 +1978,8 @@ func (s *Server) handleDeclineChatJoinRequestRequest(args [0]string, argsEscaped // // POST /deleteChatPhoto func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteChatPhoto"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1599,7 +2001,16 @@ func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1611,8 +2022,27 @@ func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1699,6 +2129,8 @@ func (s *Server) handleDeleteChatPhotoRequest(args [0]string, argsEscaped bool, // // POST /deleteChatStickerSet func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteChatStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1720,7 +2152,16 @@ func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1732,8 +2173,27 @@ func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1820,6 +2280,8 @@ func (s *Server) handleDeleteChatStickerSetRequest(args [0]string, argsEscaped b // // POST /deleteMessage func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1841,7 +2303,16 @@ func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1853,8 +2324,27 @@ func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1941,6 +2431,8 @@ func (s *Server) handleDeleteMessageRequest(args [0]string, argsEscaped bool, w // // POST /deleteMyCommands func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteMyCommands"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1962,7 +2454,16 @@ func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1974,8 +2475,27 @@ func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2062,6 +2582,8 @@ func (s *Server) handleDeleteMyCommandsRequest(args [0]string, argsEscaped bool, // // POST /deleteStickerFromSet func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteStickerFromSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2083,7 +2605,16 @@ func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2095,8 +2626,27 @@ func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2183,6 +2733,8 @@ func (s *Server) handleDeleteStickerFromSetRequest(args [0]string, argsEscaped b // // POST /deleteWebhook func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deleteWebhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2204,7 +2756,16 @@ func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2216,8 +2777,27 @@ func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2304,6 +2884,8 @@ func (s *Server) handleDeleteWebhookRequest(args [0]string, argsEscaped bool, w // // POST /editChatInviteLink func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2325,7 +2907,16 @@ func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2337,8 +2928,27 @@ func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2425,6 +3035,8 @@ func (s *Server) handleEditChatInviteLinkRequest(args [0]string, argsEscaped boo // // POST /editMessageCaption func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageCaption"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2446,7 +3058,16 @@ func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2458,8 +3079,27 @@ func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2546,6 +3186,8 @@ func (s *Server) handleEditMessageCaptionRequest(args [0]string, argsEscaped boo // // POST /editMessageLiveLocation func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageLiveLocation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2567,7 +3209,16 @@ func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2579,8 +3230,27 @@ func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2667,6 +3337,8 @@ func (s *Server) handleEditMessageLiveLocationRequest(args [0]string, argsEscape // // POST /editMessageMedia func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageMedia"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2688,7 +3360,16 @@ func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2700,8 +3381,27 @@ func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2788,6 +3488,8 @@ func (s *Server) handleEditMessageMediaRequest(args [0]string, argsEscaped bool, // // POST /editMessageReplyMarkup func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageReplyMarkup"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2809,7 +3511,16 @@ func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2821,8 +3532,27 @@ func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2909,6 +3639,8 @@ func (s *Server) handleEditMessageReplyMarkupRequest(args [0]string, argsEscaped // // POST /editMessageText func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("editMessageText"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2930,7 +3662,16 @@ func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2942,8 +3683,27 @@ func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3030,6 +3790,8 @@ func (s *Server) handleEditMessageTextRequest(args [0]string, argsEscaped bool, // // POST /exportChatInviteLink func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("exportChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3051,7 +3813,16 @@ func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3063,8 +3834,27 @@ func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3151,6 +3941,8 @@ func (s *Server) handleExportChatInviteLinkRequest(args [0]string, argsEscaped b // // POST /forwardMessage func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("forwardMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3172,7 +3964,16 @@ func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3184,8 +3985,27 @@ func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3272,6 +4092,8 @@ func (s *Server) handleForwardMessageRequest(args [0]string, argsEscaped bool, w // // POST /getChat func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3293,7 +4115,16 @@ func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3305,8 +4136,27 @@ func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3393,6 +4243,8 @@ func (s *Server) handleGetChatRequest(args [0]string, argsEscaped bool, w http.R // // POST /getChatAdministrators func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatAdministrators"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3414,7 +4266,16 @@ func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3426,8 +4287,27 @@ func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3514,6 +4394,8 @@ func (s *Server) handleGetChatAdministratorsRequest(args [0]string, argsEscaped // // POST /getChatMember func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3535,7 +4417,16 @@ func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3547,8 +4438,27 @@ func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3635,6 +4545,8 @@ func (s *Server) handleGetChatMemberRequest(args [0]string, argsEscaped bool, w // // POST /getChatMemberCount func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getChatMemberCount"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3656,7 +4568,16 @@ func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3668,8 +4589,27 @@ func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3756,6 +4696,8 @@ func (s *Server) handleGetChatMemberCountRequest(args [0]string, argsEscaped boo // // POST /getFile func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getFile"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3777,7 +4719,16 @@ func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3789,8 +4740,27 @@ func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3877,6 +4847,8 @@ func (s *Server) handleGetFileRequest(args [0]string, argsEscaped bool, w http.R // // POST /getGameHighScores func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getGameHighScores"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3898,7 +4870,16 @@ func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3910,8 +4891,27 @@ func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3998,6 +4998,8 @@ func (s *Server) handleGetGameHighScoresRequest(args [0]string, argsEscaped bool // // POST /getMe func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getMe"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4019,7 +5021,16 @@ func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.Res startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4031,8 +5042,27 @@ func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.Res var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -4100,6 +5130,8 @@ func (s *Server) handleGetMeRequest(args [0]string, argsEscaped bool, w http.Res // // POST /getMyCommands func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getMyCommands"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4121,7 +5153,16 @@ func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4133,8 +5174,27 @@ func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4221,6 +5281,8 @@ func (s *Server) handleGetMyCommandsRequest(args [0]string, argsEscaped bool, w // // POST /getStickerSet func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4242,7 +5304,16 @@ func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4254,8 +5325,27 @@ func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4342,6 +5432,8 @@ func (s *Server) handleGetStickerSetRequest(args [0]string, argsEscaped bool, w // // POST /getUpdates func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getUpdates"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4363,7 +5455,16 @@ func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4375,8 +5476,27 @@ func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4463,6 +5583,8 @@ func (s *Server) handleGetUpdatesRequest(args [0]string, argsEscaped bool, w htt // // POST /getUserProfilePhotos func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getUserProfilePhotos"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4484,7 +5606,16 @@ func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4496,8 +5627,27 @@ func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4584,6 +5734,8 @@ func (s *Server) handleGetUserProfilePhotosRequest(args [0]string, argsEscaped b // // POST /getWebhookInfo func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getWebhookInfo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4605,7 +5757,16 @@ func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4617,8 +5778,27 @@ func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -4686,6 +5866,8 @@ func (s *Server) handleGetWebhookInfoRequest(args [0]string, argsEscaped bool, w // // POST /leaveChat func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("leaveChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4707,7 +5889,16 @@ func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4719,8 +5910,27 @@ func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4807,6 +6017,8 @@ func (s *Server) handleLeaveChatRequest(args [0]string, argsEscaped bool, w http // // POST /logOut func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("logOut"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4828,7 +6040,16 @@ func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4840,8 +6061,27 @@ func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -4909,6 +6149,8 @@ func (s *Server) handleLogOutRequest(args [0]string, argsEscaped bool, w http.Re // // POST /pinChatMessage func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pinChatMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4930,7 +6172,16 @@ func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4942,8 +6193,27 @@ func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5030,6 +6300,8 @@ func (s *Server) handlePinChatMessageRequest(args [0]string, argsEscaped bool, w // // POST /promoteChatMember func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("promoteChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5051,7 +6323,16 @@ func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5063,8 +6344,27 @@ func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5151,6 +6451,8 @@ func (s *Server) handlePromoteChatMemberRequest(args [0]string, argsEscaped bool // // POST /restrictChatMember func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("restrictChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5172,7 +6474,16 @@ func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5184,8 +6495,27 @@ func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5272,6 +6602,8 @@ func (s *Server) handleRestrictChatMemberRequest(args [0]string, argsEscaped boo // // POST /revokeChatInviteLink func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("revokeChatInviteLink"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5293,7 +6625,16 @@ func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5305,8 +6646,27 @@ func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5393,6 +6753,8 @@ func (s *Server) handleRevokeChatInviteLinkRequest(args [0]string, argsEscaped b // // POST /sendAnimation func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendAnimation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5414,7 +6776,16 @@ func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5426,8 +6797,27 @@ func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5514,6 +6904,8 @@ func (s *Server) handleSendAnimationRequest(args [0]string, argsEscaped bool, w // // POST /sendAudio func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendAudio"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5535,7 +6927,16 @@ func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5547,8 +6948,27 @@ func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5635,6 +7055,8 @@ func (s *Server) handleSendAudioRequest(args [0]string, argsEscaped bool, w http // // POST /sendChatAction func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendChatAction"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5656,7 +7078,16 @@ func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5668,8 +7099,27 @@ func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5756,6 +7206,8 @@ func (s *Server) handleSendChatActionRequest(args [0]string, argsEscaped bool, w // // POST /sendContact func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendContact"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5777,7 +7229,16 @@ func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5789,8 +7250,27 @@ func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5877,6 +7357,8 @@ func (s *Server) handleSendContactRequest(args [0]string, argsEscaped bool, w ht // // POST /sendDice func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendDice"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5898,7 +7380,16 @@ func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5910,8 +7401,27 @@ func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5998,6 +7508,8 @@ func (s *Server) handleSendDiceRequest(args [0]string, argsEscaped bool, w http. // // POST /sendDocument func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendDocument"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6019,7 +7531,16 @@ func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6031,8 +7552,27 @@ func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6119,6 +7659,8 @@ func (s *Server) handleSendDocumentRequest(args [0]string, argsEscaped bool, w h // // POST /sendGame func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendGame"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6140,7 +7682,16 @@ func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6152,8 +7703,27 @@ func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6240,6 +7810,8 @@ func (s *Server) handleSendGameRequest(args [0]string, argsEscaped bool, w http. // // POST /sendInvoice func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendInvoice"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6261,7 +7833,16 @@ func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6273,8 +7854,27 @@ func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6361,6 +7961,8 @@ func (s *Server) handleSendInvoiceRequest(args [0]string, argsEscaped bool, w ht // // POST /sendLocation func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendLocation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6382,7 +7984,16 @@ func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6394,8 +8005,27 @@ func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6482,6 +8112,8 @@ func (s *Server) handleSendLocationRequest(args [0]string, argsEscaped bool, w h // // POST /sendMediaGroup func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendMediaGroup"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6503,7 +8135,16 @@ func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6515,8 +8156,27 @@ func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6603,6 +8263,8 @@ func (s *Server) handleSendMediaGroupRequest(args [0]string, argsEscaped bool, w // // POST /sendMessage func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6624,7 +8286,16 @@ func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6636,8 +8307,27 @@ func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6724,6 +8414,8 @@ func (s *Server) handleSendMessageRequest(args [0]string, argsEscaped bool, w ht // // POST /sendPhoto func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendPhoto"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6745,7 +8437,16 @@ func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6757,8 +8458,27 @@ func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6845,6 +8565,8 @@ func (s *Server) handleSendPhotoRequest(args [0]string, argsEscaped bool, w http // // POST /sendPoll func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendPoll"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6866,7 +8588,16 @@ func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6878,8 +8609,27 @@ func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6966,6 +8716,8 @@ func (s *Server) handleSendPollRequest(args [0]string, argsEscaped bool, w http. // // POST /sendSticker func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendSticker"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6987,7 +8739,16 @@ func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6999,8 +8760,27 @@ func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7087,6 +8867,8 @@ func (s *Server) handleSendStickerRequest(args [0]string, argsEscaped bool, w ht // // POST /sendVenue func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVenue"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7108,7 +8890,16 @@ func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7120,8 +8911,27 @@ func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7208,6 +9018,8 @@ func (s *Server) handleSendVenueRequest(args [0]string, argsEscaped bool, w http // // POST /sendVideo func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVideo"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7229,7 +9041,16 @@ func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7241,8 +9062,27 @@ func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7329,6 +9169,8 @@ func (s *Server) handleSendVideoRequest(args [0]string, argsEscaped bool, w http // // POST /sendVideoNote func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVideoNote"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7350,7 +9192,16 @@ func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7362,8 +9213,27 @@ func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7450,6 +9320,8 @@ func (s *Server) handleSendVideoNoteRequest(args [0]string, argsEscaped bool, w // // POST /sendVoice func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sendVoice"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7471,7 +9343,16 @@ func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7483,8 +9364,27 @@ func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7571,6 +9471,8 @@ func (s *Server) handleSendVoiceRequest(args [0]string, argsEscaped bool, w http // // POST /setChatAdministratorCustomTitle func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatAdministratorCustomTitle"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7592,7 +9494,16 @@ func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7604,8 +9515,27 @@ func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7692,6 +9622,8 @@ func (s *Server) handleSetChatAdministratorCustomTitleRequest(args [0]string, ar // // POST /setChatDescription func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatDescription"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7713,7 +9645,16 @@ func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7725,8 +9666,27 @@ func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7813,6 +9773,8 @@ func (s *Server) handleSetChatDescriptionRequest(args [0]string, argsEscaped boo // // POST /setChatPermissions func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatPermissions"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7834,7 +9796,16 @@ func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7846,8 +9817,27 @@ func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7934,6 +9924,8 @@ func (s *Server) handleSetChatPermissionsRequest(args [0]string, argsEscaped boo // // POST /setChatPhoto func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatPhoto"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7955,7 +9947,16 @@ func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7967,8 +9968,27 @@ func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8055,6 +10075,8 @@ func (s *Server) handleSetChatPhotoRequest(args [0]string, argsEscaped bool, w h // // POST /setChatStickerSet func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatStickerSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8076,7 +10098,16 @@ func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8088,8 +10119,27 @@ func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8176,6 +10226,8 @@ func (s *Server) handleSetChatStickerSetRequest(args [0]string, argsEscaped bool // // POST /setChatTitle func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setChatTitle"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8197,7 +10249,16 @@ func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8209,8 +10270,27 @@ func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8297,6 +10377,8 @@ func (s *Server) handleSetChatTitleRequest(args [0]string, argsEscaped bool, w h // // POST /setGameScore func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setGameScore"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8318,7 +10400,16 @@ func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8330,8 +10421,27 @@ func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8418,6 +10528,8 @@ func (s *Server) handleSetGameScoreRequest(args [0]string, argsEscaped bool, w h // // POST /setMyCommands func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setMyCommands"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8439,7 +10551,16 @@ func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8451,8 +10572,27 @@ func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8539,6 +10679,8 @@ func (s *Server) handleSetMyCommandsRequest(args [0]string, argsEscaped bool, w // // POST /setPassportDataErrors func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setPassportDataErrors"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8560,7 +10702,16 @@ func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8572,8 +10723,27 @@ func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8660,6 +10830,8 @@ func (s *Server) handleSetPassportDataErrorsRequest(args [0]string, argsEscaped // // POST /setStickerPositionInSet func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setStickerPositionInSet"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8681,7 +10853,16 @@ func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8693,8 +10874,27 @@ func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8781,6 +10981,8 @@ func (s *Server) handleSetStickerPositionInSetRequest(args [0]string, argsEscape // // POST /setStickerSetThumb func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setStickerSetThumb"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8802,7 +11004,16 @@ func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8814,8 +11025,27 @@ func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8902,6 +11132,8 @@ func (s *Server) handleSetStickerSetThumbRequest(args [0]string, argsEscaped boo // // POST /setWebhook func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("setWebhook"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8923,7 +11155,16 @@ func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8935,8 +11176,27 @@ func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9023,6 +11283,8 @@ func (s *Server) handleSetWebhookRequest(args [0]string, argsEscaped bool, w htt // // POST /stopMessageLiveLocation func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("stopMessageLiveLocation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9044,7 +11306,16 @@ func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9056,8 +11327,27 @@ func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9144,6 +11434,8 @@ func (s *Server) handleStopMessageLiveLocationRequest(args [0]string, argsEscape // // POST /stopPoll func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("stopPoll"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9165,7 +11457,16 @@ func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9177,8 +11478,27 @@ func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9265,6 +11585,8 @@ func (s *Server) handleStopPollRequest(args [0]string, argsEscaped bool, w http. // // POST /unbanChatMember func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unbanChatMember"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9286,7 +11608,16 @@ func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9298,8 +11629,27 @@ func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9386,6 +11736,8 @@ func (s *Server) handleUnbanChatMemberRequest(args [0]string, argsEscaped bool, // // POST /unbanChatSenderChat func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unbanChatSenderChat"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9407,7 +11759,16 @@ func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9419,8 +11780,27 @@ func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9507,6 +11887,8 @@ func (s *Server) handleUnbanChatSenderChatRequest(args [0]string, argsEscaped bo // // POST /unpinAllChatMessages func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unpinAllChatMessages"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9528,7 +11910,16 @@ func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9540,8 +11931,27 @@ func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9628,6 +12038,8 @@ func (s *Server) handleUnpinAllChatMessagesRequest(args [0]string, argsEscaped b // // POST /unpinChatMessage func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("unpinChatMessage"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9649,7 +12061,16 @@ func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9661,8 +12082,27 @@ func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9749,6 +12189,8 @@ func (s *Server) handleUnpinChatMessageRequest(args [0]string, argsEscaped bool, // // POST /uploadStickerFile func (s *Server) handleUploadStickerFileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("uploadStickerFile"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9770,7 +12212,16 @@ func (s *Server) handleUploadStickerFileRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9782,8 +12233,27 @@ func (s *Server) handleUploadStickerFileRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_test_format/oas_handlers_gen.go b/examples/ex_test_format/oas_handlers_gen.go index 623e86091..55ea3c42a 100644 --- a/examples/ex_test_format/oas_handlers_gen.go +++ b/examples/ex_test_format/oas_handlers_gen.go @@ -25,10 +25,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleTestQueryParameterRequest handles test_query_parameter operation. // // POST /test_query_parameter func (s *Server) handleTestQueryParameterRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_query_parameter"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50,7 +62,16 @@ func (s *Server) handleTestQueryParameterRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62,8 +83,27 @@ func (s *Server) handleTestQueryParameterRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -590,6 +630,8 @@ func (s *Server) handleTestQueryParameterRequest(args [0]string, argsEscaped boo // // POST /test_request_Any func (s *Server) handleTestRequestAnyRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_Any"), semconv.HTTPRequestMethodKey.String("POST"), @@ -611,7 +653,16 @@ func (s *Server) handleTestRequestAnyRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -623,8 +674,27 @@ func (s *Server) handleTestRequestAnyRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -700,6 +770,8 @@ func (s *Server) handleTestRequestAnyRequest(args [0]string, argsEscaped bool, w // // POST /test_request_boolean func (s *Server) handleTestRequestBooleanRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_boolean"), semconv.HTTPRequestMethodKey.String("POST"), @@ -721,7 +793,16 @@ func (s *Server) handleTestRequestBooleanRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -733,8 +814,27 @@ func (s *Server) handleTestRequestBooleanRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -810,6 +910,8 @@ func (s *Server) handleTestRequestBooleanRequest(args [0]string, argsEscaped boo // // POST /test_request_boolean_array func (s *Server) handleTestRequestBooleanArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_boolean_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -831,7 +933,16 @@ func (s *Server) handleTestRequestBooleanArrayRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -843,8 +954,27 @@ func (s *Server) handleTestRequestBooleanArrayRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -920,6 +1050,8 @@ func (s *Server) handleTestRequestBooleanArrayRequest(args [0]string, argsEscape // // POST /test_request_boolean_array_array func (s *Server) handleTestRequestBooleanArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_boolean_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -941,7 +1073,16 @@ func (s *Server) handleTestRequestBooleanArrayArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -953,8 +1094,27 @@ func (s *Server) handleTestRequestBooleanArrayArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1030,6 +1190,8 @@ func (s *Server) handleTestRequestBooleanArrayArrayRequest(args [0]string, argsE // // POST /test_request_boolean_nullable func (s *Server) handleTestRequestBooleanNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_boolean_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1051,7 +1213,16 @@ func (s *Server) handleTestRequestBooleanNullableRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1063,8 +1234,27 @@ func (s *Server) handleTestRequestBooleanNullableRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1140,6 +1330,8 @@ func (s *Server) handleTestRequestBooleanNullableRequest(args [0]string, argsEsc // // POST /test_request_boolean_nullable_array func (s *Server) handleTestRequestBooleanNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_boolean_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1161,7 +1353,16 @@ func (s *Server) handleTestRequestBooleanNullableArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1173,8 +1374,27 @@ func (s *Server) handleTestRequestBooleanNullableArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1250,6 +1470,8 @@ func (s *Server) handleTestRequestBooleanNullableArrayRequest(args [0]string, ar // // POST /test_request_boolean_nullable_array_array func (s *Server) handleTestRequestBooleanNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_boolean_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1271,7 +1493,16 @@ func (s *Server) handleTestRequestBooleanNullableArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1283,8 +1514,27 @@ func (s *Server) handleTestRequestBooleanNullableArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1360,6 +1610,8 @@ func (s *Server) handleTestRequestBooleanNullableArrayArrayRequest(args [0]strin // // POST /test_request_EmptyStruct func (s *Server) handleTestRequestEmptyStructRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_EmptyStruct"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1381,7 +1633,16 @@ func (s *Server) handleTestRequestEmptyStructRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1393,8 +1654,27 @@ func (s *Server) handleTestRequestEmptyStructRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1470,6 +1750,8 @@ func (s *Server) handleTestRequestEmptyStructRequest(args [0]string, argsEscaped // // POST /test_request_FormatTest func (s *Server) handleTestRequestFormatTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_FormatTest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1491,7 +1773,16 @@ func (s *Server) handleTestRequestFormatTestRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1503,8 +1794,27 @@ func (s *Server) handleTestRequestFormatTestRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1580,6 +1890,8 @@ func (s *Server) handleTestRequestFormatTestRequest(args [0]string, argsEscaped // // POST /test_request_integer func (s *Server) handleTestRequestIntegerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1601,7 +1913,16 @@ func (s *Server) handleTestRequestIntegerRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1613,8 +1934,27 @@ func (s *Server) handleTestRequestIntegerRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1690,6 +2030,8 @@ func (s *Server) handleTestRequestIntegerRequest(args [0]string, argsEscaped boo // // POST /test_request_integer_array func (s *Server) handleTestRequestIntegerArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1711,7 +2053,16 @@ func (s *Server) handleTestRequestIntegerArrayRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1723,8 +2074,27 @@ func (s *Server) handleTestRequestIntegerArrayRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1800,6 +2170,8 @@ func (s *Server) handleTestRequestIntegerArrayRequest(args [0]string, argsEscape // // POST /test_request_integer_array_array func (s *Server) handleTestRequestIntegerArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1821,7 +2193,16 @@ func (s *Server) handleTestRequestIntegerArrayArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1833,8 +2214,27 @@ func (s *Server) handleTestRequestIntegerArrayArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1910,6 +2310,8 @@ func (s *Server) handleTestRequestIntegerArrayArrayRequest(args [0]string, argsE // // POST /test_request_integer_int16 func (s *Server) handleTestRequestIntegerInt16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1931,7 +2333,16 @@ func (s *Server) handleTestRequestIntegerInt16Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1943,8 +2354,27 @@ func (s *Server) handleTestRequestIntegerInt16Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2020,6 +2450,8 @@ func (s *Server) handleTestRequestIntegerInt16Request(args [0]string, argsEscape // // POST /test_request_integer_int16_array func (s *Server) handleTestRequestIntegerInt16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2041,7 +2473,16 @@ func (s *Server) handleTestRequestIntegerInt16ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2053,8 +2494,27 @@ func (s *Server) handleTestRequestIntegerInt16ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2130,6 +2590,8 @@ func (s *Server) handleTestRequestIntegerInt16ArrayRequest(args [0]string, argsE // // POST /test_request_integer_int16_array_array func (s *Server) handleTestRequestIntegerInt16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2151,7 +2613,16 @@ func (s *Server) handleTestRequestIntegerInt16ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2163,8 +2634,27 @@ func (s *Server) handleTestRequestIntegerInt16ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2240,6 +2730,8 @@ func (s *Server) handleTestRequestIntegerInt16ArrayArrayRequest(args [0]string, // // POST /test_request_integer_int16_nullable func (s *Server) handleTestRequestIntegerInt16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2261,7 +2753,16 @@ func (s *Server) handleTestRequestIntegerInt16NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2273,8 +2774,27 @@ func (s *Server) handleTestRequestIntegerInt16NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2350,6 +2870,8 @@ func (s *Server) handleTestRequestIntegerInt16NullableRequest(args [0]string, ar // // POST /test_request_integer_int16_nullable_array func (s *Server) handleTestRequestIntegerInt16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2371,7 +2893,16 @@ func (s *Server) handleTestRequestIntegerInt16NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2383,8 +2914,27 @@ func (s *Server) handleTestRequestIntegerInt16NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2460,6 +3010,8 @@ func (s *Server) handleTestRequestIntegerInt16NullableArrayRequest(args [0]strin // // POST /test_request_integer_int16_nullable_array_array func (s *Server) handleTestRequestIntegerInt16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2481,7 +3033,16 @@ func (s *Server) handleTestRequestIntegerInt16NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2493,8 +3054,27 @@ func (s *Server) handleTestRequestIntegerInt16NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2570,6 +3150,8 @@ func (s *Server) handleTestRequestIntegerInt16NullableArrayArrayRequest(args [0] // // POST /test_request_integer_int32 func (s *Server) handleTestRequestIntegerInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2591,7 +3173,16 @@ func (s *Server) handleTestRequestIntegerInt32Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2603,8 +3194,27 @@ func (s *Server) handleTestRequestIntegerInt32Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2680,6 +3290,8 @@ func (s *Server) handleTestRequestIntegerInt32Request(args [0]string, argsEscape // // POST /test_request_integer_int32_array func (s *Server) handleTestRequestIntegerInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2701,7 +3313,16 @@ func (s *Server) handleTestRequestIntegerInt32ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2713,8 +3334,27 @@ func (s *Server) handleTestRequestIntegerInt32ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2790,6 +3430,8 @@ func (s *Server) handleTestRequestIntegerInt32ArrayRequest(args [0]string, argsE // // POST /test_request_integer_int32_array_array func (s *Server) handleTestRequestIntegerInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2811,7 +3453,16 @@ func (s *Server) handleTestRequestIntegerInt32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2823,8 +3474,27 @@ func (s *Server) handleTestRequestIntegerInt32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2900,6 +3570,8 @@ func (s *Server) handleTestRequestIntegerInt32ArrayArrayRequest(args [0]string, // // POST /test_request_integer_int32_nullable func (s *Server) handleTestRequestIntegerInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2921,7 +3593,16 @@ func (s *Server) handleTestRequestIntegerInt32NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2933,8 +3614,27 @@ func (s *Server) handleTestRequestIntegerInt32NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3010,6 +3710,8 @@ func (s *Server) handleTestRequestIntegerInt32NullableRequest(args [0]string, ar // // POST /test_request_integer_int32_nullable_array func (s *Server) handleTestRequestIntegerInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3031,7 +3733,16 @@ func (s *Server) handleTestRequestIntegerInt32NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3043,8 +3754,27 @@ func (s *Server) handleTestRequestIntegerInt32NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3120,6 +3850,8 @@ func (s *Server) handleTestRequestIntegerInt32NullableArrayRequest(args [0]strin // // POST /test_request_integer_int32_nullable_array_array func (s *Server) handleTestRequestIntegerInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3141,7 +3873,16 @@ func (s *Server) handleTestRequestIntegerInt32NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3153,8 +3894,27 @@ func (s *Server) handleTestRequestIntegerInt32NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3230,6 +3990,8 @@ func (s *Server) handleTestRequestIntegerInt32NullableArrayArrayRequest(args [0] // // POST /test_request_integer_int64 func (s *Server) handleTestRequestIntegerInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3251,7 +4013,16 @@ func (s *Server) handleTestRequestIntegerInt64Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3263,8 +4034,27 @@ func (s *Server) handleTestRequestIntegerInt64Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3340,6 +4130,8 @@ func (s *Server) handleTestRequestIntegerInt64Request(args [0]string, argsEscape // // POST /test_request_integer_int64_array func (s *Server) handleTestRequestIntegerInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3361,7 +4153,16 @@ func (s *Server) handleTestRequestIntegerInt64ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3373,8 +4174,27 @@ func (s *Server) handleTestRequestIntegerInt64ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3450,6 +4270,8 @@ func (s *Server) handleTestRequestIntegerInt64ArrayRequest(args [0]string, argsE // // POST /test_request_integer_int64_array_array func (s *Server) handleTestRequestIntegerInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3471,7 +4293,16 @@ func (s *Server) handleTestRequestIntegerInt64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3483,8 +4314,27 @@ func (s *Server) handleTestRequestIntegerInt64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3560,6 +4410,8 @@ func (s *Server) handleTestRequestIntegerInt64ArrayArrayRequest(args [0]string, // // POST /test_request_integer_int64_nullable func (s *Server) handleTestRequestIntegerInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3581,7 +4433,16 @@ func (s *Server) handleTestRequestIntegerInt64NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3593,8 +4454,27 @@ func (s *Server) handleTestRequestIntegerInt64NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3670,6 +4550,8 @@ func (s *Server) handleTestRequestIntegerInt64NullableRequest(args [0]string, ar // // POST /test_request_integer_int64_nullable_array func (s *Server) handleTestRequestIntegerInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3691,7 +4573,16 @@ func (s *Server) handleTestRequestIntegerInt64NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3703,8 +4594,27 @@ func (s *Server) handleTestRequestIntegerInt64NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3780,6 +4690,8 @@ func (s *Server) handleTestRequestIntegerInt64NullableArrayRequest(args [0]strin // // POST /test_request_integer_int64_nullable_array_array func (s *Server) handleTestRequestIntegerInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3801,7 +4713,16 @@ func (s *Server) handleTestRequestIntegerInt64NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3813,8 +4734,27 @@ func (s *Server) handleTestRequestIntegerInt64NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3890,6 +4830,8 @@ func (s *Server) handleTestRequestIntegerInt64NullableArrayArrayRequest(args [0] // // POST /test_request_integer_int8 func (s *Server) handleTestRequestIntegerInt8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -3911,7 +4853,16 @@ func (s *Server) handleTestRequestIntegerInt8Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3923,8 +4874,27 @@ func (s *Server) handleTestRequestIntegerInt8Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4000,6 +4970,8 @@ func (s *Server) handleTestRequestIntegerInt8Request(args [0]string, argsEscaped // // POST /test_request_integer_int8_array func (s *Server) handleTestRequestIntegerInt8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4021,7 +4993,16 @@ func (s *Server) handleTestRequestIntegerInt8ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4033,8 +5014,27 @@ func (s *Server) handleTestRequestIntegerInt8ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4110,6 +5110,8 @@ func (s *Server) handleTestRequestIntegerInt8ArrayRequest(args [0]string, argsEs // // POST /test_request_integer_int8_array_array func (s *Server) handleTestRequestIntegerInt8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4131,7 +5133,16 @@ func (s *Server) handleTestRequestIntegerInt8ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4143,8 +5154,27 @@ func (s *Server) handleTestRequestIntegerInt8ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4220,6 +5250,8 @@ func (s *Server) handleTestRequestIntegerInt8ArrayArrayRequest(args [0]string, a // // POST /test_request_integer_int8_nullable func (s *Server) handleTestRequestIntegerInt8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4241,7 +5273,16 @@ func (s *Server) handleTestRequestIntegerInt8NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4253,8 +5294,27 @@ func (s *Server) handleTestRequestIntegerInt8NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4330,6 +5390,8 @@ func (s *Server) handleTestRequestIntegerInt8NullableRequest(args [0]string, arg // // POST /test_request_integer_int8_nullable_array func (s *Server) handleTestRequestIntegerInt8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4351,7 +5413,16 @@ func (s *Server) handleTestRequestIntegerInt8NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4363,8 +5434,27 @@ func (s *Server) handleTestRequestIntegerInt8NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4440,6 +5530,8 @@ func (s *Server) handleTestRequestIntegerInt8NullableArrayRequest(args [0]string // // POST /test_request_integer_int8_nullable_array_array func (s *Server) handleTestRequestIntegerInt8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_int8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4461,7 +5553,16 @@ func (s *Server) handleTestRequestIntegerInt8NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4473,8 +5574,27 @@ func (s *Server) handleTestRequestIntegerInt8NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4550,6 +5670,8 @@ func (s *Server) handleTestRequestIntegerInt8NullableArrayArrayRequest(args [0]s // // POST /test_request_integer_nullable func (s *Server) handleTestRequestIntegerNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4571,7 +5693,16 @@ func (s *Server) handleTestRequestIntegerNullableRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4583,8 +5714,27 @@ func (s *Server) handleTestRequestIntegerNullableRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4660,6 +5810,8 @@ func (s *Server) handleTestRequestIntegerNullableRequest(args [0]string, argsEsc // // POST /test_request_integer_nullable_array func (s *Server) handleTestRequestIntegerNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4681,7 +5833,16 @@ func (s *Server) handleTestRequestIntegerNullableArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4693,8 +5854,27 @@ func (s *Server) handleTestRequestIntegerNullableArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4770,6 +5950,8 @@ func (s *Server) handleTestRequestIntegerNullableArrayRequest(args [0]string, ar // // POST /test_request_integer_nullable_array_array func (s *Server) handleTestRequestIntegerNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4791,7 +5973,16 @@ func (s *Server) handleTestRequestIntegerNullableArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4803,8 +5994,27 @@ func (s *Server) handleTestRequestIntegerNullableArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4880,6 +6090,8 @@ func (s *Server) handleTestRequestIntegerNullableArrayArrayRequest(args [0]strin // // POST /test_request_integer_uint func (s *Server) handleTestRequestIntegerUintRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4901,7 +6113,16 @@ func (s *Server) handleTestRequestIntegerUintRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -4913,8 +6134,27 @@ func (s *Server) handleTestRequestIntegerUintRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -4990,6 +6230,8 @@ func (s *Server) handleTestRequestIntegerUintRequest(args [0]string, argsEscaped // // POST /test_request_integer_uint16 func (s *Server) handleTestRequestIntegerUint16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5011,7 +6253,16 @@ func (s *Server) handleTestRequestIntegerUint16Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5023,8 +6274,27 @@ func (s *Server) handleTestRequestIntegerUint16Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5100,6 +6370,8 @@ func (s *Server) handleTestRequestIntegerUint16Request(args [0]string, argsEscap // // POST /test_request_integer_uint16_array func (s *Server) handleTestRequestIntegerUint16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5121,7 +6393,16 @@ func (s *Server) handleTestRequestIntegerUint16ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5133,8 +6414,27 @@ func (s *Server) handleTestRequestIntegerUint16ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5210,6 +6510,8 @@ func (s *Server) handleTestRequestIntegerUint16ArrayRequest(args [0]string, args // // POST /test_request_integer_uint16_array_array func (s *Server) handleTestRequestIntegerUint16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5231,7 +6533,16 @@ func (s *Server) handleTestRequestIntegerUint16ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5243,8 +6554,27 @@ func (s *Server) handleTestRequestIntegerUint16ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5320,6 +6650,8 @@ func (s *Server) handleTestRequestIntegerUint16ArrayArrayRequest(args [0]string, // // POST /test_request_integer_uint16_nullable func (s *Server) handleTestRequestIntegerUint16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5341,7 +6673,16 @@ func (s *Server) handleTestRequestIntegerUint16NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5353,8 +6694,27 @@ func (s *Server) handleTestRequestIntegerUint16NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5430,6 +6790,8 @@ func (s *Server) handleTestRequestIntegerUint16NullableRequest(args [0]string, a // // POST /test_request_integer_uint16_nullable_array func (s *Server) handleTestRequestIntegerUint16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5451,7 +6813,16 @@ func (s *Server) handleTestRequestIntegerUint16NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5463,8 +6834,27 @@ func (s *Server) handleTestRequestIntegerUint16NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5540,6 +6930,8 @@ func (s *Server) handleTestRequestIntegerUint16NullableArrayRequest(args [0]stri // // POST /test_request_integer_uint16_nullable_array_array func (s *Server) handleTestRequestIntegerUint16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5561,7 +6953,16 @@ func (s *Server) handleTestRequestIntegerUint16NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5573,8 +6974,27 @@ func (s *Server) handleTestRequestIntegerUint16NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5650,6 +7070,8 @@ func (s *Server) handleTestRequestIntegerUint16NullableArrayArrayRequest(args [0 // // POST /test_request_integer_uint32 func (s *Server) handleTestRequestIntegerUint32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5671,7 +7093,16 @@ func (s *Server) handleTestRequestIntegerUint32Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5683,8 +7114,27 @@ func (s *Server) handleTestRequestIntegerUint32Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5760,6 +7210,8 @@ func (s *Server) handleTestRequestIntegerUint32Request(args [0]string, argsEscap // // POST /test_request_integer_uint32_array func (s *Server) handleTestRequestIntegerUint32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5781,7 +7233,16 @@ func (s *Server) handleTestRequestIntegerUint32ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5793,8 +7254,27 @@ func (s *Server) handleTestRequestIntegerUint32ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5870,6 +7350,8 @@ func (s *Server) handleTestRequestIntegerUint32ArrayRequest(args [0]string, args // // POST /test_request_integer_uint32_array_array func (s *Server) handleTestRequestIntegerUint32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -5891,7 +7373,16 @@ func (s *Server) handleTestRequestIntegerUint32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -5903,8 +7394,27 @@ func (s *Server) handleTestRequestIntegerUint32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -5980,6 +7490,8 @@ func (s *Server) handleTestRequestIntegerUint32ArrayArrayRequest(args [0]string, // // POST /test_request_integer_uint32_nullable func (s *Server) handleTestRequestIntegerUint32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6001,7 +7513,16 @@ func (s *Server) handleTestRequestIntegerUint32NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6013,8 +7534,27 @@ func (s *Server) handleTestRequestIntegerUint32NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6090,6 +7630,8 @@ func (s *Server) handleTestRequestIntegerUint32NullableRequest(args [0]string, a // // POST /test_request_integer_uint32_nullable_array func (s *Server) handleTestRequestIntegerUint32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6111,7 +7653,16 @@ func (s *Server) handleTestRequestIntegerUint32NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6123,8 +7674,27 @@ func (s *Server) handleTestRequestIntegerUint32NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6200,6 +7770,8 @@ func (s *Server) handleTestRequestIntegerUint32NullableArrayRequest(args [0]stri // // POST /test_request_integer_uint32_nullable_array_array func (s *Server) handleTestRequestIntegerUint32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6221,7 +7793,16 @@ func (s *Server) handleTestRequestIntegerUint32NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6233,8 +7814,27 @@ func (s *Server) handleTestRequestIntegerUint32NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6310,6 +7910,8 @@ func (s *Server) handleTestRequestIntegerUint32NullableArrayArrayRequest(args [0 // // POST /test_request_integer_uint64 func (s *Server) handleTestRequestIntegerUint64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6331,7 +7933,16 @@ func (s *Server) handleTestRequestIntegerUint64Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6343,8 +7954,27 @@ func (s *Server) handleTestRequestIntegerUint64Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6420,6 +8050,8 @@ func (s *Server) handleTestRequestIntegerUint64Request(args [0]string, argsEscap // // POST /test_request_integer_uint64_array func (s *Server) handleTestRequestIntegerUint64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6441,7 +8073,16 @@ func (s *Server) handleTestRequestIntegerUint64ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6453,8 +8094,27 @@ func (s *Server) handleTestRequestIntegerUint64ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6530,6 +8190,8 @@ func (s *Server) handleTestRequestIntegerUint64ArrayRequest(args [0]string, args // // POST /test_request_integer_uint64_array_array func (s *Server) handleTestRequestIntegerUint64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6551,7 +8213,16 @@ func (s *Server) handleTestRequestIntegerUint64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6563,8 +8234,27 @@ func (s *Server) handleTestRequestIntegerUint64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6640,6 +8330,8 @@ func (s *Server) handleTestRequestIntegerUint64ArrayArrayRequest(args [0]string, // // POST /test_request_integer_uint64_nullable func (s *Server) handleTestRequestIntegerUint64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6661,7 +8353,16 @@ func (s *Server) handleTestRequestIntegerUint64NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6673,8 +8374,27 @@ func (s *Server) handleTestRequestIntegerUint64NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6750,6 +8470,8 @@ func (s *Server) handleTestRequestIntegerUint64NullableRequest(args [0]string, a // // POST /test_request_integer_uint64_nullable_array func (s *Server) handleTestRequestIntegerUint64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6771,7 +8493,16 @@ func (s *Server) handleTestRequestIntegerUint64NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6783,8 +8514,27 @@ func (s *Server) handleTestRequestIntegerUint64NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6860,6 +8610,8 @@ func (s *Server) handleTestRequestIntegerUint64NullableArrayRequest(args [0]stri // // POST /test_request_integer_uint64_nullable_array_array func (s *Server) handleTestRequestIntegerUint64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6881,7 +8633,16 @@ func (s *Server) handleTestRequestIntegerUint64NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -6893,8 +8654,27 @@ func (s *Server) handleTestRequestIntegerUint64NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -6970,6 +8750,8 @@ func (s *Server) handleTestRequestIntegerUint64NullableArrayArrayRequest(args [0 // // POST /test_request_integer_uint8 func (s *Server) handleTestRequestIntegerUint8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -6991,7 +8773,16 @@ func (s *Server) handleTestRequestIntegerUint8Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7003,8 +8794,27 @@ func (s *Server) handleTestRequestIntegerUint8Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7080,6 +8890,8 @@ func (s *Server) handleTestRequestIntegerUint8Request(args [0]string, argsEscape // // POST /test_request_integer_uint8_array func (s *Server) handleTestRequestIntegerUint8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7101,7 +8913,16 @@ func (s *Server) handleTestRequestIntegerUint8ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7113,8 +8934,27 @@ func (s *Server) handleTestRequestIntegerUint8ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7190,6 +9030,8 @@ func (s *Server) handleTestRequestIntegerUint8ArrayRequest(args [0]string, argsE // // POST /test_request_integer_uint8_array_array func (s *Server) handleTestRequestIntegerUint8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7211,7 +9053,16 @@ func (s *Server) handleTestRequestIntegerUint8ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7223,8 +9074,27 @@ func (s *Server) handleTestRequestIntegerUint8ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7300,6 +9170,8 @@ func (s *Server) handleTestRequestIntegerUint8ArrayArrayRequest(args [0]string, // // POST /test_request_integer_uint8_nullable func (s *Server) handleTestRequestIntegerUint8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7321,7 +9193,16 @@ func (s *Server) handleTestRequestIntegerUint8NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7333,8 +9214,27 @@ func (s *Server) handleTestRequestIntegerUint8NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7410,6 +9310,8 @@ func (s *Server) handleTestRequestIntegerUint8NullableRequest(args [0]string, ar // // POST /test_request_integer_uint8_nullable_array func (s *Server) handleTestRequestIntegerUint8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7431,7 +9333,16 @@ func (s *Server) handleTestRequestIntegerUint8NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7443,8 +9354,27 @@ func (s *Server) handleTestRequestIntegerUint8NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7520,6 +9450,8 @@ func (s *Server) handleTestRequestIntegerUint8NullableArrayRequest(args [0]strin // // POST /test_request_integer_uint8_nullable_array_array func (s *Server) handleTestRequestIntegerUint8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7541,7 +9473,16 @@ func (s *Server) handleTestRequestIntegerUint8NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7553,8 +9494,27 @@ func (s *Server) handleTestRequestIntegerUint8NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7630,6 +9590,8 @@ func (s *Server) handleTestRequestIntegerUint8NullableArrayArrayRequest(args [0] // // POST /test_request_integer_uint_array func (s *Server) handleTestRequestIntegerUintArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7651,7 +9613,16 @@ func (s *Server) handleTestRequestIntegerUintArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7663,8 +9634,27 @@ func (s *Server) handleTestRequestIntegerUintArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7740,6 +9730,8 @@ func (s *Server) handleTestRequestIntegerUintArrayRequest(args [0]string, argsEs // // POST /test_request_integer_uint_array_array func (s *Server) handleTestRequestIntegerUintArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7761,7 +9753,16 @@ func (s *Server) handleTestRequestIntegerUintArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7773,8 +9774,27 @@ func (s *Server) handleTestRequestIntegerUintArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7850,6 +9870,8 @@ func (s *Server) handleTestRequestIntegerUintArrayArrayRequest(args [0]string, a // // POST /test_request_integer_uint_nullable func (s *Server) handleTestRequestIntegerUintNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7871,7 +9893,16 @@ func (s *Server) handleTestRequestIntegerUintNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7883,8 +9914,27 @@ func (s *Server) handleTestRequestIntegerUintNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -7960,6 +10010,8 @@ func (s *Server) handleTestRequestIntegerUintNullableRequest(args [0]string, arg // // POST /test_request_integer_uint_nullable_array func (s *Server) handleTestRequestIntegerUintNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -7981,7 +10033,16 @@ func (s *Server) handleTestRequestIntegerUintNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -7993,8 +10054,27 @@ func (s *Server) handleTestRequestIntegerUintNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8070,6 +10150,8 @@ func (s *Server) handleTestRequestIntegerUintNullableArrayRequest(args [0]string // // POST /test_request_integer_uint_nullable_array_array func (s *Server) handleTestRequestIntegerUintNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_uint_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8091,7 +10173,16 @@ func (s *Server) handleTestRequestIntegerUintNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8103,8 +10194,27 @@ func (s *Server) handleTestRequestIntegerUintNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8180,6 +10290,8 @@ func (s *Server) handleTestRequestIntegerUintNullableArrayArrayRequest(args [0]s // // POST /test_request_integer_unix func (s *Server) handleTestRequestIntegerUnixRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8201,7 +10313,16 @@ func (s *Server) handleTestRequestIntegerUnixRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8213,8 +10334,27 @@ func (s *Server) handleTestRequestIntegerUnixRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8290,6 +10430,8 @@ func (s *Server) handleTestRequestIntegerUnixRequest(args [0]string, argsEscaped // // POST /test_request_integer_unix_array func (s *Server) handleTestRequestIntegerUnixArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8311,7 +10453,16 @@ func (s *Server) handleTestRequestIntegerUnixArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8323,8 +10474,27 @@ func (s *Server) handleTestRequestIntegerUnixArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8400,6 +10570,8 @@ func (s *Server) handleTestRequestIntegerUnixArrayRequest(args [0]string, argsEs // // POST /test_request_integer_unix_array_array func (s *Server) handleTestRequestIntegerUnixArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8421,7 +10593,16 @@ func (s *Server) handleTestRequestIntegerUnixArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8433,8 +10614,27 @@ func (s *Server) handleTestRequestIntegerUnixArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8510,6 +10710,8 @@ func (s *Server) handleTestRequestIntegerUnixArrayArrayRequest(args [0]string, a // // POST /test_request_integer_unix-micro func (s *Server) handleTestRequestIntegerUnixMicroRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-micro"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8531,7 +10733,16 @@ func (s *Server) handleTestRequestIntegerUnixMicroRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8543,8 +10754,27 @@ func (s *Server) handleTestRequestIntegerUnixMicroRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8620,6 +10850,8 @@ func (s *Server) handleTestRequestIntegerUnixMicroRequest(args [0]string, argsEs // // POST /test_request_integer_unix-micro_array func (s *Server) handleTestRequestIntegerUnixMicroArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-micro_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8641,7 +10873,16 @@ func (s *Server) handleTestRequestIntegerUnixMicroArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8653,8 +10894,27 @@ func (s *Server) handleTestRequestIntegerUnixMicroArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8730,6 +10990,8 @@ func (s *Server) handleTestRequestIntegerUnixMicroArrayRequest(args [0]string, a // // POST /test_request_integer_unix-micro_array_array func (s *Server) handleTestRequestIntegerUnixMicroArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-micro_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8751,7 +11013,16 @@ func (s *Server) handleTestRequestIntegerUnixMicroArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8763,8 +11034,27 @@ func (s *Server) handleTestRequestIntegerUnixMicroArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8840,6 +11130,8 @@ func (s *Server) handleTestRequestIntegerUnixMicroArrayArrayRequest(args [0]stri // // POST /test_request_integer_unix-micro_nullable func (s *Server) handleTestRequestIntegerUnixMicroNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-micro_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8861,7 +11153,16 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8873,8 +11174,27 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -8950,6 +11270,8 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableRequest(args [0]string // // POST /test_request_integer_unix-micro_nullable_array func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-micro_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -8971,7 +11293,16 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -8983,8 +11314,27 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9060,6 +11410,8 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayRequest(args [0]s // // POST /test_request_integer_unix-micro_nullable_array_array func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-micro_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9081,7 +11433,16 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9093,8 +11454,27 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9170,6 +11550,8 @@ func (s *Server) handleTestRequestIntegerUnixMicroNullableArrayArrayRequest(args // // POST /test_request_integer_unix-milli func (s *Server) handleTestRequestIntegerUnixMilliRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-milli"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9191,7 +11573,16 @@ func (s *Server) handleTestRequestIntegerUnixMilliRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9203,8 +11594,27 @@ func (s *Server) handleTestRequestIntegerUnixMilliRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9280,6 +11690,8 @@ func (s *Server) handleTestRequestIntegerUnixMilliRequest(args [0]string, argsEs // // POST /test_request_integer_unix-milli_array func (s *Server) handleTestRequestIntegerUnixMilliArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-milli_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9301,7 +11713,16 @@ func (s *Server) handleTestRequestIntegerUnixMilliArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9313,8 +11734,27 @@ func (s *Server) handleTestRequestIntegerUnixMilliArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9390,6 +11830,8 @@ func (s *Server) handleTestRequestIntegerUnixMilliArrayRequest(args [0]string, a // // POST /test_request_integer_unix-milli_array_array func (s *Server) handleTestRequestIntegerUnixMilliArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-milli_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9411,7 +11853,16 @@ func (s *Server) handleTestRequestIntegerUnixMilliArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9423,8 +11874,27 @@ func (s *Server) handleTestRequestIntegerUnixMilliArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9500,6 +11970,8 @@ func (s *Server) handleTestRequestIntegerUnixMilliArrayArrayRequest(args [0]stri // // POST /test_request_integer_unix-milli_nullable func (s *Server) handleTestRequestIntegerUnixMilliNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-milli_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9521,7 +11993,16 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9533,8 +12014,27 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9610,6 +12110,8 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableRequest(args [0]string // // POST /test_request_integer_unix-milli_nullable_array func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-milli_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9631,7 +12133,16 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9643,8 +12154,27 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9720,6 +12250,8 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayRequest(args [0]s // // POST /test_request_integer_unix-milli_nullable_array_array func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-milli_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9741,7 +12273,16 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9753,8 +12294,27 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9830,6 +12390,8 @@ func (s *Server) handleTestRequestIntegerUnixMilliNullableArrayArrayRequest(args // // POST /test_request_integer_unix-nano func (s *Server) handleTestRequestIntegerUnixNanoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-nano"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9851,7 +12413,16 @@ func (s *Server) handleTestRequestIntegerUnixNanoRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9863,8 +12434,27 @@ func (s *Server) handleTestRequestIntegerUnixNanoRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -9940,6 +12530,8 @@ func (s *Server) handleTestRequestIntegerUnixNanoRequest(args [0]string, argsEsc // // POST /test_request_integer_unix-nano_array func (s *Server) handleTestRequestIntegerUnixNanoArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-nano_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -9961,7 +12553,16 @@ func (s *Server) handleTestRequestIntegerUnixNanoArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -9973,8 +12574,27 @@ func (s *Server) handleTestRequestIntegerUnixNanoArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10050,6 +12670,8 @@ func (s *Server) handleTestRequestIntegerUnixNanoArrayRequest(args [0]string, ar // // POST /test_request_integer_unix-nano_array_array func (s *Server) handleTestRequestIntegerUnixNanoArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-nano_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10071,7 +12693,16 @@ func (s *Server) handleTestRequestIntegerUnixNanoArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10083,8 +12714,27 @@ func (s *Server) handleTestRequestIntegerUnixNanoArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10160,6 +12810,8 @@ func (s *Server) handleTestRequestIntegerUnixNanoArrayArrayRequest(args [0]strin // // POST /test_request_integer_unix-nano_nullable func (s *Server) handleTestRequestIntegerUnixNanoNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-nano_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10181,7 +12833,16 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10193,8 +12854,27 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10270,6 +12950,8 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableRequest(args [0]string, // // POST /test_request_integer_unix-nano_nullable_array func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-nano_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10291,7 +12973,16 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10303,8 +12994,27 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10380,6 +13090,8 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayRequest(args [0]st // // POST /test_request_integer_unix-nano_nullable_array_array func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-nano_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10401,7 +13113,16 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10413,8 +13134,27 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10490,6 +13230,8 @@ func (s *Server) handleTestRequestIntegerUnixNanoNullableArrayArrayRequest(args // // POST /test_request_integer_unix_nullable func (s *Server) handleTestRequestIntegerUnixNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10511,7 +13253,16 @@ func (s *Server) handleTestRequestIntegerUnixNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10523,8 +13274,27 @@ func (s *Server) handleTestRequestIntegerUnixNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10600,6 +13370,8 @@ func (s *Server) handleTestRequestIntegerUnixNullableRequest(args [0]string, arg // // POST /test_request_integer_unix_nullable_array func (s *Server) handleTestRequestIntegerUnixNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10621,7 +13393,16 @@ func (s *Server) handleTestRequestIntegerUnixNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10633,8 +13414,27 @@ func (s *Server) handleTestRequestIntegerUnixNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10710,6 +13510,8 @@ func (s *Server) handleTestRequestIntegerUnixNullableArrayRequest(args [0]string // // POST /test_request_integer_unix_nullable_array_array func (s *Server) handleTestRequestIntegerUnixNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10731,7 +13533,16 @@ func (s *Server) handleTestRequestIntegerUnixNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10743,8 +13554,27 @@ func (s *Server) handleTestRequestIntegerUnixNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10820,6 +13650,8 @@ func (s *Server) handleTestRequestIntegerUnixNullableArrayArrayRequest(args [0]s // // POST /test_request_integer_unix-seconds func (s *Server) handleTestRequestIntegerUnixSecondsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-seconds"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10841,7 +13673,16 @@ func (s *Server) handleTestRequestIntegerUnixSecondsRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10853,8 +13694,27 @@ func (s *Server) handleTestRequestIntegerUnixSecondsRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -10930,6 +13790,8 @@ func (s *Server) handleTestRequestIntegerUnixSecondsRequest(args [0]string, args // // POST /test_request_integer_unix-seconds_array func (s *Server) handleTestRequestIntegerUnixSecondsArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-seconds_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -10951,7 +13813,16 @@ func (s *Server) handleTestRequestIntegerUnixSecondsArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -10963,8 +13834,27 @@ func (s *Server) handleTestRequestIntegerUnixSecondsArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11040,6 +13930,8 @@ func (s *Server) handleTestRequestIntegerUnixSecondsArrayRequest(args [0]string, // // POST /test_request_integer_unix-seconds_array_array func (s *Server) handleTestRequestIntegerUnixSecondsArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-seconds_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11061,7 +13953,16 @@ func (s *Server) handleTestRequestIntegerUnixSecondsArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11073,8 +13974,27 @@ func (s *Server) handleTestRequestIntegerUnixSecondsArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11150,6 +14070,8 @@ func (s *Server) handleTestRequestIntegerUnixSecondsArrayArrayRequest(args [0]st // // POST /test_request_integer_unix-seconds_nullable func (s *Server) handleTestRequestIntegerUnixSecondsNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-seconds_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11171,7 +14093,16 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11183,8 +14114,27 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11260,6 +14210,8 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableRequest(args [0]stri // // POST /test_request_integer_unix-seconds_nullable_array func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-seconds_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11281,7 +14233,16 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11293,8 +14254,27 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11370,6 +14350,8 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayRequest(args [0 // // POST /test_request_integer_unix-seconds_nullable_array_array func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_integer_unix-seconds_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11391,7 +14373,16 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11403,8 +14394,27 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11480,6 +14490,8 @@ func (s *Server) handleTestRequestIntegerUnixSecondsNullableArrayArrayRequest(ar // // POST /test_request_null func (s *Server) handleTestRequestNullRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_null"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11501,7 +14513,16 @@ func (s *Server) handleTestRequestNullRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11513,8 +14534,27 @@ func (s *Server) handleTestRequestNullRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11590,6 +14630,8 @@ func (s *Server) handleTestRequestNullRequest(args [0]string, argsEscaped bool, // // POST /test_request_null_array func (s *Server) handleTestRequestNullArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_null_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11611,7 +14653,16 @@ func (s *Server) handleTestRequestNullArrayRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11623,8 +14674,27 @@ func (s *Server) handleTestRequestNullArrayRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11700,6 +14770,8 @@ func (s *Server) handleTestRequestNullArrayRequest(args [0]string, argsEscaped b // // POST /test_request_null_array_array func (s *Server) handleTestRequestNullArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_null_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11721,7 +14793,16 @@ func (s *Server) handleTestRequestNullArrayArrayRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11733,8 +14814,27 @@ func (s *Server) handleTestRequestNullArrayArrayRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11810,6 +14910,8 @@ func (s *Server) handleTestRequestNullArrayArrayRequest(args [0]string, argsEsca // // POST /test_request_null_nullable func (s *Server) handleTestRequestNullNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_null_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11831,7 +14933,16 @@ func (s *Server) handleTestRequestNullNullableRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11843,8 +14954,27 @@ func (s *Server) handleTestRequestNullNullableRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -11920,6 +15050,8 @@ func (s *Server) handleTestRequestNullNullableRequest(args [0]string, argsEscape // // POST /test_request_null_nullable_array func (s *Server) handleTestRequestNullNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_null_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -11941,7 +15073,16 @@ func (s *Server) handleTestRequestNullNullableArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -11953,8 +15094,27 @@ func (s *Server) handleTestRequestNullNullableArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12030,6 +15190,8 @@ func (s *Server) handleTestRequestNullNullableArrayRequest(args [0]string, argsE // // POST /test_request_null_nullable_array_array func (s *Server) handleTestRequestNullNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_null_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12051,7 +15213,16 @@ func (s *Server) handleTestRequestNullNullableArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12063,8 +15234,27 @@ func (s *Server) handleTestRequestNullNullableArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12140,6 +15330,8 @@ func (s *Server) handleTestRequestNullNullableArrayArrayRequest(args [0]string, // // POST /test_request_number func (s *Server) handleTestRequestNumberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12161,7 +15353,16 @@ func (s *Server) handleTestRequestNumberRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12173,8 +15374,27 @@ func (s *Server) handleTestRequestNumberRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12250,6 +15470,8 @@ func (s *Server) handleTestRequestNumberRequest(args [0]string, argsEscaped bool // // POST /test_request_number_array func (s *Server) handleTestRequestNumberArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12271,7 +15493,16 @@ func (s *Server) handleTestRequestNumberArrayRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12283,8 +15514,27 @@ func (s *Server) handleTestRequestNumberArrayRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12360,6 +15610,8 @@ func (s *Server) handleTestRequestNumberArrayRequest(args [0]string, argsEscaped // // POST /test_request_number_array_array func (s *Server) handleTestRequestNumberArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12381,7 +15633,16 @@ func (s *Server) handleTestRequestNumberArrayArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12393,8 +15654,27 @@ func (s *Server) handleTestRequestNumberArrayArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12470,6 +15750,8 @@ func (s *Server) handleTestRequestNumberArrayArrayRequest(args [0]string, argsEs // // POST /test_request_number_double func (s *Server) handleTestRequestNumberDoubleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_double"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12491,7 +15773,16 @@ func (s *Server) handleTestRequestNumberDoubleRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12503,8 +15794,27 @@ func (s *Server) handleTestRequestNumberDoubleRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12580,6 +15890,8 @@ func (s *Server) handleTestRequestNumberDoubleRequest(args [0]string, argsEscape // // POST /test_request_number_double_array func (s *Server) handleTestRequestNumberDoubleArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_double_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12601,7 +15913,16 @@ func (s *Server) handleTestRequestNumberDoubleArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12613,8 +15934,27 @@ func (s *Server) handleTestRequestNumberDoubleArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12690,6 +16030,8 @@ func (s *Server) handleTestRequestNumberDoubleArrayRequest(args [0]string, argsE // // POST /test_request_number_double_array_array func (s *Server) handleTestRequestNumberDoubleArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_double_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12711,7 +16053,16 @@ func (s *Server) handleTestRequestNumberDoubleArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12723,8 +16074,27 @@ func (s *Server) handleTestRequestNumberDoubleArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12800,6 +16170,8 @@ func (s *Server) handleTestRequestNumberDoubleArrayArrayRequest(args [0]string, // // POST /test_request_number_double_nullable func (s *Server) handleTestRequestNumberDoubleNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_double_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12821,7 +16193,16 @@ func (s *Server) handleTestRequestNumberDoubleNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12833,8 +16214,27 @@ func (s *Server) handleTestRequestNumberDoubleNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -12910,6 +16310,8 @@ func (s *Server) handleTestRequestNumberDoubleNullableRequest(args [0]string, ar // // POST /test_request_number_double_nullable_array func (s *Server) handleTestRequestNumberDoubleNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_double_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -12931,7 +16333,16 @@ func (s *Server) handleTestRequestNumberDoubleNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -12943,8 +16354,27 @@ func (s *Server) handleTestRequestNumberDoubleNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13020,6 +16450,8 @@ func (s *Server) handleTestRequestNumberDoubleNullableArrayRequest(args [0]strin // // POST /test_request_number_double_nullable_array_array func (s *Server) handleTestRequestNumberDoubleNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_double_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13041,7 +16473,16 @@ func (s *Server) handleTestRequestNumberDoubleNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13053,8 +16494,27 @@ func (s *Server) handleTestRequestNumberDoubleNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13130,6 +16590,8 @@ func (s *Server) handleTestRequestNumberDoubleNullableArrayArrayRequest(args [0] // // POST /test_request_number_float func (s *Server) handleTestRequestNumberFloatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_float"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13151,7 +16613,16 @@ func (s *Server) handleTestRequestNumberFloatRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13163,8 +16634,27 @@ func (s *Server) handleTestRequestNumberFloatRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13240,6 +16730,8 @@ func (s *Server) handleTestRequestNumberFloatRequest(args [0]string, argsEscaped // // POST /test_request_number_float_array func (s *Server) handleTestRequestNumberFloatArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_float_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13261,7 +16753,16 @@ func (s *Server) handleTestRequestNumberFloatArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13273,8 +16774,27 @@ func (s *Server) handleTestRequestNumberFloatArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13350,6 +16870,8 @@ func (s *Server) handleTestRequestNumberFloatArrayRequest(args [0]string, argsEs // // POST /test_request_number_float_array_array func (s *Server) handleTestRequestNumberFloatArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_float_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13371,7 +16893,16 @@ func (s *Server) handleTestRequestNumberFloatArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13383,8 +16914,27 @@ func (s *Server) handleTestRequestNumberFloatArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13460,6 +17010,8 @@ func (s *Server) handleTestRequestNumberFloatArrayArrayRequest(args [0]string, a // // POST /test_request_number_float_nullable func (s *Server) handleTestRequestNumberFloatNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_float_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13481,7 +17033,16 @@ func (s *Server) handleTestRequestNumberFloatNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13493,8 +17054,27 @@ func (s *Server) handleTestRequestNumberFloatNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13570,6 +17150,8 @@ func (s *Server) handleTestRequestNumberFloatNullableRequest(args [0]string, arg // // POST /test_request_number_float_nullable_array func (s *Server) handleTestRequestNumberFloatNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_float_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13591,7 +17173,16 @@ func (s *Server) handleTestRequestNumberFloatNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13603,8 +17194,27 @@ func (s *Server) handleTestRequestNumberFloatNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13680,6 +17290,8 @@ func (s *Server) handleTestRequestNumberFloatNullableArrayRequest(args [0]string // // POST /test_request_number_float_nullable_array_array func (s *Server) handleTestRequestNumberFloatNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_float_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13701,7 +17313,16 @@ func (s *Server) handleTestRequestNumberFloatNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13713,8 +17334,27 @@ func (s *Server) handleTestRequestNumberFloatNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13790,6 +17430,8 @@ func (s *Server) handleTestRequestNumberFloatNullableArrayArrayRequest(args [0]s // // POST /test_request_number_int32 func (s *Server) handleTestRequestNumberInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13811,7 +17453,16 @@ func (s *Server) handleTestRequestNumberInt32Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13823,8 +17474,27 @@ func (s *Server) handleTestRequestNumberInt32Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -13900,6 +17570,8 @@ func (s *Server) handleTestRequestNumberInt32Request(args [0]string, argsEscaped // // POST /test_request_number_int32_array func (s *Server) handleTestRequestNumberInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -13921,7 +17593,16 @@ func (s *Server) handleTestRequestNumberInt32ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -13933,8 +17614,27 @@ func (s *Server) handleTestRequestNumberInt32ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14010,6 +17710,8 @@ func (s *Server) handleTestRequestNumberInt32ArrayRequest(args [0]string, argsEs // // POST /test_request_number_int32_array_array func (s *Server) handleTestRequestNumberInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14031,7 +17733,16 @@ func (s *Server) handleTestRequestNumberInt32ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14043,8 +17754,27 @@ func (s *Server) handleTestRequestNumberInt32ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14120,6 +17850,8 @@ func (s *Server) handleTestRequestNumberInt32ArrayArrayRequest(args [0]string, a // // POST /test_request_number_int32_nullable func (s *Server) handleTestRequestNumberInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14141,7 +17873,16 @@ func (s *Server) handleTestRequestNumberInt32NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14153,8 +17894,27 @@ func (s *Server) handleTestRequestNumberInt32NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14230,6 +17990,8 @@ func (s *Server) handleTestRequestNumberInt32NullableRequest(args [0]string, arg // // POST /test_request_number_int32_nullable_array func (s *Server) handleTestRequestNumberInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14251,7 +18013,16 @@ func (s *Server) handleTestRequestNumberInt32NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14263,8 +18034,27 @@ func (s *Server) handleTestRequestNumberInt32NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14340,6 +18130,8 @@ func (s *Server) handleTestRequestNumberInt32NullableArrayRequest(args [0]string // // POST /test_request_number_int32_nullable_array_array func (s *Server) handleTestRequestNumberInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14361,7 +18153,16 @@ func (s *Server) handleTestRequestNumberInt32NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14373,8 +18174,27 @@ func (s *Server) handleTestRequestNumberInt32NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14450,6 +18270,8 @@ func (s *Server) handleTestRequestNumberInt32NullableArrayArrayRequest(args [0]s // // POST /test_request_number_int64 func (s *Server) handleTestRequestNumberInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14471,7 +18293,16 @@ func (s *Server) handleTestRequestNumberInt64Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14483,8 +18314,27 @@ func (s *Server) handleTestRequestNumberInt64Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14560,6 +18410,8 @@ func (s *Server) handleTestRequestNumberInt64Request(args [0]string, argsEscaped // // POST /test_request_number_int64_array func (s *Server) handleTestRequestNumberInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14581,7 +18433,16 @@ func (s *Server) handleTestRequestNumberInt64ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14593,8 +18454,27 @@ func (s *Server) handleTestRequestNumberInt64ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14670,6 +18550,8 @@ func (s *Server) handleTestRequestNumberInt64ArrayRequest(args [0]string, argsEs // // POST /test_request_number_int64_array_array func (s *Server) handleTestRequestNumberInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14691,7 +18573,16 @@ func (s *Server) handleTestRequestNumberInt64ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14703,8 +18594,27 @@ func (s *Server) handleTestRequestNumberInt64ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14780,6 +18690,8 @@ func (s *Server) handleTestRequestNumberInt64ArrayArrayRequest(args [0]string, a // // POST /test_request_number_int64_nullable func (s *Server) handleTestRequestNumberInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14801,7 +18713,16 @@ func (s *Server) handleTestRequestNumberInt64NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14813,8 +18734,27 @@ func (s *Server) handleTestRequestNumberInt64NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -14890,6 +18830,8 @@ func (s *Server) handleTestRequestNumberInt64NullableRequest(args [0]string, arg // // POST /test_request_number_int64_nullable_array func (s *Server) handleTestRequestNumberInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -14911,7 +18853,16 @@ func (s *Server) handleTestRequestNumberInt64NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -14923,8 +18874,27 @@ func (s *Server) handleTestRequestNumberInt64NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15000,6 +18970,8 @@ func (s *Server) handleTestRequestNumberInt64NullableArrayRequest(args [0]string // // POST /test_request_number_int64_nullable_array_array func (s *Server) handleTestRequestNumberInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15021,7 +18993,16 @@ func (s *Server) handleTestRequestNumberInt64NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15033,8 +19014,27 @@ func (s *Server) handleTestRequestNumberInt64NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15110,6 +19110,8 @@ func (s *Server) handleTestRequestNumberInt64NullableArrayArrayRequest(args [0]s // // POST /test_request_number_nullable func (s *Server) handleTestRequestNumberNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15131,7 +19133,16 @@ func (s *Server) handleTestRequestNumberNullableRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15143,8 +19154,27 @@ func (s *Server) handleTestRequestNumberNullableRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15220,6 +19250,8 @@ func (s *Server) handleTestRequestNumberNullableRequest(args [0]string, argsEsca // // POST /test_request_number_nullable_array func (s *Server) handleTestRequestNumberNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15241,7 +19273,16 @@ func (s *Server) handleTestRequestNumberNullableArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15253,8 +19294,27 @@ func (s *Server) handleTestRequestNumberNullableArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15330,6 +19390,8 @@ func (s *Server) handleTestRequestNumberNullableArrayRequest(args [0]string, arg // // POST /test_request_number_nullable_array_array func (s *Server) handleTestRequestNumberNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_number_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15351,7 +19413,16 @@ func (s *Server) handleTestRequestNumberNullableArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15363,8 +19434,27 @@ func (s *Server) handleTestRequestNumberNullableArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15440,6 +19530,8 @@ func (s *Server) handleTestRequestNumberNullableArrayArrayRequest(args [0]string // // POST /test_request_required_Any func (s *Server) handleTestRequestRequiredAnyRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_Any"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15461,7 +19553,16 @@ func (s *Server) handleTestRequestRequiredAnyRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15473,8 +19574,27 @@ func (s *Server) handleTestRequestRequiredAnyRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15550,6 +19670,8 @@ func (s *Server) handleTestRequestRequiredAnyRequest(args [0]string, argsEscaped // // POST /test_request_required_boolean func (s *Server) handleTestRequestRequiredBooleanRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_boolean"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15571,7 +19693,16 @@ func (s *Server) handleTestRequestRequiredBooleanRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15583,8 +19714,27 @@ func (s *Server) handleTestRequestRequiredBooleanRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15660,6 +19810,8 @@ func (s *Server) handleTestRequestRequiredBooleanRequest(args [0]string, argsEsc // // POST /test_request_required_boolean_array func (s *Server) handleTestRequestRequiredBooleanArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_boolean_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15681,7 +19833,16 @@ func (s *Server) handleTestRequestRequiredBooleanArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15693,8 +19854,27 @@ func (s *Server) handleTestRequestRequiredBooleanArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15770,6 +19950,8 @@ func (s *Server) handleTestRequestRequiredBooleanArrayRequest(args [0]string, ar // // POST /test_request_required_boolean_array_array func (s *Server) handleTestRequestRequiredBooleanArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_boolean_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15791,7 +19973,16 @@ func (s *Server) handleTestRequestRequiredBooleanArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15803,8 +19994,27 @@ func (s *Server) handleTestRequestRequiredBooleanArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15880,6 +20090,8 @@ func (s *Server) handleTestRequestRequiredBooleanArrayArrayRequest(args [0]strin // // POST /test_request_required_boolean_nullable func (s *Server) handleTestRequestRequiredBooleanNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_boolean_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -15901,7 +20113,16 @@ func (s *Server) handleTestRequestRequiredBooleanNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -15913,8 +20134,27 @@ func (s *Server) handleTestRequestRequiredBooleanNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -15990,6 +20230,8 @@ func (s *Server) handleTestRequestRequiredBooleanNullableRequest(args [0]string, // // POST /test_request_required_boolean_nullable_array func (s *Server) handleTestRequestRequiredBooleanNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_boolean_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16011,7 +20253,16 @@ func (s *Server) handleTestRequestRequiredBooleanNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16023,8 +20274,27 @@ func (s *Server) handleTestRequestRequiredBooleanNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16100,6 +20370,8 @@ func (s *Server) handleTestRequestRequiredBooleanNullableArrayRequest(args [0]st // // POST /test_request_required_boolean_nullable_array_array func (s *Server) handleTestRequestRequiredBooleanNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_boolean_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16121,7 +20393,16 @@ func (s *Server) handleTestRequestRequiredBooleanNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16133,8 +20414,27 @@ func (s *Server) handleTestRequestRequiredBooleanNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16210,6 +20510,8 @@ func (s *Server) handleTestRequestRequiredBooleanNullableArrayArrayRequest(args // // POST /test_request_required_EmptyStruct func (s *Server) handleTestRequestRequiredEmptyStructRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_EmptyStruct"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16231,7 +20533,16 @@ func (s *Server) handleTestRequestRequiredEmptyStructRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16243,8 +20554,27 @@ func (s *Server) handleTestRequestRequiredEmptyStructRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16320,6 +20650,8 @@ func (s *Server) handleTestRequestRequiredEmptyStructRequest(args [0]string, arg // // POST /test_request_required_FormatTest func (s *Server) handleTestRequestRequiredFormatTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_FormatTest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16341,7 +20673,16 @@ func (s *Server) handleTestRequestRequiredFormatTestRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16353,8 +20694,27 @@ func (s *Server) handleTestRequestRequiredFormatTestRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16430,6 +20790,8 @@ func (s *Server) handleTestRequestRequiredFormatTestRequest(args [0]string, args // // POST /test_request_required_integer func (s *Server) handleTestRequestRequiredIntegerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16451,7 +20813,16 @@ func (s *Server) handleTestRequestRequiredIntegerRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16463,8 +20834,27 @@ func (s *Server) handleTestRequestRequiredIntegerRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16540,6 +20930,8 @@ func (s *Server) handleTestRequestRequiredIntegerRequest(args [0]string, argsEsc // // POST /test_request_required_integer_array func (s *Server) handleTestRequestRequiredIntegerArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16561,7 +20953,16 @@ func (s *Server) handleTestRequestRequiredIntegerArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16573,8 +20974,27 @@ func (s *Server) handleTestRequestRequiredIntegerArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16650,6 +21070,8 @@ func (s *Server) handleTestRequestRequiredIntegerArrayRequest(args [0]string, ar // // POST /test_request_required_integer_array_array func (s *Server) handleTestRequestRequiredIntegerArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16671,7 +21093,16 @@ func (s *Server) handleTestRequestRequiredIntegerArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16683,8 +21114,27 @@ func (s *Server) handleTestRequestRequiredIntegerArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16760,6 +21210,8 @@ func (s *Server) handleTestRequestRequiredIntegerArrayArrayRequest(args [0]strin // // POST /test_request_required_integer_int16 func (s *Server) handleTestRequestRequiredIntegerInt16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16781,7 +21233,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt16Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16793,8 +21254,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt16Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16870,6 +21350,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt16Request(args [0]string, ar // // POST /test_request_required_integer_int16_array func (s *Server) handleTestRequestRequiredIntegerInt16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -16891,7 +21373,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt16ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -16903,8 +21394,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt16ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -16980,6 +21490,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt16ArrayRequest(args [0]strin // // POST /test_request_required_integer_int16_array_array func (s *Server) handleTestRequestRequiredIntegerInt16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17001,7 +21513,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt16ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17013,8 +21534,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt16ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17090,6 +21630,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt16ArrayArrayRequest(args [0] // // POST /test_request_required_integer_int16_nullable func (s *Server) handleTestRequestRequiredIntegerInt16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17111,7 +21653,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17123,8 +21674,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17200,6 +21770,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableRequest(args [0]st // // POST /test_request_required_integer_int16_nullable_array func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17221,7 +21793,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17233,8 +21814,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17310,6 +21910,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayRequest(args // // POST /test_request_required_integer_int16_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17331,7 +21933,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17343,8 +21954,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17420,6 +22050,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt16NullableArrayArrayRequest( // // POST /test_request_required_integer_int32 func (s *Server) handleTestRequestRequiredIntegerInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17441,7 +22073,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt32Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17453,8 +22094,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt32Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17530,6 +22190,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt32Request(args [0]string, ar // // POST /test_request_required_integer_int32_array func (s *Server) handleTestRequestRequiredIntegerInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17551,7 +22213,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt32ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17563,8 +22234,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt32ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17640,6 +22330,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt32ArrayRequest(args [0]strin // // POST /test_request_required_integer_int32_array_array func (s *Server) handleTestRequestRequiredIntegerInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17661,7 +22353,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt32ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17673,8 +22374,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt32ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17750,6 +22470,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt32ArrayArrayRequest(args [0] // // POST /test_request_required_integer_int32_nullable func (s *Server) handleTestRequestRequiredIntegerInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17771,7 +22493,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17783,8 +22514,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17860,6 +22610,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableRequest(args [0]st // // POST /test_request_required_integer_int32_nullable_array func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17881,7 +22633,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -17893,8 +22654,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -17970,6 +22750,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayRequest(args // // POST /test_request_required_integer_int32_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -17991,7 +22773,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18003,8 +22794,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18080,6 +22890,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt32NullableArrayArrayRequest( // // POST /test_request_required_integer_int64 func (s *Server) handleTestRequestRequiredIntegerInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18101,7 +22913,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt64Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18113,8 +22934,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt64Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18190,6 +23030,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt64Request(args [0]string, ar // // POST /test_request_required_integer_int64_array func (s *Server) handleTestRequestRequiredIntegerInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18211,7 +23053,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt64ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18223,8 +23074,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt64ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18300,6 +23170,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt64ArrayRequest(args [0]strin // // POST /test_request_required_integer_int64_array_array func (s *Server) handleTestRequestRequiredIntegerInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18321,7 +23193,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt64ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18333,8 +23214,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt64ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18410,6 +23310,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt64ArrayArrayRequest(args [0] // // POST /test_request_required_integer_int64_nullable func (s *Server) handleTestRequestRequiredIntegerInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18431,7 +23333,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18443,8 +23354,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18520,6 +23450,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableRequest(args [0]st // // POST /test_request_required_integer_int64_nullable_array func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18541,7 +23473,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18553,8 +23494,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18630,6 +23590,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayRequest(args // // POST /test_request_required_integer_int64_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18651,7 +23613,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18663,8 +23634,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18740,6 +23730,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt64NullableArrayArrayRequest( // // POST /test_request_required_integer_int8 func (s *Server) handleTestRequestRequiredIntegerInt8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18761,7 +23753,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt8Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18773,8 +23774,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt8Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18850,6 +23870,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt8Request(args [0]string, arg // // POST /test_request_required_integer_int8_array func (s *Server) handleTestRequestRequiredIntegerInt8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18871,7 +23893,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt8ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18883,8 +23914,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt8ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -18960,6 +24010,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt8ArrayRequest(args [0]string // // POST /test_request_required_integer_int8_array_array func (s *Server) handleTestRequestRequiredIntegerInt8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -18981,7 +24033,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt8ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -18993,8 +24054,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt8ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19070,6 +24150,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt8ArrayArrayRequest(args [0]s // // POST /test_request_required_integer_int8_nullable func (s *Server) handleTestRequestRequiredIntegerInt8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19091,7 +24173,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19103,8 +24194,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19180,6 +24290,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableRequest(args [0]str // // POST /test_request_required_integer_int8_nullable_array func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19201,7 +24313,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19213,8 +24334,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19290,6 +24430,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayRequest(args [ // // POST /test_request_required_integer_int8_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_int8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19311,7 +24453,16 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19323,8 +24474,27 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19400,6 +24570,8 @@ func (s *Server) handleTestRequestRequiredIntegerInt8NullableArrayArrayRequest(a // // POST /test_request_required_integer_nullable func (s *Server) handleTestRequestRequiredIntegerNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19421,7 +24593,16 @@ func (s *Server) handleTestRequestRequiredIntegerNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19433,8 +24614,27 @@ func (s *Server) handleTestRequestRequiredIntegerNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19510,6 +24710,8 @@ func (s *Server) handleTestRequestRequiredIntegerNullableRequest(args [0]string, // // POST /test_request_required_integer_nullable_array func (s *Server) handleTestRequestRequiredIntegerNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19531,7 +24733,16 @@ func (s *Server) handleTestRequestRequiredIntegerNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19543,8 +24754,27 @@ func (s *Server) handleTestRequestRequiredIntegerNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19620,6 +24850,8 @@ func (s *Server) handleTestRequestRequiredIntegerNullableArrayRequest(args [0]st // // POST /test_request_required_integer_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19641,7 +24873,16 @@ func (s *Server) handleTestRequestRequiredIntegerNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19653,8 +24894,27 @@ func (s *Server) handleTestRequestRequiredIntegerNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19730,6 +24990,8 @@ func (s *Server) handleTestRequestRequiredIntegerNullableArrayArrayRequest(args // // POST /test_request_required_integer_uint func (s *Server) handleTestRequestRequiredIntegerUintRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19751,7 +25013,16 @@ func (s *Server) handleTestRequestRequiredIntegerUintRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19763,8 +25034,27 @@ func (s *Server) handleTestRequestRequiredIntegerUintRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19840,6 +25130,8 @@ func (s *Server) handleTestRequestRequiredIntegerUintRequest(args [0]string, arg // // POST /test_request_required_integer_uint16 func (s *Server) handleTestRequestRequiredIntegerUint16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19861,7 +25153,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint16Request(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19873,8 +25174,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint16Request(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -19950,6 +25270,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint16Request(args [0]string, a // // POST /test_request_required_integer_uint16_array func (s *Server) handleTestRequestRequiredIntegerUint16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -19971,7 +25293,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint16ArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -19983,8 +25314,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint16ArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20060,6 +25410,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint16ArrayRequest(args [0]stri // // POST /test_request_required_integer_uint16_array_array func (s *Server) handleTestRequestRequiredIntegerUint16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20081,7 +25433,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint16ArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20093,8 +25454,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint16ArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20170,6 +25550,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint16ArrayArrayRequest(args [0 // // POST /test_request_required_integer_uint16_nullable func (s *Server) handleTestRequestRequiredIntegerUint16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20191,7 +25573,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20203,8 +25594,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20280,6 +25690,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableRequest(args [0]s // // POST /test_request_required_integer_uint16_nullable_array func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20301,7 +25713,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20313,8 +25734,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20390,6 +25830,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayRequest(args // // POST /test_request_required_integer_uint16_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20411,7 +25853,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayArrayRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20423,8 +25874,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayArrayRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20500,6 +25970,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint16NullableArrayArrayRequest // // POST /test_request_required_integer_uint32 func (s *Server) handleTestRequestRequiredIntegerUint32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20521,7 +25993,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint32Request(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20533,8 +26014,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint32Request(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20610,6 +26110,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint32Request(args [0]string, a // // POST /test_request_required_integer_uint32_array func (s *Server) handleTestRequestRequiredIntegerUint32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20631,7 +26133,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint32ArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20643,8 +26154,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint32ArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20720,6 +26250,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint32ArrayRequest(args [0]stri // // POST /test_request_required_integer_uint32_array_array func (s *Server) handleTestRequestRequiredIntegerUint32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20741,7 +26273,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint32ArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20753,8 +26294,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint32ArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20830,6 +26390,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint32ArrayArrayRequest(args [0 // // POST /test_request_required_integer_uint32_nullable func (s *Server) handleTestRequestRequiredIntegerUint32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20851,7 +26413,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20863,8 +26434,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -20940,6 +26530,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableRequest(args [0]s // // POST /test_request_required_integer_uint32_nullable_array func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -20961,7 +26553,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -20973,8 +26574,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21050,6 +26670,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayRequest(args // // POST /test_request_required_integer_uint32_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21071,7 +26693,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayArrayRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21083,8 +26714,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayArrayRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21160,6 +26810,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint32NullableArrayArrayRequest // // POST /test_request_required_integer_uint64 func (s *Server) handleTestRequestRequiredIntegerUint64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21181,7 +26833,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint64Request(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21193,8 +26854,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint64Request(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21270,6 +26950,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint64Request(args [0]string, a // // POST /test_request_required_integer_uint64_array func (s *Server) handleTestRequestRequiredIntegerUint64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21291,7 +26973,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint64ArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21303,8 +26994,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint64ArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21380,6 +27090,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint64ArrayRequest(args [0]stri // // POST /test_request_required_integer_uint64_array_array func (s *Server) handleTestRequestRequiredIntegerUint64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21401,7 +27113,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint64ArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21413,8 +27134,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint64ArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21490,6 +27230,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint64ArrayArrayRequest(args [0 // // POST /test_request_required_integer_uint64_nullable func (s *Server) handleTestRequestRequiredIntegerUint64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21511,7 +27253,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21523,8 +27274,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21600,6 +27370,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableRequest(args [0]s // // POST /test_request_required_integer_uint64_nullable_array func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21621,7 +27393,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21633,8 +27414,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21710,6 +27510,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayRequest(args // // POST /test_request_required_integer_uint64_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21731,7 +27533,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayArrayRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21743,8 +27554,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayArrayRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21820,6 +27650,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint64NullableArrayArrayRequest // // POST /test_request_required_integer_uint8 func (s *Server) handleTestRequestRequiredIntegerUint8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21841,7 +27673,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint8Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21853,8 +27694,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint8Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -21930,6 +27790,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint8Request(args [0]string, ar // // POST /test_request_required_integer_uint8_array func (s *Server) handleTestRequestRequiredIntegerUint8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -21951,7 +27813,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint8ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -21963,8 +27834,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint8ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22040,6 +27930,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint8ArrayRequest(args [0]strin // // POST /test_request_required_integer_uint8_array_array func (s *Server) handleTestRequestRequiredIntegerUint8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22061,7 +27953,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint8ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22073,8 +27974,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint8ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22150,6 +28070,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint8ArrayArrayRequest(args [0] // // POST /test_request_required_integer_uint8_nullable func (s *Server) handleTestRequestRequiredIntegerUint8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22171,7 +28093,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22183,8 +28114,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22260,6 +28210,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableRequest(args [0]st // // POST /test_request_required_integer_uint8_nullable_array func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22281,7 +28233,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22293,8 +28254,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22370,6 +28350,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayRequest(args // // POST /test_request_required_integer_uint8_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22391,7 +28373,16 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22403,8 +28394,27 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22480,6 +28490,8 @@ func (s *Server) handleTestRequestRequiredIntegerUint8NullableArrayArrayRequest( // // POST /test_request_required_integer_uint_array func (s *Server) handleTestRequestRequiredIntegerUintArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22501,7 +28513,16 @@ func (s *Server) handleTestRequestRequiredIntegerUintArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22513,8 +28534,27 @@ func (s *Server) handleTestRequestRequiredIntegerUintArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22590,6 +28630,8 @@ func (s *Server) handleTestRequestRequiredIntegerUintArrayRequest(args [0]string // // POST /test_request_required_integer_uint_array_array func (s *Server) handleTestRequestRequiredIntegerUintArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22611,7 +28653,16 @@ func (s *Server) handleTestRequestRequiredIntegerUintArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22623,8 +28674,27 @@ func (s *Server) handleTestRequestRequiredIntegerUintArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22700,6 +28770,8 @@ func (s *Server) handleTestRequestRequiredIntegerUintArrayArrayRequest(args [0]s // // POST /test_request_required_integer_uint_nullable func (s *Server) handleTestRequestRequiredIntegerUintNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22721,7 +28793,16 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22733,8 +28814,27 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22810,6 +28910,8 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableRequest(args [0]str // // POST /test_request_required_integer_uint_nullable_array func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22831,7 +28933,16 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22843,8 +28954,27 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -22920,6 +29050,8 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayRequest(args [ // // POST /test_request_required_integer_uint_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_uint_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -22941,7 +29073,16 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -22953,8 +29094,27 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23030,6 +29190,8 @@ func (s *Server) handleTestRequestRequiredIntegerUintNullableArrayArrayRequest(a // // POST /test_request_required_integer_unix func (s *Server) handleTestRequestRequiredIntegerUnixRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23051,7 +29213,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23063,8 +29234,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23140,6 +29330,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixRequest(args [0]string, arg // // POST /test_request_required_integer_unix_array func (s *Server) handleTestRequestRequiredIntegerUnixArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23161,7 +29353,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23173,8 +29374,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23250,6 +29470,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixArrayRequest(args [0]string // // POST /test_request_required_integer_unix_array_array func (s *Server) handleTestRequestRequiredIntegerUnixArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23271,7 +29493,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23283,8 +29514,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23360,6 +29610,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixArrayArrayRequest(args [0]s // // POST /test_request_required_integer_unix-micro func (s *Server) handleTestRequestRequiredIntegerUnixMicroRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-micro"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23381,7 +29633,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23393,8 +29654,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23470,6 +29750,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroRequest(args [0]string // // POST /test_request_required_integer_unix-micro_array func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-micro_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23491,7 +29773,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23503,8 +29794,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23580,6 +29890,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayRequest(args [0]s // // POST /test_request_required_integer_unix-micro_array_array func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-micro_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23601,7 +29913,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23613,8 +29934,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23690,6 +30030,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroArrayArrayRequest(args // // POST /test_request_required_integer_unix-micro_nullable func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-micro_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23711,7 +30053,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23723,8 +30074,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23800,6 +30170,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableRequest(args [ // // POST /test_request_required_integer_unix-micro_nullable_array func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-micro_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23821,7 +30193,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23833,8 +30214,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -23910,6 +30310,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayRequest(a // // POST /test_request_required_integer_unix-micro_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-micro_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -23931,7 +30333,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayArrayRequ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -23943,8 +30354,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayArrayRequ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24020,6 +30450,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMicroNullableArrayArrayRequ // // POST /test_request_required_integer_unix-milli func (s *Server) handleTestRequestRequiredIntegerUnixMilliRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-milli"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24041,7 +30473,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24053,8 +30494,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24130,6 +30590,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliRequest(args [0]string // // POST /test_request_required_integer_unix-milli_array func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-milli_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24151,7 +30613,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24163,8 +30634,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24240,6 +30730,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayRequest(args [0]s // // POST /test_request_required_integer_unix-milli_array_array func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-milli_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24261,7 +30753,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24273,8 +30774,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24350,6 +30870,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliArrayArrayRequest(args // // POST /test_request_required_integer_unix-milli_nullable func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-milli_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24371,7 +30893,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24383,8 +30914,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24460,6 +31010,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableRequest(args [ // // POST /test_request_required_integer_unix-milli_nullable_array func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-milli_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24481,7 +31033,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24493,8 +31054,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24570,6 +31150,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayRequest(a // // POST /test_request_required_integer_unix-milli_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-milli_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24591,7 +31173,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayArrayRequ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24603,8 +31194,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayArrayRequ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24680,6 +31290,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixMilliNullableArrayArrayRequ // // POST /test_request_required_integer_unix-nano func (s *Server) handleTestRequestRequiredIntegerUnixNanoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-nano"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24701,7 +31313,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24713,8 +31334,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24790,6 +31430,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoRequest(args [0]string, // // POST /test_request_required_integer_unix-nano_array func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-nano_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24811,7 +31453,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24823,8 +31474,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -24900,6 +31570,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayRequest(args [0]st // // POST /test_request_required_integer_unix-nano_array_array func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-nano_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -24921,7 +31593,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -24933,8 +31614,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25010,6 +31710,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoArrayArrayRequest(args // // POST /test_request_required_integer_unix-nano_nullable func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-nano_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25031,7 +31733,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25043,8 +31754,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25120,6 +31850,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableRequest(args [0 // // POST /test_request_required_integer_unix-nano_nullable_array func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-nano_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25141,7 +31873,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25153,8 +31894,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25230,6 +31990,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayRequest(ar // // POST /test_request_required_integer_unix-nano_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-nano_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25251,7 +32013,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayArrayReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25263,8 +32034,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayArrayReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25340,6 +32130,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNanoNullableArrayArrayReque // // POST /test_request_required_integer_unix_nullable func (s *Server) handleTestRequestRequiredIntegerUnixNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25361,7 +32153,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25373,8 +32174,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25450,6 +32270,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableRequest(args [0]str // // POST /test_request_required_integer_unix_nullable_array func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25471,7 +32293,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25483,8 +32314,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25560,6 +32410,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayRequest(args [ // // POST /test_request_required_integer_unix_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25581,7 +32433,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25593,8 +32454,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25670,6 +32550,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixNullableArrayArrayRequest(a // // POST /test_request_required_integer_unix-seconds func (s *Server) handleTestRequestRequiredIntegerUnixSecondsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-seconds"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25691,7 +32573,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25703,8 +32594,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25780,6 +32690,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsRequest(args [0]stri // // POST /test_request_required_integer_unix-seconds_array func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-seconds_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25801,7 +32713,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25813,8 +32734,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -25890,6 +32830,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayRequest(args [0 // // POST /test_request_required_integer_unix-seconds_array_array func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-seconds_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -25911,7 +32853,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -25923,8 +32874,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26000,6 +32970,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsArrayArrayRequest(ar // // POST /test_request_required_integer_unix-seconds_nullable func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-seconds_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26021,7 +32993,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26033,8 +33014,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26110,6 +33110,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableRequest(args // // POST /test_request_required_integer_unix-seconds_nullable_array func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-seconds_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26131,7 +33133,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26143,8 +33154,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26220,6 +33250,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayRequest // // POST /test_request_required_integer_unix-seconds_nullable_array_array func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_integer_unix-seconds_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26241,7 +33273,16 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayArrayRe startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26253,8 +33294,27 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayArrayRe var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26330,6 +33390,8 @@ func (s *Server) handleTestRequestRequiredIntegerUnixSecondsNullableArrayArrayRe // // POST /test_request_required_null func (s *Server) handleTestRequestRequiredNullRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_null"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26351,7 +33413,16 @@ func (s *Server) handleTestRequestRequiredNullRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26363,8 +33434,27 @@ func (s *Server) handleTestRequestRequiredNullRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26440,6 +33530,8 @@ func (s *Server) handleTestRequestRequiredNullRequest(args [0]string, argsEscape // // POST /test_request_required_null_array func (s *Server) handleTestRequestRequiredNullArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_null_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26461,7 +33553,16 @@ func (s *Server) handleTestRequestRequiredNullArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26473,8 +33574,27 @@ func (s *Server) handleTestRequestRequiredNullArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26550,6 +33670,8 @@ func (s *Server) handleTestRequestRequiredNullArrayRequest(args [0]string, argsE // // POST /test_request_required_null_array_array func (s *Server) handleTestRequestRequiredNullArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_null_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26571,7 +33693,16 @@ func (s *Server) handleTestRequestRequiredNullArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26583,8 +33714,27 @@ func (s *Server) handleTestRequestRequiredNullArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26660,6 +33810,8 @@ func (s *Server) handleTestRequestRequiredNullArrayArrayRequest(args [0]string, // // POST /test_request_required_null_nullable func (s *Server) handleTestRequestRequiredNullNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_null_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26681,7 +33833,16 @@ func (s *Server) handleTestRequestRequiredNullNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26693,8 +33854,27 @@ func (s *Server) handleTestRequestRequiredNullNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26770,6 +33950,8 @@ func (s *Server) handleTestRequestRequiredNullNullableRequest(args [0]string, ar // // POST /test_request_required_null_nullable_array func (s *Server) handleTestRequestRequiredNullNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_null_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26791,7 +33973,16 @@ func (s *Server) handleTestRequestRequiredNullNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26803,8 +33994,27 @@ func (s *Server) handleTestRequestRequiredNullNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26880,6 +34090,8 @@ func (s *Server) handleTestRequestRequiredNullNullableArrayRequest(args [0]strin // // POST /test_request_required_null_nullable_array_array func (s *Server) handleTestRequestRequiredNullNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_null_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -26901,7 +34113,16 @@ func (s *Server) handleTestRequestRequiredNullNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -26913,8 +34134,27 @@ func (s *Server) handleTestRequestRequiredNullNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -26990,6 +34230,8 @@ func (s *Server) handleTestRequestRequiredNullNullableArrayArrayRequest(args [0] // // POST /test_request_required_number func (s *Server) handleTestRequestRequiredNumberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27011,7 +34253,16 @@ func (s *Server) handleTestRequestRequiredNumberRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27023,8 +34274,27 @@ func (s *Server) handleTestRequestRequiredNumberRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27100,6 +34370,8 @@ func (s *Server) handleTestRequestRequiredNumberRequest(args [0]string, argsEsca // // POST /test_request_required_number_array func (s *Server) handleTestRequestRequiredNumberArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27121,7 +34393,16 @@ func (s *Server) handleTestRequestRequiredNumberArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27133,8 +34414,27 @@ func (s *Server) handleTestRequestRequiredNumberArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27210,6 +34510,8 @@ func (s *Server) handleTestRequestRequiredNumberArrayRequest(args [0]string, arg // // POST /test_request_required_number_array_array func (s *Server) handleTestRequestRequiredNumberArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27231,7 +34533,16 @@ func (s *Server) handleTestRequestRequiredNumberArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27243,8 +34554,27 @@ func (s *Server) handleTestRequestRequiredNumberArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27320,6 +34650,8 @@ func (s *Server) handleTestRequestRequiredNumberArrayArrayRequest(args [0]string // // POST /test_request_required_number_double func (s *Server) handleTestRequestRequiredNumberDoubleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_double"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27341,7 +34673,16 @@ func (s *Server) handleTestRequestRequiredNumberDoubleRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27353,8 +34694,27 @@ func (s *Server) handleTestRequestRequiredNumberDoubleRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27430,6 +34790,8 @@ func (s *Server) handleTestRequestRequiredNumberDoubleRequest(args [0]string, ar // // POST /test_request_required_number_double_array func (s *Server) handleTestRequestRequiredNumberDoubleArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_double_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27451,7 +34813,16 @@ func (s *Server) handleTestRequestRequiredNumberDoubleArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27463,8 +34834,27 @@ func (s *Server) handleTestRequestRequiredNumberDoubleArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27540,6 +34930,8 @@ func (s *Server) handleTestRequestRequiredNumberDoubleArrayRequest(args [0]strin // // POST /test_request_required_number_double_array_array func (s *Server) handleTestRequestRequiredNumberDoubleArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_double_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27561,7 +34953,16 @@ func (s *Server) handleTestRequestRequiredNumberDoubleArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27573,8 +34974,27 @@ func (s *Server) handleTestRequestRequiredNumberDoubleArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27650,6 +35070,8 @@ func (s *Server) handleTestRequestRequiredNumberDoubleArrayArrayRequest(args [0] // // POST /test_request_required_number_double_nullable func (s *Server) handleTestRequestRequiredNumberDoubleNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_double_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27671,7 +35093,16 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27683,8 +35114,27 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27760,6 +35210,8 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableRequest(args [0]st // // POST /test_request_required_number_double_nullable_array func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_double_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27781,7 +35233,16 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27793,8 +35254,27 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27870,6 +35350,8 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayRequest(args // // POST /test_request_required_number_double_nullable_array_array func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_double_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -27891,7 +35373,16 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -27903,8 +35394,27 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -27980,6 +35490,8 @@ func (s *Server) handleTestRequestRequiredNumberDoubleNullableArrayArrayRequest( // // POST /test_request_required_number_float func (s *Server) handleTestRequestRequiredNumberFloatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_float"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28001,7 +35513,16 @@ func (s *Server) handleTestRequestRequiredNumberFloatRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28013,8 +35534,27 @@ func (s *Server) handleTestRequestRequiredNumberFloatRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28090,6 +35630,8 @@ func (s *Server) handleTestRequestRequiredNumberFloatRequest(args [0]string, arg // // POST /test_request_required_number_float_array func (s *Server) handleTestRequestRequiredNumberFloatArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_float_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28111,7 +35653,16 @@ func (s *Server) handleTestRequestRequiredNumberFloatArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28123,8 +35674,27 @@ func (s *Server) handleTestRequestRequiredNumberFloatArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28200,6 +35770,8 @@ func (s *Server) handleTestRequestRequiredNumberFloatArrayRequest(args [0]string // // POST /test_request_required_number_float_array_array func (s *Server) handleTestRequestRequiredNumberFloatArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_float_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28221,7 +35793,16 @@ func (s *Server) handleTestRequestRequiredNumberFloatArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28233,8 +35814,27 @@ func (s *Server) handleTestRequestRequiredNumberFloatArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28310,6 +35910,8 @@ func (s *Server) handleTestRequestRequiredNumberFloatArrayArrayRequest(args [0]s // // POST /test_request_required_number_float_nullable func (s *Server) handleTestRequestRequiredNumberFloatNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_float_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28331,7 +35933,16 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28343,8 +35954,27 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28420,6 +36050,8 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableRequest(args [0]str // // POST /test_request_required_number_float_nullable_array func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_float_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28441,7 +36073,16 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28453,8 +36094,27 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28530,6 +36190,8 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayRequest(args [ // // POST /test_request_required_number_float_nullable_array_array func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_float_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28551,7 +36213,16 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28563,8 +36234,27 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28640,6 +36330,8 @@ func (s *Server) handleTestRequestRequiredNumberFloatNullableArrayArrayRequest(a // // POST /test_request_required_number_int32 func (s *Server) handleTestRequestRequiredNumberInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28661,7 +36353,16 @@ func (s *Server) handleTestRequestRequiredNumberInt32Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28673,8 +36374,27 @@ func (s *Server) handleTestRequestRequiredNumberInt32Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28750,6 +36470,8 @@ func (s *Server) handleTestRequestRequiredNumberInt32Request(args [0]string, arg // // POST /test_request_required_number_int32_array func (s *Server) handleTestRequestRequiredNumberInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28771,7 +36493,16 @@ func (s *Server) handleTestRequestRequiredNumberInt32ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28783,8 +36514,27 @@ func (s *Server) handleTestRequestRequiredNumberInt32ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28860,6 +36610,8 @@ func (s *Server) handleTestRequestRequiredNumberInt32ArrayRequest(args [0]string // // POST /test_request_required_number_int32_array_array func (s *Server) handleTestRequestRequiredNumberInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28881,7 +36633,16 @@ func (s *Server) handleTestRequestRequiredNumberInt32ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -28893,8 +36654,27 @@ func (s *Server) handleTestRequestRequiredNumberInt32ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -28970,6 +36750,8 @@ func (s *Server) handleTestRequestRequiredNumberInt32ArrayArrayRequest(args [0]s // // POST /test_request_required_number_int32_nullable func (s *Server) handleTestRequestRequiredNumberInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -28991,7 +36773,16 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29003,8 +36794,27 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29080,6 +36890,8 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableRequest(args [0]str // // POST /test_request_required_number_int32_nullable_array func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29101,7 +36913,16 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29113,8 +36934,27 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29190,6 +37030,8 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayRequest(args [ // // POST /test_request_required_number_int32_nullable_array_array func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29211,7 +37053,16 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29223,8 +37074,27 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29300,6 +37170,8 @@ func (s *Server) handleTestRequestRequiredNumberInt32NullableArrayArrayRequest(a // // POST /test_request_required_number_int64 func (s *Server) handleTestRequestRequiredNumberInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29321,7 +37193,16 @@ func (s *Server) handleTestRequestRequiredNumberInt64Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29333,8 +37214,27 @@ func (s *Server) handleTestRequestRequiredNumberInt64Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29410,6 +37310,8 @@ func (s *Server) handleTestRequestRequiredNumberInt64Request(args [0]string, arg // // POST /test_request_required_number_int64_array func (s *Server) handleTestRequestRequiredNumberInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29431,7 +37333,16 @@ func (s *Server) handleTestRequestRequiredNumberInt64ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29443,8 +37354,27 @@ func (s *Server) handleTestRequestRequiredNumberInt64ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29520,6 +37450,8 @@ func (s *Server) handleTestRequestRequiredNumberInt64ArrayRequest(args [0]string // // POST /test_request_required_number_int64_array_array func (s *Server) handleTestRequestRequiredNumberInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29541,7 +37473,16 @@ func (s *Server) handleTestRequestRequiredNumberInt64ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29553,8 +37494,27 @@ func (s *Server) handleTestRequestRequiredNumberInt64ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29630,6 +37590,8 @@ func (s *Server) handleTestRequestRequiredNumberInt64ArrayArrayRequest(args [0]s // // POST /test_request_required_number_int64_nullable func (s *Server) handleTestRequestRequiredNumberInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29651,7 +37613,16 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29663,8 +37634,27 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29740,6 +37730,8 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableRequest(args [0]str // // POST /test_request_required_number_int64_nullable_array func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29761,7 +37753,16 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29773,8 +37774,27 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29850,6 +37870,8 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayRequest(args [ // // POST /test_request_required_number_int64_nullable_array_array func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29871,7 +37893,16 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29883,8 +37914,27 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -29960,6 +38010,8 @@ func (s *Server) handleTestRequestRequiredNumberInt64NullableArrayArrayRequest(a // // POST /test_request_required_number_nullable func (s *Server) handleTestRequestRequiredNumberNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -29981,7 +38033,16 @@ func (s *Server) handleTestRequestRequiredNumberNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -29993,8 +38054,27 @@ func (s *Server) handleTestRequestRequiredNumberNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30070,6 +38150,8 @@ func (s *Server) handleTestRequestRequiredNumberNullableRequest(args [0]string, // // POST /test_request_required_number_nullable_array func (s *Server) handleTestRequestRequiredNumberNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30091,7 +38173,16 @@ func (s *Server) handleTestRequestRequiredNumberNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30103,8 +38194,27 @@ func (s *Server) handleTestRequestRequiredNumberNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30180,6 +38290,8 @@ func (s *Server) handleTestRequestRequiredNumberNullableArrayRequest(args [0]str // // POST /test_request_required_number_nullable_array_array func (s *Server) handleTestRequestRequiredNumberNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_number_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30201,7 +38313,16 @@ func (s *Server) handleTestRequestRequiredNumberNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30213,8 +38334,27 @@ func (s *Server) handleTestRequestRequiredNumberNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30290,6 +38430,8 @@ func (s *Server) handleTestRequestRequiredNumberNullableArrayArrayRequest(args [ // // POST /test_request_required_string func (s *Server) handleTestRequestRequiredStringRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30311,7 +38453,16 @@ func (s *Server) handleTestRequestRequiredStringRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30323,8 +38474,27 @@ func (s *Server) handleTestRequestRequiredStringRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30400,6 +38570,8 @@ func (s *Server) handleTestRequestRequiredStringRequest(args [0]string, argsEsca // // POST /test_request_required_string_array func (s *Server) handleTestRequestRequiredStringArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30421,7 +38593,16 @@ func (s *Server) handleTestRequestRequiredStringArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30433,8 +38614,27 @@ func (s *Server) handleTestRequestRequiredStringArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30510,6 +38710,8 @@ func (s *Server) handleTestRequestRequiredStringArrayRequest(args [0]string, arg // // POST /test_request_required_string_array_array func (s *Server) handleTestRequestRequiredStringArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30531,7 +38733,16 @@ func (s *Server) handleTestRequestRequiredStringArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30543,8 +38754,27 @@ func (s *Server) handleTestRequestRequiredStringArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30620,6 +38850,8 @@ func (s *Server) handleTestRequestRequiredStringArrayArrayRequest(args [0]string // // POST /test_request_required_string_base64 func (s *Server) handleTestRequestRequiredStringBase64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_base64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30641,7 +38873,16 @@ func (s *Server) handleTestRequestRequiredStringBase64Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30653,8 +38894,27 @@ func (s *Server) handleTestRequestRequiredStringBase64Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30730,6 +38990,8 @@ func (s *Server) handleTestRequestRequiredStringBase64Request(args [0]string, ar // // POST /test_request_required_string_base64_array func (s *Server) handleTestRequestRequiredStringBase64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_base64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30751,7 +39013,16 @@ func (s *Server) handleTestRequestRequiredStringBase64ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30763,8 +39034,27 @@ func (s *Server) handleTestRequestRequiredStringBase64ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30840,6 +39130,8 @@ func (s *Server) handleTestRequestRequiredStringBase64ArrayRequest(args [0]strin // // POST /test_request_required_string_base64_array_array func (s *Server) handleTestRequestRequiredStringBase64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_base64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30861,7 +39153,16 @@ func (s *Server) handleTestRequestRequiredStringBase64ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30873,8 +39174,27 @@ func (s *Server) handleTestRequestRequiredStringBase64ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -30950,6 +39270,8 @@ func (s *Server) handleTestRequestRequiredStringBase64ArrayArrayRequest(args [0] // // POST /test_request_required_string_base64_nullable func (s *Server) handleTestRequestRequiredStringBase64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_base64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -30971,7 +39293,16 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -30983,8 +39314,27 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31060,6 +39410,8 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableRequest(args [0]st // // POST /test_request_required_string_base64_nullable_array func (s *Server) handleTestRequestRequiredStringBase64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_base64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31081,7 +39433,16 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31093,8 +39454,27 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31170,6 +39550,8 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableArrayRequest(args // // POST /test_request_required_string_base64_nullable_array_array func (s *Server) handleTestRequestRequiredStringBase64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_base64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31191,7 +39573,16 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31203,8 +39594,27 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31280,6 +39690,8 @@ func (s *Server) handleTestRequestRequiredStringBase64NullableArrayArrayRequest( // // POST /test_request_required_string_binary func (s *Server) handleTestRequestRequiredStringBinaryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_binary"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31301,7 +39713,16 @@ func (s *Server) handleTestRequestRequiredStringBinaryRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31313,8 +39734,27 @@ func (s *Server) handleTestRequestRequiredStringBinaryRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31390,6 +39830,8 @@ func (s *Server) handleTestRequestRequiredStringBinaryRequest(args [0]string, ar // // POST /test_request_required_string_binary_array func (s *Server) handleTestRequestRequiredStringBinaryArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_binary_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31411,7 +39853,16 @@ func (s *Server) handleTestRequestRequiredStringBinaryArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31423,8 +39874,27 @@ func (s *Server) handleTestRequestRequiredStringBinaryArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31500,6 +39970,8 @@ func (s *Server) handleTestRequestRequiredStringBinaryArrayRequest(args [0]strin // // POST /test_request_required_string_binary_array_array func (s *Server) handleTestRequestRequiredStringBinaryArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_binary_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31521,7 +39993,16 @@ func (s *Server) handleTestRequestRequiredStringBinaryArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31533,8 +40014,27 @@ func (s *Server) handleTestRequestRequiredStringBinaryArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31610,6 +40110,8 @@ func (s *Server) handleTestRequestRequiredStringBinaryArrayArrayRequest(args [0] // // POST /test_request_required_string_binary_nullable func (s *Server) handleTestRequestRequiredStringBinaryNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_binary_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31631,7 +40133,16 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31643,8 +40154,27 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31720,6 +40250,8 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableRequest(args [0]st // // POST /test_request_required_string_binary_nullable_array func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_binary_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31741,7 +40273,16 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31753,8 +40294,27 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31830,6 +40390,8 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayRequest(args // // POST /test_request_required_string_binary_nullable_array_array func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_binary_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31851,7 +40413,16 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31863,8 +40434,27 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -31940,6 +40530,8 @@ func (s *Server) handleTestRequestRequiredStringBinaryNullableArrayArrayRequest( // // POST /test_request_required_string_byte func (s *Server) handleTestRequestRequiredStringByteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_byte"), semconv.HTTPRequestMethodKey.String("POST"), @@ -31961,7 +40553,16 @@ func (s *Server) handleTestRequestRequiredStringByteRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -31973,8 +40574,27 @@ func (s *Server) handleTestRequestRequiredStringByteRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32050,6 +40670,8 @@ func (s *Server) handleTestRequestRequiredStringByteRequest(args [0]string, args // // POST /test_request_required_string_byte_array func (s *Server) handleTestRequestRequiredStringByteArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_byte_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32071,7 +40693,16 @@ func (s *Server) handleTestRequestRequiredStringByteArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32083,8 +40714,27 @@ func (s *Server) handleTestRequestRequiredStringByteArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32160,6 +40810,8 @@ func (s *Server) handleTestRequestRequiredStringByteArrayRequest(args [0]string, // // POST /test_request_required_string_byte_array_array func (s *Server) handleTestRequestRequiredStringByteArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_byte_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32181,7 +40833,16 @@ func (s *Server) handleTestRequestRequiredStringByteArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32193,8 +40854,27 @@ func (s *Server) handleTestRequestRequiredStringByteArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32270,6 +40950,8 @@ func (s *Server) handleTestRequestRequiredStringByteArrayArrayRequest(args [0]st // // POST /test_request_required_string_byte_nullable func (s *Server) handleTestRequestRequiredStringByteNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_byte_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32291,7 +40973,16 @@ func (s *Server) handleTestRequestRequiredStringByteNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32303,8 +40994,27 @@ func (s *Server) handleTestRequestRequiredStringByteNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32380,6 +41090,8 @@ func (s *Server) handleTestRequestRequiredStringByteNullableRequest(args [0]stri // // POST /test_request_required_string_byte_nullable_array func (s *Server) handleTestRequestRequiredStringByteNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_byte_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32401,7 +41113,16 @@ func (s *Server) handleTestRequestRequiredStringByteNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32413,8 +41134,27 @@ func (s *Server) handleTestRequestRequiredStringByteNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32490,6 +41230,8 @@ func (s *Server) handleTestRequestRequiredStringByteNullableArrayRequest(args [0 // // POST /test_request_required_string_byte_nullable_array_array func (s *Server) handleTestRequestRequiredStringByteNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_byte_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32511,7 +41253,16 @@ func (s *Server) handleTestRequestRequiredStringByteNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32523,8 +41274,27 @@ func (s *Server) handleTestRequestRequiredStringByteNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32600,6 +41370,8 @@ func (s *Server) handleTestRequestRequiredStringByteNullableArrayArrayRequest(ar // // POST /test_request_required_string_date func (s *Server) handleTestRequestRequiredStringDateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32621,7 +41393,16 @@ func (s *Server) handleTestRequestRequiredStringDateRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32633,8 +41414,27 @@ func (s *Server) handleTestRequestRequiredStringDateRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32710,6 +41510,8 @@ func (s *Server) handleTestRequestRequiredStringDateRequest(args [0]string, args // // POST /test_request_required_string_date_array func (s *Server) handleTestRequestRequiredStringDateArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32731,7 +41533,16 @@ func (s *Server) handleTestRequestRequiredStringDateArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32743,8 +41554,27 @@ func (s *Server) handleTestRequestRequiredStringDateArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32820,6 +41650,8 @@ func (s *Server) handleTestRequestRequiredStringDateArrayRequest(args [0]string, // // POST /test_request_required_string_date_array_array func (s *Server) handleTestRequestRequiredStringDateArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32841,7 +41673,16 @@ func (s *Server) handleTestRequestRequiredStringDateArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32853,8 +41694,27 @@ func (s *Server) handleTestRequestRequiredStringDateArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -32930,6 +41790,8 @@ func (s *Server) handleTestRequestRequiredStringDateArrayArrayRequest(args [0]st // // POST /test_request_required_string_date_nullable func (s *Server) handleTestRequestRequiredStringDateNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -32951,7 +41813,16 @@ func (s *Server) handleTestRequestRequiredStringDateNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -32963,8 +41834,27 @@ func (s *Server) handleTestRequestRequiredStringDateNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33040,6 +41930,8 @@ func (s *Server) handleTestRequestRequiredStringDateNullableRequest(args [0]stri // // POST /test_request_required_string_date_nullable_array func (s *Server) handleTestRequestRequiredStringDateNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33061,7 +41953,16 @@ func (s *Server) handleTestRequestRequiredStringDateNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33073,8 +41974,27 @@ func (s *Server) handleTestRequestRequiredStringDateNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33150,6 +42070,8 @@ func (s *Server) handleTestRequestRequiredStringDateNullableArrayRequest(args [0 // // POST /test_request_required_string_date_nullable_array_array func (s *Server) handleTestRequestRequiredStringDateNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33171,7 +42093,16 @@ func (s *Server) handleTestRequestRequiredStringDateNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33183,8 +42114,27 @@ func (s *Server) handleTestRequestRequiredStringDateNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33260,6 +42210,8 @@ func (s *Server) handleTestRequestRequiredStringDateNullableArrayArrayRequest(ar // // POST /test_request_required_string_date-time func (s *Server) handleTestRequestRequiredStringDateTimeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date-time"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33281,7 +42233,16 @@ func (s *Server) handleTestRequestRequiredStringDateTimeRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33293,8 +42254,27 @@ func (s *Server) handleTestRequestRequiredStringDateTimeRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33370,6 +42350,8 @@ func (s *Server) handleTestRequestRequiredStringDateTimeRequest(args [0]string, // // POST /test_request_required_string_date-time_array func (s *Server) handleTestRequestRequiredStringDateTimeArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date-time_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33391,7 +42373,16 @@ func (s *Server) handleTestRequestRequiredStringDateTimeArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33403,8 +42394,27 @@ func (s *Server) handleTestRequestRequiredStringDateTimeArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33480,6 +42490,8 @@ func (s *Server) handleTestRequestRequiredStringDateTimeArrayRequest(args [0]str // // POST /test_request_required_string_date-time_array_array func (s *Server) handleTestRequestRequiredStringDateTimeArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date-time_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33501,7 +42513,16 @@ func (s *Server) handleTestRequestRequiredStringDateTimeArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33513,8 +42534,27 @@ func (s *Server) handleTestRequestRequiredStringDateTimeArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33590,6 +42630,8 @@ func (s *Server) handleTestRequestRequiredStringDateTimeArrayArrayRequest(args [ // // POST /test_request_required_string_date-time_nullable func (s *Server) handleTestRequestRequiredStringDateTimeNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date-time_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33611,7 +42653,16 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33623,8 +42674,27 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33700,6 +42770,8 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableRequest(args [0] // // POST /test_request_required_string_date-time_nullable_array func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date-time_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33721,7 +42793,16 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33733,8 +42814,27 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33810,6 +42910,8 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayRequest(arg // // POST /test_request_required_string_date-time_nullable_array_array func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_date-time_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33831,7 +42933,16 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayArrayReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33843,8 +42954,27 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayArrayReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -33920,6 +43050,8 @@ func (s *Server) handleTestRequestRequiredStringDateTimeNullableArrayArrayReques // // POST /test_request_required_string_duration func (s *Server) handleTestRequestRequiredStringDurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_duration"), semconv.HTTPRequestMethodKey.String("POST"), @@ -33941,7 +43073,16 @@ func (s *Server) handleTestRequestRequiredStringDurationRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -33953,8 +43094,27 @@ func (s *Server) handleTestRequestRequiredStringDurationRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34030,6 +43190,8 @@ func (s *Server) handleTestRequestRequiredStringDurationRequest(args [0]string, // // POST /test_request_required_string_duration_array func (s *Server) handleTestRequestRequiredStringDurationArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_duration_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34051,7 +43213,16 @@ func (s *Server) handleTestRequestRequiredStringDurationArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34063,8 +43234,27 @@ func (s *Server) handleTestRequestRequiredStringDurationArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34140,6 +43330,8 @@ func (s *Server) handleTestRequestRequiredStringDurationArrayRequest(args [0]str // // POST /test_request_required_string_duration_array_array func (s *Server) handleTestRequestRequiredStringDurationArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_duration_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34161,7 +43353,16 @@ func (s *Server) handleTestRequestRequiredStringDurationArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34173,8 +43374,27 @@ func (s *Server) handleTestRequestRequiredStringDurationArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34250,6 +43470,8 @@ func (s *Server) handleTestRequestRequiredStringDurationArrayArrayRequest(args [ // // POST /test_request_required_string_duration_nullable func (s *Server) handleTestRequestRequiredStringDurationNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_duration_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34271,7 +43493,16 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34283,8 +43514,27 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34360,6 +43610,8 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableRequest(args [0] // // POST /test_request_required_string_duration_nullable_array func (s *Server) handleTestRequestRequiredStringDurationNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_duration_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34381,7 +43633,16 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34393,8 +43654,27 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34470,6 +43750,8 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableArrayRequest(arg // // POST /test_request_required_string_duration_nullable_array_array func (s *Server) handleTestRequestRequiredStringDurationNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_duration_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34491,7 +43773,16 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableArrayArrayReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34503,8 +43794,27 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableArrayArrayReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34580,6 +43890,8 @@ func (s *Server) handleTestRequestRequiredStringDurationNullableArrayArrayReques // // POST /test_request_required_string_email func (s *Server) handleTestRequestRequiredStringEmailRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_email"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34601,7 +43913,16 @@ func (s *Server) handleTestRequestRequiredStringEmailRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34613,8 +43934,27 @@ func (s *Server) handleTestRequestRequiredStringEmailRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34690,6 +44030,8 @@ func (s *Server) handleTestRequestRequiredStringEmailRequest(args [0]string, arg // // POST /test_request_required_string_email_array func (s *Server) handleTestRequestRequiredStringEmailArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_email_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34711,7 +44053,16 @@ func (s *Server) handleTestRequestRequiredStringEmailArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34723,8 +44074,27 @@ func (s *Server) handleTestRequestRequiredStringEmailArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34800,6 +44170,8 @@ func (s *Server) handleTestRequestRequiredStringEmailArrayRequest(args [0]string // // POST /test_request_required_string_email_array_array func (s *Server) handleTestRequestRequiredStringEmailArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_email_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34821,7 +44193,16 @@ func (s *Server) handleTestRequestRequiredStringEmailArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34833,8 +44214,27 @@ func (s *Server) handleTestRequestRequiredStringEmailArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -34910,6 +44310,8 @@ func (s *Server) handleTestRequestRequiredStringEmailArrayArrayRequest(args [0]s // // POST /test_request_required_string_email_nullable func (s *Server) handleTestRequestRequiredStringEmailNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_email_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -34931,7 +44333,16 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -34943,8 +44354,27 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35020,6 +44450,8 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableRequest(args [0]str // // POST /test_request_required_string_email_nullable_array func (s *Server) handleTestRequestRequiredStringEmailNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_email_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35041,7 +44473,16 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35053,8 +44494,27 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35130,6 +44590,8 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableArrayRequest(args [ // // POST /test_request_required_string_email_nullable_array_array func (s *Server) handleTestRequestRequiredStringEmailNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_email_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35151,7 +44613,16 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35163,8 +44634,27 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35240,6 +44730,8 @@ func (s *Server) handleTestRequestRequiredStringEmailNullableArrayArrayRequest(a // // POST /test_request_required_string_float32 func (s *Server) handleTestRequestRequiredStringFloat32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35261,7 +44753,16 @@ func (s *Server) handleTestRequestRequiredStringFloat32Request(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35273,8 +44774,27 @@ func (s *Server) handleTestRequestRequiredStringFloat32Request(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35350,6 +44870,8 @@ func (s *Server) handleTestRequestRequiredStringFloat32Request(args [0]string, a // // POST /test_request_required_string_float32_array func (s *Server) handleTestRequestRequiredStringFloat32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35371,7 +44893,16 @@ func (s *Server) handleTestRequestRequiredStringFloat32ArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35383,8 +44914,27 @@ func (s *Server) handleTestRequestRequiredStringFloat32ArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35460,6 +45010,8 @@ func (s *Server) handleTestRequestRequiredStringFloat32ArrayRequest(args [0]stri // // POST /test_request_required_string_float32_array_array func (s *Server) handleTestRequestRequiredStringFloat32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35481,7 +45033,16 @@ func (s *Server) handleTestRequestRequiredStringFloat32ArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35493,8 +45054,27 @@ func (s *Server) handleTestRequestRequiredStringFloat32ArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35570,6 +45150,8 @@ func (s *Server) handleTestRequestRequiredStringFloat32ArrayArrayRequest(args [0 // // POST /test_request_required_string_float32_nullable func (s *Server) handleTestRequestRequiredStringFloat32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35591,7 +45173,16 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35603,8 +45194,27 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35680,6 +45290,8 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableRequest(args [0]s // // POST /test_request_required_string_float32_nullable_array func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35701,7 +45313,16 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35713,8 +45334,27 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35790,6 +45430,8 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayRequest(args // // POST /test_request_required_string_float32_nullable_array_array func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35811,7 +45453,16 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayArrayRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35823,8 +45474,27 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayArrayRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -35900,6 +45570,8 @@ func (s *Server) handleTestRequestRequiredStringFloat32NullableArrayArrayRequest // // POST /test_request_required_string_float64 func (s *Server) handleTestRequestRequiredStringFloat64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -35921,7 +45593,16 @@ func (s *Server) handleTestRequestRequiredStringFloat64Request(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -35933,8 +45614,27 @@ func (s *Server) handleTestRequestRequiredStringFloat64Request(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36010,6 +45710,8 @@ func (s *Server) handleTestRequestRequiredStringFloat64Request(args [0]string, a // // POST /test_request_required_string_float64_array func (s *Server) handleTestRequestRequiredStringFloat64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36031,7 +45733,16 @@ func (s *Server) handleTestRequestRequiredStringFloat64ArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36043,8 +45754,27 @@ func (s *Server) handleTestRequestRequiredStringFloat64ArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36120,6 +45850,8 @@ func (s *Server) handleTestRequestRequiredStringFloat64ArrayRequest(args [0]stri // // POST /test_request_required_string_float64_array_array func (s *Server) handleTestRequestRequiredStringFloat64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36141,7 +45873,16 @@ func (s *Server) handleTestRequestRequiredStringFloat64ArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36153,8 +45894,27 @@ func (s *Server) handleTestRequestRequiredStringFloat64ArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36230,6 +45990,8 @@ func (s *Server) handleTestRequestRequiredStringFloat64ArrayArrayRequest(args [0 // // POST /test_request_required_string_float64_nullable func (s *Server) handleTestRequestRequiredStringFloat64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36251,7 +46013,16 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36263,8 +46034,27 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36340,6 +46130,8 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableRequest(args [0]s // // POST /test_request_required_string_float64_nullable_array func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36361,7 +46153,16 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36373,8 +46174,27 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36450,6 +46270,8 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayRequest(args // // POST /test_request_required_string_float64_nullable_array_array func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_float64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36471,7 +46293,16 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayArrayRequest startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36483,8 +46314,27 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayArrayRequest var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36560,6 +46410,8 @@ func (s *Server) handleTestRequestRequiredStringFloat64NullableArrayArrayRequest // // POST /test_request_required_string_hostname func (s *Server) handleTestRequestRequiredStringHostnameRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_hostname"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36581,7 +46433,16 @@ func (s *Server) handleTestRequestRequiredStringHostnameRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36593,8 +46454,27 @@ func (s *Server) handleTestRequestRequiredStringHostnameRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36670,6 +46550,8 @@ func (s *Server) handleTestRequestRequiredStringHostnameRequest(args [0]string, // // POST /test_request_required_string_hostname_array func (s *Server) handleTestRequestRequiredStringHostnameArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_hostname_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36691,7 +46573,16 @@ func (s *Server) handleTestRequestRequiredStringHostnameArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36703,8 +46594,27 @@ func (s *Server) handleTestRequestRequiredStringHostnameArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36780,6 +46690,8 @@ func (s *Server) handleTestRequestRequiredStringHostnameArrayRequest(args [0]str // // POST /test_request_required_string_hostname_array_array func (s *Server) handleTestRequestRequiredStringHostnameArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_hostname_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36801,7 +46713,16 @@ func (s *Server) handleTestRequestRequiredStringHostnameArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36813,8 +46734,27 @@ func (s *Server) handleTestRequestRequiredStringHostnameArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -36890,6 +46830,8 @@ func (s *Server) handleTestRequestRequiredStringHostnameArrayArrayRequest(args [ // // POST /test_request_required_string_hostname_nullable func (s *Server) handleTestRequestRequiredStringHostnameNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_hostname_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -36911,7 +46853,16 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -36923,8 +46874,27 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37000,6 +46970,8 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableRequest(args [0] // // POST /test_request_required_string_hostname_nullable_array func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_hostname_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37021,7 +46993,16 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37033,8 +47014,27 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37110,6 +47110,8 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayRequest(arg // // POST /test_request_required_string_hostname_nullable_array_array func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_hostname_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37131,7 +47133,16 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayArrayReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37143,8 +47154,27 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayArrayReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37220,6 +47250,8 @@ func (s *Server) handleTestRequestRequiredStringHostnameNullableArrayArrayReques // // POST /test_request_required_string_ip func (s *Server) handleTestRequestRequiredStringIPRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ip"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37241,7 +47273,16 @@ func (s *Server) handleTestRequestRequiredStringIPRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37253,8 +47294,27 @@ func (s *Server) handleTestRequestRequiredStringIPRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37330,6 +47390,8 @@ func (s *Server) handleTestRequestRequiredStringIPRequest(args [0]string, argsEs // // POST /test_request_required_string_ip_array func (s *Server) handleTestRequestRequiredStringIPArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ip_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37351,7 +47413,16 @@ func (s *Server) handleTestRequestRequiredStringIPArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37363,8 +47434,27 @@ func (s *Server) handleTestRequestRequiredStringIPArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37440,6 +47530,8 @@ func (s *Server) handleTestRequestRequiredStringIPArrayRequest(args [0]string, a // // POST /test_request_required_string_ip_array_array func (s *Server) handleTestRequestRequiredStringIPArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ip_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37461,7 +47553,16 @@ func (s *Server) handleTestRequestRequiredStringIPArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37473,8 +47574,27 @@ func (s *Server) handleTestRequestRequiredStringIPArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37550,6 +47670,8 @@ func (s *Server) handleTestRequestRequiredStringIPArrayArrayRequest(args [0]stri // // POST /test_request_required_string_ip_nullable func (s *Server) handleTestRequestRequiredStringIPNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ip_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37571,7 +47693,16 @@ func (s *Server) handleTestRequestRequiredStringIPNullableRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37583,8 +47714,27 @@ func (s *Server) handleTestRequestRequiredStringIPNullableRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37660,6 +47810,8 @@ func (s *Server) handleTestRequestRequiredStringIPNullableRequest(args [0]string // // POST /test_request_required_string_ip_nullable_array func (s *Server) handleTestRequestRequiredStringIPNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ip_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37681,7 +47833,16 @@ func (s *Server) handleTestRequestRequiredStringIPNullableArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37693,8 +47854,27 @@ func (s *Server) handleTestRequestRequiredStringIPNullableArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37770,6 +47950,8 @@ func (s *Server) handleTestRequestRequiredStringIPNullableArrayRequest(args [0]s // // POST /test_request_required_string_ip_nullable_array_array func (s *Server) handleTestRequestRequiredStringIPNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ip_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37791,7 +47973,16 @@ func (s *Server) handleTestRequestRequiredStringIPNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37803,8 +47994,27 @@ func (s *Server) handleTestRequestRequiredStringIPNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37880,6 +48090,8 @@ func (s *Server) handleTestRequestRequiredStringIPNullableArrayArrayRequest(args // // POST /test_request_required_string_int func (s *Server) handleTestRequestRequiredStringIntRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int"), semconv.HTTPRequestMethodKey.String("POST"), @@ -37901,7 +48113,16 @@ func (s *Server) handleTestRequestRequiredStringIntRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -37913,8 +48134,27 @@ func (s *Server) handleTestRequestRequiredStringIntRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -37990,6 +48230,8 @@ func (s *Server) handleTestRequestRequiredStringIntRequest(args [0]string, argsE // // POST /test_request_required_string_int16 func (s *Server) handleTestRequestRequiredStringInt16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38011,7 +48253,16 @@ func (s *Server) handleTestRequestRequiredStringInt16Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38023,8 +48274,27 @@ func (s *Server) handleTestRequestRequiredStringInt16Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38100,6 +48370,8 @@ func (s *Server) handleTestRequestRequiredStringInt16Request(args [0]string, arg // // POST /test_request_required_string_int16_array func (s *Server) handleTestRequestRequiredStringInt16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38121,7 +48393,16 @@ func (s *Server) handleTestRequestRequiredStringInt16ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38133,8 +48414,27 @@ func (s *Server) handleTestRequestRequiredStringInt16ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38210,6 +48510,8 @@ func (s *Server) handleTestRequestRequiredStringInt16ArrayRequest(args [0]string // // POST /test_request_required_string_int16_array_array func (s *Server) handleTestRequestRequiredStringInt16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38231,7 +48533,16 @@ func (s *Server) handleTestRequestRequiredStringInt16ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38243,8 +48554,27 @@ func (s *Server) handleTestRequestRequiredStringInt16ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38320,6 +48650,8 @@ func (s *Server) handleTestRequestRequiredStringInt16ArrayArrayRequest(args [0]s // // POST /test_request_required_string_int16_nullable func (s *Server) handleTestRequestRequiredStringInt16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38341,7 +48673,16 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38353,8 +48694,27 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38430,6 +48790,8 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableRequest(args [0]str // // POST /test_request_required_string_int16_nullable_array func (s *Server) handleTestRequestRequiredStringInt16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38451,7 +48813,16 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38463,8 +48834,27 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38540,6 +48930,8 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableArrayRequest(args [ // // POST /test_request_required_string_int16_nullable_array_array func (s *Server) handleTestRequestRequiredStringInt16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38561,7 +48953,16 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38573,8 +48974,27 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38650,6 +49070,8 @@ func (s *Server) handleTestRequestRequiredStringInt16NullableArrayArrayRequest(a // // POST /test_request_required_string_int32 func (s *Server) handleTestRequestRequiredStringInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38671,7 +49093,16 @@ func (s *Server) handleTestRequestRequiredStringInt32Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38683,8 +49114,27 @@ func (s *Server) handleTestRequestRequiredStringInt32Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38760,6 +49210,8 @@ func (s *Server) handleTestRequestRequiredStringInt32Request(args [0]string, arg // // POST /test_request_required_string_int32_array func (s *Server) handleTestRequestRequiredStringInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38781,7 +49233,16 @@ func (s *Server) handleTestRequestRequiredStringInt32ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38793,8 +49254,27 @@ func (s *Server) handleTestRequestRequiredStringInt32ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38870,6 +49350,8 @@ func (s *Server) handleTestRequestRequiredStringInt32ArrayRequest(args [0]string // // POST /test_request_required_string_int32_array_array func (s *Server) handleTestRequestRequiredStringInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -38891,7 +49373,16 @@ func (s *Server) handleTestRequestRequiredStringInt32ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -38903,8 +49394,27 @@ func (s *Server) handleTestRequestRequiredStringInt32ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -38980,6 +49490,8 @@ func (s *Server) handleTestRequestRequiredStringInt32ArrayArrayRequest(args [0]s // // POST /test_request_required_string_int32_nullable func (s *Server) handleTestRequestRequiredStringInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39001,7 +49513,16 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39013,8 +49534,27 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39090,6 +49630,8 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableRequest(args [0]str // // POST /test_request_required_string_int32_nullable_array func (s *Server) handleTestRequestRequiredStringInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39111,7 +49653,16 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39123,8 +49674,27 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39200,6 +49770,8 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableArrayRequest(args [ // // POST /test_request_required_string_int32_nullable_array_array func (s *Server) handleTestRequestRequiredStringInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39221,7 +49793,16 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39233,8 +49814,27 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39310,6 +49910,8 @@ func (s *Server) handleTestRequestRequiredStringInt32NullableArrayArrayRequest(a // // POST /test_request_required_string_int64 func (s *Server) handleTestRequestRequiredStringInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39331,7 +49933,16 @@ func (s *Server) handleTestRequestRequiredStringInt64Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39343,8 +49954,27 @@ func (s *Server) handleTestRequestRequiredStringInt64Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39420,6 +50050,8 @@ func (s *Server) handleTestRequestRequiredStringInt64Request(args [0]string, arg // // POST /test_request_required_string_int64_array func (s *Server) handleTestRequestRequiredStringInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39441,7 +50073,16 @@ func (s *Server) handleTestRequestRequiredStringInt64ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39453,8 +50094,27 @@ func (s *Server) handleTestRequestRequiredStringInt64ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39530,6 +50190,8 @@ func (s *Server) handleTestRequestRequiredStringInt64ArrayRequest(args [0]string // // POST /test_request_required_string_int64_array_array func (s *Server) handleTestRequestRequiredStringInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39551,7 +50213,16 @@ func (s *Server) handleTestRequestRequiredStringInt64ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39563,8 +50234,27 @@ func (s *Server) handleTestRequestRequiredStringInt64ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39640,6 +50330,8 @@ func (s *Server) handleTestRequestRequiredStringInt64ArrayArrayRequest(args [0]s // // POST /test_request_required_string_int64_nullable func (s *Server) handleTestRequestRequiredStringInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39661,7 +50353,16 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39673,8 +50374,27 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39750,6 +50470,8 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableRequest(args [0]str // // POST /test_request_required_string_int64_nullable_array func (s *Server) handleTestRequestRequiredStringInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39771,7 +50493,16 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39783,8 +50514,27 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39860,6 +50610,8 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableArrayRequest(args [ // // POST /test_request_required_string_int64_nullable_array_array func (s *Server) handleTestRequestRequiredStringInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39881,7 +50633,16 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -39893,8 +50654,27 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -39970,6 +50750,8 @@ func (s *Server) handleTestRequestRequiredStringInt64NullableArrayArrayRequest(a // // POST /test_request_required_string_int8 func (s *Server) handleTestRequestRequiredStringInt8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -39991,7 +50773,16 @@ func (s *Server) handleTestRequestRequiredStringInt8Request(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40003,8 +50794,27 @@ func (s *Server) handleTestRequestRequiredStringInt8Request(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40080,6 +50890,8 @@ func (s *Server) handleTestRequestRequiredStringInt8Request(args [0]string, args // // POST /test_request_required_string_int8_array func (s *Server) handleTestRequestRequiredStringInt8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40101,7 +50913,16 @@ func (s *Server) handleTestRequestRequiredStringInt8ArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40113,8 +50934,27 @@ func (s *Server) handleTestRequestRequiredStringInt8ArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40190,6 +51030,8 @@ func (s *Server) handleTestRequestRequiredStringInt8ArrayRequest(args [0]string, // // POST /test_request_required_string_int8_array_array func (s *Server) handleTestRequestRequiredStringInt8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40211,7 +51053,16 @@ func (s *Server) handleTestRequestRequiredStringInt8ArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40223,8 +51074,27 @@ func (s *Server) handleTestRequestRequiredStringInt8ArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40300,6 +51170,8 @@ func (s *Server) handleTestRequestRequiredStringInt8ArrayArrayRequest(args [0]st // // POST /test_request_required_string_int8_nullable func (s *Server) handleTestRequestRequiredStringInt8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40321,7 +51193,16 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40333,8 +51214,27 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40410,6 +51310,8 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableRequest(args [0]stri // // POST /test_request_required_string_int8_nullable_array func (s *Server) handleTestRequestRequiredStringInt8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40431,7 +51333,16 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40443,8 +51354,27 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40520,6 +51450,8 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableArrayRequest(args [0 // // POST /test_request_required_string_int8_nullable_array_array func (s *Server) handleTestRequestRequiredStringInt8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40541,7 +51473,16 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40553,8 +51494,27 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40630,6 +51590,8 @@ func (s *Server) handleTestRequestRequiredStringInt8NullableArrayArrayRequest(ar // // POST /test_request_required_string_int_array func (s *Server) handleTestRequestRequiredStringIntArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40651,7 +51613,16 @@ func (s *Server) handleTestRequestRequiredStringIntArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40663,8 +51634,27 @@ func (s *Server) handleTestRequestRequiredStringIntArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40740,6 +51730,8 @@ func (s *Server) handleTestRequestRequiredStringIntArrayRequest(args [0]string, // // POST /test_request_required_string_int_array_array func (s *Server) handleTestRequestRequiredStringIntArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40761,7 +51753,16 @@ func (s *Server) handleTestRequestRequiredStringIntArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40773,8 +51774,27 @@ func (s *Server) handleTestRequestRequiredStringIntArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40850,6 +51870,8 @@ func (s *Server) handleTestRequestRequiredStringIntArrayArrayRequest(args [0]str // // POST /test_request_required_string_int_nullable func (s *Server) handleTestRequestRequiredStringIntNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40871,7 +51893,16 @@ func (s *Server) handleTestRequestRequiredStringIntNullableRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40883,8 +51914,27 @@ func (s *Server) handleTestRequestRequiredStringIntNullableRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -40960,6 +52010,8 @@ func (s *Server) handleTestRequestRequiredStringIntNullableRequest(args [0]strin // // POST /test_request_required_string_int_nullable_array func (s *Server) handleTestRequestRequiredStringIntNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -40981,7 +52033,16 @@ func (s *Server) handleTestRequestRequiredStringIntNullableArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -40993,8 +52054,27 @@ func (s *Server) handleTestRequestRequiredStringIntNullableArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41070,6 +52150,8 @@ func (s *Server) handleTestRequestRequiredStringIntNullableArrayRequest(args [0] // // POST /test_request_required_string_int_nullable_array_array func (s *Server) handleTestRequestRequiredStringIntNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_int_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41091,7 +52173,16 @@ func (s *Server) handleTestRequestRequiredStringIntNullableArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41103,8 +52194,27 @@ func (s *Server) handleTestRequestRequiredStringIntNullableArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41180,6 +52290,8 @@ func (s *Server) handleTestRequestRequiredStringIntNullableArrayArrayRequest(arg // // POST /test_request_required_string_ipv4 func (s *Server) handleTestRequestRequiredStringIpv4Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv4"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41201,7 +52313,16 @@ func (s *Server) handleTestRequestRequiredStringIpv4Request(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41213,8 +52334,27 @@ func (s *Server) handleTestRequestRequiredStringIpv4Request(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41290,6 +52430,8 @@ func (s *Server) handleTestRequestRequiredStringIpv4Request(args [0]string, args // // POST /test_request_required_string_ipv4_array func (s *Server) handleTestRequestRequiredStringIpv4ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv4_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41311,7 +52453,16 @@ func (s *Server) handleTestRequestRequiredStringIpv4ArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41323,8 +52474,27 @@ func (s *Server) handleTestRequestRequiredStringIpv4ArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41400,6 +52570,8 @@ func (s *Server) handleTestRequestRequiredStringIpv4ArrayRequest(args [0]string, // // POST /test_request_required_string_ipv4_array_array func (s *Server) handleTestRequestRequiredStringIpv4ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv4_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41421,7 +52593,16 @@ func (s *Server) handleTestRequestRequiredStringIpv4ArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41433,8 +52614,27 @@ func (s *Server) handleTestRequestRequiredStringIpv4ArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41510,6 +52710,8 @@ func (s *Server) handleTestRequestRequiredStringIpv4ArrayArrayRequest(args [0]st // // POST /test_request_required_string_ipv4_nullable func (s *Server) handleTestRequestRequiredStringIpv4NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv4_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41531,7 +52733,16 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41543,8 +52754,27 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41620,6 +52850,8 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableRequest(args [0]stri // // POST /test_request_required_string_ipv4_nullable_array func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv4_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41641,7 +52873,16 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41653,8 +52894,27 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41730,6 +52990,8 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayRequest(args [0 // // POST /test_request_required_string_ipv4_nullable_array_array func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv4_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41751,7 +53013,16 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41763,8 +53034,27 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41840,6 +53130,8 @@ func (s *Server) handleTestRequestRequiredStringIpv4NullableArrayArrayRequest(ar // // POST /test_request_required_string_ipv6 func (s *Server) handleTestRequestRequiredStringIpv6Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv6"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41861,7 +53153,16 @@ func (s *Server) handleTestRequestRequiredStringIpv6Request(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41873,8 +53174,27 @@ func (s *Server) handleTestRequestRequiredStringIpv6Request(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -41950,6 +53270,8 @@ func (s *Server) handleTestRequestRequiredStringIpv6Request(args [0]string, args // // POST /test_request_required_string_ipv6_array func (s *Server) handleTestRequestRequiredStringIpv6ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv6_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -41971,7 +53293,16 @@ func (s *Server) handleTestRequestRequiredStringIpv6ArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -41983,8 +53314,27 @@ func (s *Server) handleTestRequestRequiredStringIpv6ArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42060,6 +53410,8 @@ func (s *Server) handleTestRequestRequiredStringIpv6ArrayRequest(args [0]string, // // POST /test_request_required_string_ipv6_array_array func (s *Server) handleTestRequestRequiredStringIpv6ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv6_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42081,7 +53433,16 @@ func (s *Server) handleTestRequestRequiredStringIpv6ArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42093,8 +53454,27 @@ func (s *Server) handleTestRequestRequiredStringIpv6ArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42170,6 +53550,8 @@ func (s *Server) handleTestRequestRequiredStringIpv6ArrayArrayRequest(args [0]st // // POST /test_request_required_string_ipv6_nullable func (s *Server) handleTestRequestRequiredStringIpv6NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv6_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42191,7 +53573,16 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42203,8 +53594,27 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42280,6 +53690,8 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableRequest(args [0]stri // // POST /test_request_required_string_ipv6_nullable_array func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv6_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42301,7 +53713,16 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42313,8 +53734,27 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42390,6 +53830,8 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayRequest(args [0 // // POST /test_request_required_string_ipv6_nullable_array_array func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_ipv6_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42411,7 +53853,16 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42423,8 +53874,27 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42500,6 +53970,8 @@ func (s *Server) handleTestRequestRequiredStringIpv6NullableArrayArrayRequest(ar // // POST /test_request_required_string_mac func (s *Server) handleTestRequestRequiredStringMACRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_mac"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42521,7 +53993,16 @@ func (s *Server) handleTestRequestRequiredStringMACRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42533,8 +54014,27 @@ func (s *Server) handleTestRequestRequiredStringMACRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42610,6 +54110,8 @@ func (s *Server) handleTestRequestRequiredStringMACRequest(args [0]string, argsE // // POST /test_request_required_string_mac_array func (s *Server) handleTestRequestRequiredStringMACArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_mac_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42631,7 +54133,16 @@ func (s *Server) handleTestRequestRequiredStringMACArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42643,8 +54154,27 @@ func (s *Server) handleTestRequestRequiredStringMACArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42720,6 +54250,8 @@ func (s *Server) handleTestRequestRequiredStringMACArrayRequest(args [0]string, // // POST /test_request_required_string_mac_array_array func (s *Server) handleTestRequestRequiredStringMACArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_mac_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42741,7 +54273,16 @@ func (s *Server) handleTestRequestRequiredStringMACArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42753,8 +54294,27 @@ func (s *Server) handleTestRequestRequiredStringMACArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42830,6 +54390,8 @@ func (s *Server) handleTestRequestRequiredStringMACArrayArrayRequest(args [0]str // // POST /test_request_required_string_mac_nullable func (s *Server) handleTestRequestRequiredStringMACNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_mac_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42851,7 +54413,16 @@ func (s *Server) handleTestRequestRequiredStringMACNullableRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42863,8 +54434,27 @@ func (s *Server) handleTestRequestRequiredStringMACNullableRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -42940,6 +54530,8 @@ func (s *Server) handleTestRequestRequiredStringMACNullableRequest(args [0]strin // // POST /test_request_required_string_mac_nullable_array func (s *Server) handleTestRequestRequiredStringMACNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_mac_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -42961,7 +54553,16 @@ func (s *Server) handleTestRequestRequiredStringMACNullableArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -42973,8 +54574,27 @@ func (s *Server) handleTestRequestRequiredStringMACNullableArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43050,6 +54670,8 @@ func (s *Server) handleTestRequestRequiredStringMACNullableArrayRequest(args [0] // // POST /test_request_required_string_mac_nullable_array_array func (s *Server) handleTestRequestRequiredStringMACNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_mac_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43071,7 +54693,16 @@ func (s *Server) handleTestRequestRequiredStringMACNullableArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43083,8 +54714,27 @@ func (s *Server) handleTestRequestRequiredStringMACNullableArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43160,6 +54810,8 @@ func (s *Server) handleTestRequestRequiredStringMACNullableArrayArrayRequest(arg // // POST /test_request_required_string_nullable func (s *Server) handleTestRequestRequiredStringNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43181,7 +54833,16 @@ func (s *Server) handleTestRequestRequiredStringNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43193,8 +54854,27 @@ func (s *Server) handleTestRequestRequiredStringNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43270,6 +54950,8 @@ func (s *Server) handleTestRequestRequiredStringNullableRequest(args [0]string, // // POST /test_request_required_string_nullable_array func (s *Server) handleTestRequestRequiredStringNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43291,7 +54973,16 @@ func (s *Server) handleTestRequestRequiredStringNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43303,8 +54994,27 @@ func (s *Server) handleTestRequestRequiredStringNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43380,6 +55090,8 @@ func (s *Server) handleTestRequestRequiredStringNullableArrayRequest(args [0]str // // POST /test_request_required_string_nullable_array_array func (s *Server) handleTestRequestRequiredStringNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43401,7 +55113,16 @@ func (s *Server) handleTestRequestRequiredStringNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43413,8 +55134,27 @@ func (s *Server) handleTestRequestRequiredStringNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43490,6 +55230,8 @@ func (s *Server) handleTestRequestRequiredStringNullableArrayArrayRequest(args [ // // POST /test_request_required_string_password func (s *Server) handleTestRequestRequiredStringPasswordRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_password"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43511,7 +55253,16 @@ func (s *Server) handleTestRequestRequiredStringPasswordRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43523,8 +55274,27 @@ func (s *Server) handleTestRequestRequiredStringPasswordRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43600,6 +55370,8 @@ func (s *Server) handleTestRequestRequiredStringPasswordRequest(args [0]string, // // POST /test_request_required_string_password_array func (s *Server) handleTestRequestRequiredStringPasswordArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_password_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43621,7 +55393,16 @@ func (s *Server) handleTestRequestRequiredStringPasswordArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43633,8 +55414,27 @@ func (s *Server) handleTestRequestRequiredStringPasswordArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43710,6 +55510,8 @@ func (s *Server) handleTestRequestRequiredStringPasswordArrayRequest(args [0]str // // POST /test_request_required_string_password_array_array func (s *Server) handleTestRequestRequiredStringPasswordArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_password_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43731,7 +55533,16 @@ func (s *Server) handleTestRequestRequiredStringPasswordArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43743,8 +55554,27 @@ func (s *Server) handleTestRequestRequiredStringPasswordArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43820,6 +55650,8 @@ func (s *Server) handleTestRequestRequiredStringPasswordArrayArrayRequest(args [ // // POST /test_request_required_string_password_nullable func (s *Server) handleTestRequestRequiredStringPasswordNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_password_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43841,7 +55673,16 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43853,8 +55694,27 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -43930,6 +55790,8 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableRequest(args [0] // // POST /test_request_required_string_password_nullable_array func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_password_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -43951,7 +55813,16 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -43963,8 +55834,27 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44040,6 +55930,8 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayRequest(arg // // POST /test_request_required_string_password_nullable_array_array func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_password_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44061,7 +55953,16 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayArrayReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44073,8 +55974,27 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayArrayReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44150,6 +56070,8 @@ func (s *Server) handleTestRequestRequiredStringPasswordNullableArrayArrayReques // // POST /test_request_required_string_time func (s *Server) handleTestRequestRequiredStringTimeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_time"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44171,7 +56093,16 @@ func (s *Server) handleTestRequestRequiredStringTimeRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44183,8 +56114,27 @@ func (s *Server) handleTestRequestRequiredStringTimeRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44260,6 +56210,8 @@ func (s *Server) handleTestRequestRequiredStringTimeRequest(args [0]string, args // // POST /test_request_required_string_time_array func (s *Server) handleTestRequestRequiredStringTimeArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_time_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44281,7 +56233,16 @@ func (s *Server) handleTestRequestRequiredStringTimeArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44293,8 +56254,27 @@ func (s *Server) handleTestRequestRequiredStringTimeArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44370,6 +56350,8 @@ func (s *Server) handleTestRequestRequiredStringTimeArrayRequest(args [0]string, // // POST /test_request_required_string_time_array_array func (s *Server) handleTestRequestRequiredStringTimeArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_time_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44391,7 +56373,16 @@ func (s *Server) handleTestRequestRequiredStringTimeArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44403,8 +56394,27 @@ func (s *Server) handleTestRequestRequiredStringTimeArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44480,6 +56490,8 @@ func (s *Server) handleTestRequestRequiredStringTimeArrayArrayRequest(args [0]st // // POST /test_request_required_string_time_nullable func (s *Server) handleTestRequestRequiredStringTimeNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_time_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44501,7 +56513,16 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44513,8 +56534,27 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44590,6 +56630,8 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableRequest(args [0]stri // // POST /test_request_required_string_time_nullable_array func (s *Server) handleTestRequestRequiredStringTimeNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_time_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44611,7 +56653,16 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44623,8 +56674,27 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44700,6 +56770,8 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableArrayRequest(args [0 // // POST /test_request_required_string_time_nullable_array_array func (s *Server) handleTestRequestRequiredStringTimeNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_time_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44721,7 +56793,16 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44733,8 +56814,27 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44810,6 +56910,8 @@ func (s *Server) handleTestRequestRequiredStringTimeNullableArrayArrayRequest(ar // // POST /test_request_required_string_uri func (s *Server) handleTestRequestRequiredStringURIRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uri"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44831,7 +56933,16 @@ func (s *Server) handleTestRequestRequiredStringURIRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44843,8 +56954,27 @@ func (s *Server) handleTestRequestRequiredStringURIRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -44920,6 +57050,8 @@ func (s *Server) handleTestRequestRequiredStringURIRequest(args [0]string, argsE // // POST /test_request_required_string_uri_array func (s *Server) handleTestRequestRequiredStringURIArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uri_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -44941,7 +57073,16 @@ func (s *Server) handleTestRequestRequiredStringURIArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -44953,8 +57094,27 @@ func (s *Server) handleTestRequestRequiredStringURIArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45030,6 +57190,8 @@ func (s *Server) handleTestRequestRequiredStringURIArrayRequest(args [0]string, // // POST /test_request_required_string_uri_array_array func (s *Server) handleTestRequestRequiredStringURIArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uri_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45051,7 +57213,16 @@ func (s *Server) handleTestRequestRequiredStringURIArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45063,8 +57234,27 @@ func (s *Server) handleTestRequestRequiredStringURIArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45140,6 +57330,8 @@ func (s *Server) handleTestRequestRequiredStringURIArrayArrayRequest(args [0]str // // POST /test_request_required_string_uri_nullable func (s *Server) handleTestRequestRequiredStringURINullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uri_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45161,7 +57353,16 @@ func (s *Server) handleTestRequestRequiredStringURINullableRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45173,8 +57374,27 @@ func (s *Server) handleTestRequestRequiredStringURINullableRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45250,6 +57470,8 @@ func (s *Server) handleTestRequestRequiredStringURINullableRequest(args [0]strin // // POST /test_request_required_string_uri_nullable_array func (s *Server) handleTestRequestRequiredStringURINullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uri_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45271,7 +57493,16 @@ func (s *Server) handleTestRequestRequiredStringURINullableArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45283,8 +57514,27 @@ func (s *Server) handleTestRequestRequiredStringURINullableArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45360,6 +57610,8 @@ func (s *Server) handleTestRequestRequiredStringURINullableArrayRequest(args [0] // // POST /test_request_required_string_uri_nullable_array_array func (s *Server) handleTestRequestRequiredStringURINullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uri_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45381,7 +57633,16 @@ func (s *Server) handleTestRequestRequiredStringURINullableArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45393,8 +57654,27 @@ func (s *Server) handleTestRequestRequiredStringURINullableArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45470,6 +57750,8 @@ func (s *Server) handleTestRequestRequiredStringURINullableArrayArrayRequest(arg // // POST /test_request_required_string_uuid func (s *Server) handleTestRequestRequiredStringUUIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uuid"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45491,7 +57773,16 @@ func (s *Server) handleTestRequestRequiredStringUUIDRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45503,8 +57794,27 @@ func (s *Server) handleTestRequestRequiredStringUUIDRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45580,6 +57890,8 @@ func (s *Server) handleTestRequestRequiredStringUUIDRequest(args [0]string, args // // POST /test_request_required_string_uuid_array func (s *Server) handleTestRequestRequiredStringUUIDArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uuid_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45601,7 +57913,16 @@ func (s *Server) handleTestRequestRequiredStringUUIDArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45613,8 +57934,27 @@ func (s *Server) handleTestRequestRequiredStringUUIDArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45690,6 +58030,8 @@ func (s *Server) handleTestRequestRequiredStringUUIDArrayRequest(args [0]string, // // POST /test_request_required_string_uuid_array_array func (s *Server) handleTestRequestRequiredStringUUIDArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uuid_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45711,7 +58053,16 @@ func (s *Server) handleTestRequestRequiredStringUUIDArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45723,8 +58074,27 @@ func (s *Server) handleTestRequestRequiredStringUUIDArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45800,6 +58170,8 @@ func (s *Server) handleTestRequestRequiredStringUUIDArrayArrayRequest(args [0]st // // POST /test_request_required_string_uuid_nullable func (s *Server) handleTestRequestRequiredStringUUIDNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uuid_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45821,7 +58193,16 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45833,8 +58214,27 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -45910,6 +58310,8 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableRequest(args [0]stri // // POST /test_request_required_string_uuid_nullable_array func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uuid_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45931,7 +58333,16 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -45943,8 +58354,27 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46020,6 +58450,8 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayRequest(args [0 // // POST /test_request_required_string_uuid_nullable_array_array func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uuid_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46041,7 +58473,16 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46053,8 +58494,27 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46130,6 +58590,8 @@ func (s *Server) handleTestRequestRequiredStringUUIDNullableArrayArrayRequest(ar // // POST /test_request_required_string_uint func (s *Server) handleTestRequestRequiredStringUintRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46151,7 +58613,16 @@ func (s *Server) handleTestRequestRequiredStringUintRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46163,8 +58634,27 @@ func (s *Server) handleTestRequestRequiredStringUintRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46240,6 +58730,8 @@ func (s *Server) handleTestRequestRequiredStringUintRequest(args [0]string, args // // POST /test_request_required_string_uint16 func (s *Server) handleTestRequestRequiredStringUint16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46261,7 +58753,16 @@ func (s *Server) handleTestRequestRequiredStringUint16Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46273,8 +58774,27 @@ func (s *Server) handleTestRequestRequiredStringUint16Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46350,6 +58870,8 @@ func (s *Server) handleTestRequestRequiredStringUint16Request(args [0]string, ar // // POST /test_request_required_string_uint16_array func (s *Server) handleTestRequestRequiredStringUint16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46371,7 +58893,16 @@ func (s *Server) handleTestRequestRequiredStringUint16ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46383,8 +58914,27 @@ func (s *Server) handleTestRequestRequiredStringUint16ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46460,6 +59010,8 @@ func (s *Server) handleTestRequestRequiredStringUint16ArrayRequest(args [0]strin // // POST /test_request_required_string_uint16_array_array func (s *Server) handleTestRequestRequiredStringUint16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46481,7 +59033,16 @@ func (s *Server) handleTestRequestRequiredStringUint16ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46493,8 +59054,27 @@ func (s *Server) handleTestRequestRequiredStringUint16ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46570,6 +59150,8 @@ func (s *Server) handleTestRequestRequiredStringUint16ArrayArrayRequest(args [0] // // POST /test_request_required_string_uint16_nullable func (s *Server) handleTestRequestRequiredStringUint16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46591,7 +59173,16 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46603,8 +59194,27 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46680,6 +59290,8 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableRequest(args [0]st // // POST /test_request_required_string_uint16_nullable_array func (s *Server) handleTestRequestRequiredStringUint16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46701,7 +59313,16 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46713,8 +59334,27 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46790,6 +59430,8 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableArrayRequest(args // // POST /test_request_required_string_uint16_nullable_array_array func (s *Server) handleTestRequestRequiredStringUint16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46811,7 +59453,16 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46823,8 +59474,27 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -46900,6 +59570,8 @@ func (s *Server) handleTestRequestRequiredStringUint16NullableArrayArrayRequest( // // POST /test_request_required_string_uint32 func (s *Server) handleTestRequestRequiredStringUint32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -46921,7 +59593,16 @@ func (s *Server) handleTestRequestRequiredStringUint32Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -46933,8 +59614,27 @@ func (s *Server) handleTestRequestRequiredStringUint32Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47010,6 +59710,8 @@ func (s *Server) handleTestRequestRequiredStringUint32Request(args [0]string, ar // // POST /test_request_required_string_uint32_array func (s *Server) handleTestRequestRequiredStringUint32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47031,7 +59733,16 @@ func (s *Server) handleTestRequestRequiredStringUint32ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47043,8 +59754,27 @@ func (s *Server) handleTestRequestRequiredStringUint32ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47120,6 +59850,8 @@ func (s *Server) handleTestRequestRequiredStringUint32ArrayRequest(args [0]strin // // POST /test_request_required_string_uint32_array_array func (s *Server) handleTestRequestRequiredStringUint32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47141,7 +59873,16 @@ func (s *Server) handleTestRequestRequiredStringUint32ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47153,8 +59894,27 @@ func (s *Server) handleTestRequestRequiredStringUint32ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47230,6 +59990,8 @@ func (s *Server) handleTestRequestRequiredStringUint32ArrayArrayRequest(args [0] // // POST /test_request_required_string_uint32_nullable func (s *Server) handleTestRequestRequiredStringUint32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47251,7 +60013,16 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47263,8 +60034,27 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47340,6 +60130,8 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableRequest(args [0]st // // POST /test_request_required_string_uint32_nullable_array func (s *Server) handleTestRequestRequiredStringUint32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47361,7 +60153,16 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47373,8 +60174,27 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47450,6 +60270,8 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableArrayRequest(args // // POST /test_request_required_string_uint32_nullable_array_array func (s *Server) handleTestRequestRequiredStringUint32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47471,7 +60293,16 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47483,8 +60314,27 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47560,6 +60410,8 @@ func (s *Server) handleTestRequestRequiredStringUint32NullableArrayArrayRequest( // // POST /test_request_required_string_uint64 func (s *Server) handleTestRequestRequiredStringUint64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47581,7 +60433,16 @@ func (s *Server) handleTestRequestRequiredStringUint64Request(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47593,8 +60454,27 @@ func (s *Server) handleTestRequestRequiredStringUint64Request(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47670,6 +60550,8 @@ func (s *Server) handleTestRequestRequiredStringUint64Request(args [0]string, ar // // POST /test_request_required_string_uint64_array func (s *Server) handleTestRequestRequiredStringUint64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47691,7 +60573,16 @@ func (s *Server) handleTestRequestRequiredStringUint64ArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47703,8 +60594,27 @@ func (s *Server) handleTestRequestRequiredStringUint64ArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47780,6 +60690,8 @@ func (s *Server) handleTestRequestRequiredStringUint64ArrayRequest(args [0]strin // // POST /test_request_required_string_uint64_array_array func (s *Server) handleTestRequestRequiredStringUint64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47801,7 +60713,16 @@ func (s *Server) handleTestRequestRequiredStringUint64ArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47813,8 +60734,27 @@ func (s *Server) handleTestRequestRequiredStringUint64ArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -47890,6 +60830,8 @@ func (s *Server) handleTestRequestRequiredStringUint64ArrayArrayRequest(args [0] // // POST /test_request_required_string_uint64_nullable func (s *Server) handleTestRequestRequiredStringUint64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47911,7 +60853,16 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -47923,8 +60874,27 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48000,6 +60970,8 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableRequest(args [0]st // // POST /test_request_required_string_uint64_nullable_array func (s *Server) handleTestRequestRequiredStringUint64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48021,7 +60993,16 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48033,8 +61014,27 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48110,6 +61110,8 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableArrayRequest(args // // POST /test_request_required_string_uint64_nullable_array_array func (s *Server) handleTestRequestRequiredStringUint64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48131,7 +61133,16 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableArrayArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48143,8 +61154,27 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableArrayArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48220,6 +61250,8 @@ func (s *Server) handleTestRequestRequiredStringUint64NullableArrayArrayRequest( // // POST /test_request_required_string_uint8 func (s *Server) handleTestRequestRequiredStringUint8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48241,7 +61273,16 @@ func (s *Server) handleTestRequestRequiredStringUint8Request(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48253,8 +61294,27 @@ func (s *Server) handleTestRequestRequiredStringUint8Request(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48330,6 +61390,8 @@ func (s *Server) handleTestRequestRequiredStringUint8Request(args [0]string, arg // // POST /test_request_required_string_uint8_array func (s *Server) handleTestRequestRequiredStringUint8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48351,7 +61413,16 @@ func (s *Server) handleTestRequestRequiredStringUint8ArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48363,8 +61434,27 @@ func (s *Server) handleTestRequestRequiredStringUint8ArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48440,6 +61530,8 @@ func (s *Server) handleTestRequestRequiredStringUint8ArrayRequest(args [0]string // // POST /test_request_required_string_uint8_array_array func (s *Server) handleTestRequestRequiredStringUint8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48461,7 +61553,16 @@ func (s *Server) handleTestRequestRequiredStringUint8ArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48473,8 +61574,27 @@ func (s *Server) handleTestRequestRequiredStringUint8ArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48550,6 +61670,8 @@ func (s *Server) handleTestRequestRequiredStringUint8ArrayArrayRequest(args [0]s // // POST /test_request_required_string_uint8_nullable func (s *Server) handleTestRequestRequiredStringUint8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48571,7 +61693,16 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48583,8 +61714,27 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48660,6 +61810,8 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableRequest(args [0]str // // POST /test_request_required_string_uint8_nullable_array func (s *Server) handleTestRequestRequiredStringUint8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48681,7 +61833,16 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48693,8 +61854,27 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48770,6 +61950,8 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableArrayRequest(args [ // // POST /test_request_required_string_uint8_nullable_array_array func (s *Server) handleTestRequestRequiredStringUint8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48791,7 +61973,16 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48803,8 +61994,27 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48880,6 +62090,8 @@ func (s *Server) handleTestRequestRequiredStringUint8NullableArrayArrayRequest(a // // POST /test_request_required_string_uint_array func (s *Server) handleTestRequestRequiredStringUintArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -48901,7 +62113,16 @@ func (s *Server) handleTestRequestRequiredStringUintArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -48913,8 +62134,27 @@ func (s *Server) handleTestRequestRequiredStringUintArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -48990,6 +62230,8 @@ func (s *Server) handleTestRequestRequiredStringUintArrayRequest(args [0]string, // // POST /test_request_required_string_uint_array_array func (s *Server) handleTestRequestRequiredStringUintArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49011,7 +62253,16 @@ func (s *Server) handleTestRequestRequiredStringUintArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49023,8 +62274,27 @@ func (s *Server) handleTestRequestRequiredStringUintArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49100,6 +62370,8 @@ func (s *Server) handleTestRequestRequiredStringUintArrayArrayRequest(args [0]st // // POST /test_request_required_string_uint_nullable func (s *Server) handleTestRequestRequiredStringUintNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49121,7 +62393,16 @@ func (s *Server) handleTestRequestRequiredStringUintNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49133,8 +62414,27 @@ func (s *Server) handleTestRequestRequiredStringUintNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49210,6 +62510,8 @@ func (s *Server) handleTestRequestRequiredStringUintNullableRequest(args [0]stri // // POST /test_request_required_string_uint_nullable_array func (s *Server) handleTestRequestRequiredStringUintNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49231,7 +62533,16 @@ func (s *Server) handleTestRequestRequiredStringUintNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49243,8 +62554,27 @@ func (s *Server) handleTestRequestRequiredStringUintNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49320,6 +62650,8 @@ func (s *Server) handleTestRequestRequiredStringUintNullableArrayRequest(args [0 // // POST /test_request_required_string_uint_nullable_array_array func (s *Server) handleTestRequestRequiredStringUintNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_uint_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49341,7 +62673,16 @@ func (s *Server) handleTestRequestRequiredStringUintNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49353,8 +62694,27 @@ func (s *Server) handleTestRequestRequiredStringUintNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49430,6 +62790,8 @@ func (s *Server) handleTestRequestRequiredStringUintNullableArrayArrayRequest(ar // // POST /test_request_required_string_unix func (s *Server) handleTestRequestRequiredStringUnixRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49451,7 +62813,16 @@ func (s *Server) handleTestRequestRequiredStringUnixRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49463,8 +62834,27 @@ func (s *Server) handleTestRequestRequiredStringUnixRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49540,6 +62930,8 @@ func (s *Server) handleTestRequestRequiredStringUnixRequest(args [0]string, args // // POST /test_request_required_string_unix_array func (s *Server) handleTestRequestRequiredStringUnixArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49561,7 +62953,16 @@ func (s *Server) handleTestRequestRequiredStringUnixArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49573,8 +62974,27 @@ func (s *Server) handleTestRequestRequiredStringUnixArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49650,6 +63070,8 @@ func (s *Server) handleTestRequestRequiredStringUnixArrayRequest(args [0]string, // // POST /test_request_required_string_unix_array_array func (s *Server) handleTestRequestRequiredStringUnixArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49671,7 +63093,16 @@ func (s *Server) handleTestRequestRequiredStringUnixArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49683,8 +63114,27 @@ func (s *Server) handleTestRequestRequiredStringUnixArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49760,6 +63210,8 @@ func (s *Server) handleTestRequestRequiredStringUnixArrayArrayRequest(args [0]st // // POST /test_request_required_string_unix-micro func (s *Server) handleTestRequestRequiredStringUnixMicroRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-micro"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49781,7 +63233,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49793,8 +63254,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49870,6 +63350,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroRequest(args [0]string, // // POST /test_request_required_string_unix-micro_array func (s *Server) handleTestRequestRequiredStringUnixMicroArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-micro_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -49891,7 +63373,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -49903,8 +63394,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -49980,6 +63490,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroArrayRequest(args [0]st // // POST /test_request_required_string_unix-micro_array_array func (s *Server) handleTestRequestRequiredStringUnixMicroArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-micro_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50001,7 +63513,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50013,8 +63534,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50090,6 +63630,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroArrayArrayRequest(args // // POST /test_request_required_string_unix-micro_nullable func (s *Server) handleTestRequestRequiredStringUnixMicroNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-micro_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50111,7 +63653,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50123,8 +63674,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50200,6 +63770,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableRequest(args [0 // // POST /test_request_required_string_unix-micro_nullable_array func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-micro_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50221,7 +63793,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50233,8 +63814,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50310,6 +63910,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayRequest(ar // // POST /test_request_required_string_unix-micro_nullable_array_array func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-micro_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50331,7 +63933,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayArrayReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50343,8 +63954,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayArrayReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50420,6 +64050,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMicroNullableArrayArrayReque // // POST /test_request_required_string_unix-milli func (s *Server) handleTestRequestRequiredStringUnixMilliRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-milli"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50441,7 +64073,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50453,8 +64094,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50530,6 +64190,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliRequest(args [0]string, // // POST /test_request_required_string_unix-milli_array func (s *Server) handleTestRequestRequiredStringUnixMilliArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-milli_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50551,7 +64213,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50563,8 +64234,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50640,6 +64330,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliArrayRequest(args [0]st // // POST /test_request_required_string_unix-milli_array_array func (s *Server) handleTestRequestRequiredStringUnixMilliArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-milli_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50661,7 +64353,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50673,8 +64374,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50750,6 +64470,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliArrayArrayRequest(args // // POST /test_request_required_string_unix-milli_nullable func (s *Server) handleTestRequestRequiredStringUnixMilliNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-milli_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50771,7 +64493,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50783,8 +64514,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50860,6 +64610,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableRequest(args [0 // // POST /test_request_required_string_unix-milli_nullable_array func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-milli_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50881,7 +64633,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -50893,8 +64654,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -50970,6 +64750,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayRequest(ar // // POST /test_request_required_string_unix-milli_nullable_array_array func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-milli_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -50991,7 +64773,16 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayArrayReque startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51003,8 +64794,27 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayArrayReque var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51080,6 +64890,8 @@ func (s *Server) handleTestRequestRequiredStringUnixMilliNullableArrayArrayReque // // POST /test_request_required_string_unix-nano func (s *Server) handleTestRequestRequiredStringUnixNanoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-nano"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51101,7 +64913,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51113,8 +64934,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51190,6 +65030,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoRequest(args [0]string, // // POST /test_request_required_string_unix-nano_array func (s *Server) handleTestRequestRequiredStringUnixNanoArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-nano_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51211,7 +65053,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51223,8 +65074,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51300,6 +65170,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoArrayRequest(args [0]str // // POST /test_request_required_string_unix-nano_array_array func (s *Server) handleTestRequestRequiredStringUnixNanoArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-nano_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51321,7 +65193,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51333,8 +65214,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51410,6 +65310,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoArrayArrayRequest(args [ // // POST /test_request_required_string_unix-nano_nullable func (s *Server) handleTestRequestRequiredStringUnixNanoNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-nano_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51431,7 +65333,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51443,8 +65354,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51520,6 +65450,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableRequest(args [0] // // POST /test_request_required_string_unix-nano_nullable_array func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-nano_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51541,7 +65473,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51553,8 +65494,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51630,6 +65590,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayRequest(arg // // POST /test_request_required_string_unix-nano_nullable_array_array func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-nano_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51651,7 +65613,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayArrayReques startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51663,8 +65634,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayArrayReques var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51740,6 +65730,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNanoNullableArrayArrayReques // // POST /test_request_required_string_unix_nullable func (s *Server) handleTestRequestRequiredStringUnixNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51761,7 +65753,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51773,8 +65774,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51850,6 +65870,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableRequest(args [0]stri // // POST /test_request_required_string_unix_nullable_array func (s *Server) handleTestRequestRequiredStringUnixNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51871,7 +65893,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51883,8 +65914,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -51960,6 +66010,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableArrayRequest(args [0 // // POST /test_request_required_string_unix_nullable_array_array func (s *Server) handleTestRequestRequiredStringUnixNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -51981,7 +66033,16 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -51993,8 +66054,27 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52070,6 +66150,8 @@ func (s *Server) handleTestRequestRequiredStringUnixNullableArrayArrayRequest(ar // // POST /test_request_required_string_unix-seconds func (s *Server) handleTestRequestRequiredStringUnixSecondsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-seconds"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52091,7 +66173,16 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52103,8 +66194,27 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52180,6 +66290,8 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsRequest(args [0]strin // // POST /test_request_required_string_unix-seconds_array func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-seconds_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52201,7 +66313,16 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52213,8 +66334,27 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52290,6 +66430,8 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayRequest(args [0] // // POST /test_request_required_string_unix-seconds_array_array func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-seconds_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52311,7 +66453,16 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52323,8 +66474,27 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52400,6 +66570,8 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsArrayArrayRequest(arg // // POST /test_request_required_string_unix-seconds_nullable func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-seconds_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52421,7 +66593,16 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52433,8 +66614,27 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52510,6 +66710,8 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableRequest(args // // POST /test_request_required_string_unix-seconds_nullable_array func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-seconds_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52531,7 +66733,16 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayRequest( startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52543,8 +66754,27 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayRequest( var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52620,6 +66850,8 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayRequest( // // POST /test_request_required_string_unix-seconds_nullable_array_array func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_required_string_unix-seconds_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52641,7 +66873,16 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayArrayReq startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52653,8 +66894,27 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayArrayReq var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52730,6 +66990,8 @@ func (s *Server) handleTestRequestRequiredStringUnixSecondsNullableArrayArrayReq // // POST /test_request_string func (s *Server) handleTestRequestStringRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52751,7 +67013,16 @@ func (s *Server) handleTestRequestStringRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52763,8 +67034,27 @@ func (s *Server) handleTestRequestStringRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52840,6 +67130,8 @@ func (s *Server) handleTestRequestStringRequest(args [0]string, argsEscaped bool // // POST /test_request_string_array func (s *Server) handleTestRequestStringArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52861,7 +67153,16 @@ func (s *Server) handleTestRequestStringArrayRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52873,8 +67174,27 @@ func (s *Server) handleTestRequestStringArrayRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -52950,6 +67270,8 @@ func (s *Server) handleTestRequestStringArrayRequest(args [0]string, argsEscaped // // POST /test_request_string_array_array func (s *Server) handleTestRequestStringArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -52971,7 +67293,16 @@ func (s *Server) handleTestRequestStringArrayArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -52983,8 +67314,27 @@ func (s *Server) handleTestRequestStringArrayArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53060,6 +67410,8 @@ func (s *Server) handleTestRequestStringArrayArrayRequest(args [0]string, argsEs // // POST /test_request_string_base64 func (s *Server) handleTestRequestStringBase64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_base64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53081,7 +67433,16 @@ func (s *Server) handleTestRequestStringBase64Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53093,8 +67454,27 @@ func (s *Server) handleTestRequestStringBase64Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53170,6 +67550,8 @@ func (s *Server) handleTestRequestStringBase64Request(args [0]string, argsEscape // // POST /test_request_string_base64_array func (s *Server) handleTestRequestStringBase64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_base64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53191,7 +67573,16 @@ func (s *Server) handleTestRequestStringBase64ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53203,8 +67594,27 @@ func (s *Server) handleTestRequestStringBase64ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53280,6 +67690,8 @@ func (s *Server) handleTestRequestStringBase64ArrayRequest(args [0]string, argsE // // POST /test_request_string_base64_array_array func (s *Server) handleTestRequestStringBase64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_base64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53301,7 +67713,16 @@ func (s *Server) handleTestRequestStringBase64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53313,8 +67734,27 @@ func (s *Server) handleTestRequestStringBase64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53390,6 +67830,8 @@ func (s *Server) handleTestRequestStringBase64ArrayArrayRequest(args [0]string, // // POST /test_request_string_base64_nullable func (s *Server) handleTestRequestStringBase64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_base64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53411,7 +67853,16 @@ func (s *Server) handleTestRequestStringBase64NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53423,8 +67874,27 @@ func (s *Server) handleTestRequestStringBase64NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53500,6 +67970,8 @@ func (s *Server) handleTestRequestStringBase64NullableRequest(args [0]string, ar // // POST /test_request_string_base64_nullable_array func (s *Server) handleTestRequestStringBase64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_base64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53521,7 +67993,16 @@ func (s *Server) handleTestRequestStringBase64NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53533,8 +68014,27 @@ func (s *Server) handleTestRequestStringBase64NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53610,6 +68110,8 @@ func (s *Server) handleTestRequestStringBase64NullableArrayRequest(args [0]strin // // POST /test_request_string_base64_nullable_array_array func (s *Server) handleTestRequestStringBase64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_base64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53631,7 +68133,16 @@ func (s *Server) handleTestRequestStringBase64NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53643,8 +68154,27 @@ func (s *Server) handleTestRequestStringBase64NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53720,6 +68250,8 @@ func (s *Server) handleTestRequestStringBase64NullableArrayArrayRequest(args [0] // // POST /test_request_string_binary func (s *Server) handleTestRequestStringBinaryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_binary"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53741,7 +68273,16 @@ func (s *Server) handleTestRequestStringBinaryRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53753,8 +68294,27 @@ func (s *Server) handleTestRequestStringBinaryRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53830,6 +68390,8 @@ func (s *Server) handleTestRequestStringBinaryRequest(args [0]string, argsEscape // // POST /test_request_string_binary_array func (s *Server) handleTestRequestStringBinaryArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_binary_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53851,7 +68413,16 @@ func (s *Server) handleTestRequestStringBinaryArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53863,8 +68434,27 @@ func (s *Server) handleTestRequestStringBinaryArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -53940,6 +68530,8 @@ func (s *Server) handleTestRequestStringBinaryArrayRequest(args [0]string, argsE // // POST /test_request_string_binary_array_array func (s *Server) handleTestRequestStringBinaryArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_binary_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -53961,7 +68553,16 @@ func (s *Server) handleTestRequestStringBinaryArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -53973,8 +68574,27 @@ func (s *Server) handleTestRequestStringBinaryArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54050,6 +68670,8 @@ func (s *Server) handleTestRequestStringBinaryArrayArrayRequest(args [0]string, // // POST /test_request_string_binary_nullable func (s *Server) handleTestRequestStringBinaryNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_binary_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54071,7 +68693,16 @@ func (s *Server) handleTestRequestStringBinaryNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54083,8 +68714,27 @@ func (s *Server) handleTestRequestStringBinaryNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54160,6 +68810,8 @@ func (s *Server) handleTestRequestStringBinaryNullableRequest(args [0]string, ar // // POST /test_request_string_binary_nullable_array func (s *Server) handleTestRequestStringBinaryNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_binary_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54181,7 +68833,16 @@ func (s *Server) handleTestRequestStringBinaryNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54193,8 +68854,27 @@ func (s *Server) handleTestRequestStringBinaryNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54270,6 +68950,8 @@ func (s *Server) handleTestRequestStringBinaryNullableArrayRequest(args [0]strin // // POST /test_request_string_binary_nullable_array_array func (s *Server) handleTestRequestStringBinaryNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_binary_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54291,7 +68973,16 @@ func (s *Server) handleTestRequestStringBinaryNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54303,8 +68994,27 @@ func (s *Server) handleTestRequestStringBinaryNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54380,6 +69090,8 @@ func (s *Server) handleTestRequestStringBinaryNullableArrayArrayRequest(args [0] // // POST /test_request_string_byte func (s *Server) handleTestRequestStringByteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_byte"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54401,7 +69113,16 @@ func (s *Server) handleTestRequestStringByteRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54413,8 +69134,27 @@ func (s *Server) handleTestRequestStringByteRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54490,6 +69230,8 @@ func (s *Server) handleTestRequestStringByteRequest(args [0]string, argsEscaped // // POST /test_request_string_byte_array func (s *Server) handleTestRequestStringByteArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_byte_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54511,7 +69253,16 @@ func (s *Server) handleTestRequestStringByteArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54523,8 +69274,27 @@ func (s *Server) handleTestRequestStringByteArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54600,6 +69370,8 @@ func (s *Server) handleTestRequestStringByteArrayRequest(args [0]string, argsEsc // // POST /test_request_string_byte_array_array func (s *Server) handleTestRequestStringByteArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_byte_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54621,7 +69393,16 @@ func (s *Server) handleTestRequestStringByteArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54633,8 +69414,27 @@ func (s *Server) handleTestRequestStringByteArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54710,6 +69510,8 @@ func (s *Server) handleTestRequestStringByteArrayArrayRequest(args [0]string, ar // // POST /test_request_string_byte_nullable func (s *Server) handleTestRequestStringByteNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_byte_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54731,7 +69533,16 @@ func (s *Server) handleTestRequestStringByteNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54743,8 +69554,27 @@ func (s *Server) handleTestRequestStringByteNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54820,6 +69650,8 @@ func (s *Server) handleTestRequestStringByteNullableRequest(args [0]string, args // // POST /test_request_string_byte_nullable_array func (s *Server) handleTestRequestStringByteNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_byte_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54841,7 +69673,16 @@ func (s *Server) handleTestRequestStringByteNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54853,8 +69694,27 @@ func (s *Server) handleTestRequestStringByteNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -54930,6 +69790,8 @@ func (s *Server) handleTestRequestStringByteNullableArrayRequest(args [0]string, // // POST /test_request_string_byte_nullable_array_array func (s *Server) handleTestRequestStringByteNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_byte_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -54951,7 +69813,16 @@ func (s *Server) handleTestRequestStringByteNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54963,8 +69834,27 @@ func (s *Server) handleTestRequestStringByteNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55040,6 +69930,8 @@ func (s *Server) handleTestRequestStringByteNullableArrayArrayRequest(args [0]st // // POST /test_request_string_date func (s *Server) handleTestRequestStringDateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55061,7 +69953,16 @@ func (s *Server) handleTestRequestStringDateRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55073,8 +69974,27 @@ func (s *Server) handleTestRequestStringDateRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55150,6 +70070,8 @@ func (s *Server) handleTestRequestStringDateRequest(args [0]string, argsEscaped // // POST /test_request_string_date_array func (s *Server) handleTestRequestStringDateArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55171,7 +70093,16 @@ func (s *Server) handleTestRequestStringDateArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55183,8 +70114,27 @@ func (s *Server) handleTestRequestStringDateArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55260,6 +70210,8 @@ func (s *Server) handleTestRequestStringDateArrayRequest(args [0]string, argsEsc // // POST /test_request_string_date_array_array func (s *Server) handleTestRequestStringDateArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55281,7 +70233,16 @@ func (s *Server) handleTestRequestStringDateArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55293,8 +70254,27 @@ func (s *Server) handleTestRequestStringDateArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55370,6 +70350,8 @@ func (s *Server) handleTestRequestStringDateArrayArrayRequest(args [0]string, ar // // POST /test_request_string_date_nullable func (s *Server) handleTestRequestStringDateNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55391,7 +70373,16 @@ func (s *Server) handleTestRequestStringDateNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55403,8 +70394,27 @@ func (s *Server) handleTestRequestStringDateNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55480,6 +70490,8 @@ func (s *Server) handleTestRequestStringDateNullableRequest(args [0]string, args // // POST /test_request_string_date_nullable_array func (s *Server) handleTestRequestStringDateNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55501,7 +70513,16 @@ func (s *Server) handleTestRequestStringDateNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55513,8 +70534,27 @@ func (s *Server) handleTestRequestStringDateNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55590,6 +70630,8 @@ func (s *Server) handleTestRequestStringDateNullableArrayRequest(args [0]string, // // POST /test_request_string_date_nullable_array_array func (s *Server) handleTestRequestStringDateNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55611,7 +70653,16 @@ func (s *Server) handleTestRequestStringDateNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55623,8 +70674,27 @@ func (s *Server) handleTestRequestStringDateNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55700,6 +70770,8 @@ func (s *Server) handleTestRequestStringDateNullableArrayArrayRequest(args [0]st // // POST /test_request_string_date-time func (s *Server) handleTestRequestStringDateTimeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date-time"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55721,7 +70793,16 @@ func (s *Server) handleTestRequestStringDateTimeRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55733,8 +70814,27 @@ func (s *Server) handleTestRequestStringDateTimeRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55810,6 +70910,8 @@ func (s *Server) handleTestRequestStringDateTimeRequest(args [0]string, argsEsca // // POST /test_request_string_date-time_array func (s *Server) handleTestRequestStringDateTimeArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date-time_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55831,7 +70933,16 @@ func (s *Server) handleTestRequestStringDateTimeArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55843,8 +70954,27 @@ func (s *Server) handleTestRequestStringDateTimeArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -55920,6 +71050,8 @@ func (s *Server) handleTestRequestStringDateTimeArrayRequest(args [0]string, arg // // POST /test_request_string_date-time_array_array func (s *Server) handleTestRequestStringDateTimeArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date-time_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -55941,7 +71073,16 @@ func (s *Server) handleTestRequestStringDateTimeArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55953,8 +71094,27 @@ func (s *Server) handleTestRequestStringDateTimeArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56030,6 +71190,8 @@ func (s *Server) handleTestRequestStringDateTimeArrayArrayRequest(args [0]string // // POST /test_request_string_date-time_nullable func (s *Server) handleTestRequestStringDateTimeNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date-time_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56051,7 +71213,16 @@ func (s *Server) handleTestRequestStringDateTimeNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56063,8 +71234,27 @@ func (s *Server) handleTestRequestStringDateTimeNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56140,6 +71330,8 @@ func (s *Server) handleTestRequestStringDateTimeNullableRequest(args [0]string, // // POST /test_request_string_date-time_nullable_array func (s *Server) handleTestRequestStringDateTimeNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date-time_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56161,7 +71353,16 @@ func (s *Server) handleTestRequestStringDateTimeNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56173,8 +71374,27 @@ func (s *Server) handleTestRequestStringDateTimeNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56250,6 +71470,8 @@ func (s *Server) handleTestRequestStringDateTimeNullableArrayRequest(args [0]str // // POST /test_request_string_date-time_nullable_array_array func (s *Server) handleTestRequestStringDateTimeNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_date-time_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56271,7 +71493,16 @@ func (s *Server) handleTestRequestStringDateTimeNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56283,8 +71514,27 @@ func (s *Server) handleTestRequestStringDateTimeNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56360,6 +71610,8 @@ func (s *Server) handleTestRequestStringDateTimeNullableArrayArrayRequest(args [ // // POST /test_request_string_duration func (s *Server) handleTestRequestStringDurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_duration"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56381,7 +71633,16 @@ func (s *Server) handleTestRequestStringDurationRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56393,8 +71654,27 @@ func (s *Server) handleTestRequestStringDurationRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56470,6 +71750,8 @@ func (s *Server) handleTestRequestStringDurationRequest(args [0]string, argsEsca // // POST /test_request_string_duration_array func (s *Server) handleTestRequestStringDurationArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_duration_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56491,7 +71773,16 @@ func (s *Server) handleTestRequestStringDurationArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56503,8 +71794,27 @@ func (s *Server) handleTestRequestStringDurationArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56580,6 +71890,8 @@ func (s *Server) handleTestRequestStringDurationArrayRequest(args [0]string, arg // // POST /test_request_string_duration_array_array func (s *Server) handleTestRequestStringDurationArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_duration_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56601,7 +71913,16 @@ func (s *Server) handleTestRequestStringDurationArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56613,8 +71934,27 @@ func (s *Server) handleTestRequestStringDurationArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56690,6 +72030,8 @@ func (s *Server) handleTestRequestStringDurationArrayArrayRequest(args [0]string // // POST /test_request_string_duration_nullable func (s *Server) handleTestRequestStringDurationNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_duration_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56711,7 +72053,16 @@ func (s *Server) handleTestRequestStringDurationNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56723,8 +72074,27 @@ func (s *Server) handleTestRequestStringDurationNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56800,6 +72170,8 @@ func (s *Server) handleTestRequestStringDurationNullableRequest(args [0]string, // // POST /test_request_string_duration_nullable_array func (s *Server) handleTestRequestStringDurationNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_duration_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56821,7 +72193,16 @@ func (s *Server) handleTestRequestStringDurationNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56833,8 +72214,27 @@ func (s *Server) handleTestRequestStringDurationNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -56910,6 +72310,8 @@ func (s *Server) handleTestRequestStringDurationNullableArrayRequest(args [0]str // // POST /test_request_string_duration_nullable_array_array func (s *Server) handleTestRequestStringDurationNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_duration_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -56931,7 +72333,16 @@ func (s *Server) handleTestRequestStringDurationNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56943,8 +72354,27 @@ func (s *Server) handleTestRequestStringDurationNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57020,6 +72450,8 @@ func (s *Server) handleTestRequestStringDurationNullableArrayArrayRequest(args [ // // POST /test_request_string_email func (s *Server) handleTestRequestStringEmailRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_email"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57041,7 +72473,16 @@ func (s *Server) handleTestRequestStringEmailRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57053,8 +72494,27 @@ func (s *Server) handleTestRequestStringEmailRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57130,6 +72590,8 @@ func (s *Server) handleTestRequestStringEmailRequest(args [0]string, argsEscaped // // POST /test_request_string_email_array func (s *Server) handleTestRequestStringEmailArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_email_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57151,7 +72613,16 @@ func (s *Server) handleTestRequestStringEmailArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57163,8 +72634,27 @@ func (s *Server) handleTestRequestStringEmailArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57240,6 +72730,8 @@ func (s *Server) handleTestRequestStringEmailArrayRequest(args [0]string, argsEs // // POST /test_request_string_email_array_array func (s *Server) handleTestRequestStringEmailArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_email_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57261,7 +72753,16 @@ func (s *Server) handleTestRequestStringEmailArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57273,8 +72774,27 @@ func (s *Server) handleTestRequestStringEmailArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57350,6 +72870,8 @@ func (s *Server) handleTestRequestStringEmailArrayArrayRequest(args [0]string, a // // POST /test_request_string_email_nullable func (s *Server) handleTestRequestStringEmailNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_email_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57371,7 +72893,16 @@ func (s *Server) handleTestRequestStringEmailNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57383,8 +72914,27 @@ func (s *Server) handleTestRequestStringEmailNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57460,6 +73010,8 @@ func (s *Server) handleTestRequestStringEmailNullableRequest(args [0]string, arg // // POST /test_request_string_email_nullable_array func (s *Server) handleTestRequestStringEmailNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_email_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57481,7 +73033,16 @@ func (s *Server) handleTestRequestStringEmailNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57493,8 +73054,27 @@ func (s *Server) handleTestRequestStringEmailNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57570,6 +73150,8 @@ func (s *Server) handleTestRequestStringEmailNullableArrayRequest(args [0]string // // POST /test_request_string_email_nullable_array_array func (s *Server) handleTestRequestStringEmailNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_email_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57591,7 +73173,16 @@ func (s *Server) handleTestRequestStringEmailNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57603,8 +73194,27 @@ func (s *Server) handleTestRequestStringEmailNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57680,6 +73290,8 @@ func (s *Server) handleTestRequestStringEmailNullableArrayArrayRequest(args [0]s // // POST /test_request_string_float32 func (s *Server) handleTestRequestStringFloat32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57701,7 +73313,16 @@ func (s *Server) handleTestRequestStringFloat32Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57713,8 +73334,27 @@ func (s *Server) handleTestRequestStringFloat32Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57790,6 +73430,8 @@ func (s *Server) handleTestRequestStringFloat32Request(args [0]string, argsEscap // // POST /test_request_string_float32_array func (s *Server) handleTestRequestStringFloat32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57811,7 +73453,16 @@ func (s *Server) handleTestRequestStringFloat32ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57823,8 +73474,27 @@ func (s *Server) handleTestRequestStringFloat32ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -57900,6 +73570,8 @@ func (s *Server) handleTestRequestStringFloat32ArrayRequest(args [0]string, args // // POST /test_request_string_float32_array_array func (s *Server) handleTestRequestStringFloat32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -57921,7 +73593,16 @@ func (s *Server) handleTestRequestStringFloat32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57933,8 +73614,27 @@ func (s *Server) handleTestRequestStringFloat32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58010,6 +73710,8 @@ func (s *Server) handleTestRequestStringFloat32ArrayArrayRequest(args [0]string, // // POST /test_request_string_float32_nullable func (s *Server) handleTestRequestStringFloat32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58031,7 +73733,16 @@ func (s *Server) handleTestRequestStringFloat32NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58043,8 +73754,27 @@ func (s *Server) handleTestRequestStringFloat32NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58120,6 +73850,8 @@ func (s *Server) handleTestRequestStringFloat32NullableRequest(args [0]string, a // // POST /test_request_string_float32_nullable_array func (s *Server) handleTestRequestStringFloat32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58141,7 +73873,16 @@ func (s *Server) handleTestRequestStringFloat32NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58153,8 +73894,27 @@ func (s *Server) handleTestRequestStringFloat32NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58230,6 +73990,8 @@ func (s *Server) handleTestRequestStringFloat32NullableArrayRequest(args [0]stri // // POST /test_request_string_float32_nullable_array_array func (s *Server) handleTestRequestStringFloat32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58251,7 +74013,16 @@ func (s *Server) handleTestRequestStringFloat32NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58263,8 +74034,27 @@ func (s *Server) handleTestRequestStringFloat32NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58340,6 +74130,8 @@ func (s *Server) handleTestRequestStringFloat32NullableArrayArrayRequest(args [0 // // POST /test_request_string_float64 func (s *Server) handleTestRequestStringFloat64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58361,7 +74153,16 @@ func (s *Server) handleTestRequestStringFloat64Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58373,8 +74174,27 @@ func (s *Server) handleTestRequestStringFloat64Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58450,6 +74270,8 @@ func (s *Server) handleTestRequestStringFloat64Request(args [0]string, argsEscap // // POST /test_request_string_float64_array func (s *Server) handleTestRequestStringFloat64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58471,7 +74293,16 @@ func (s *Server) handleTestRequestStringFloat64ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58483,8 +74314,27 @@ func (s *Server) handleTestRequestStringFloat64ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58560,6 +74410,8 @@ func (s *Server) handleTestRequestStringFloat64ArrayRequest(args [0]string, args // // POST /test_request_string_float64_array_array func (s *Server) handleTestRequestStringFloat64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58581,7 +74433,16 @@ func (s *Server) handleTestRequestStringFloat64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58593,8 +74454,27 @@ func (s *Server) handleTestRequestStringFloat64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58670,6 +74550,8 @@ func (s *Server) handleTestRequestStringFloat64ArrayArrayRequest(args [0]string, // // POST /test_request_string_float64_nullable func (s *Server) handleTestRequestStringFloat64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58691,7 +74573,16 @@ func (s *Server) handleTestRequestStringFloat64NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58703,8 +74594,27 @@ func (s *Server) handleTestRequestStringFloat64NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58780,6 +74690,8 @@ func (s *Server) handleTestRequestStringFloat64NullableRequest(args [0]string, a // // POST /test_request_string_float64_nullable_array func (s *Server) handleTestRequestStringFloat64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58801,7 +74713,16 @@ func (s *Server) handleTestRequestStringFloat64NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58813,8 +74734,27 @@ func (s *Server) handleTestRequestStringFloat64NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -58890,6 +74830,8 @@ func (s *Server) handleTestRequestStringFloat64NullableArrayRequest(args [0]stri // // POST /test_request_string_float64_nullable_array_array func (s *Server) handleTestRequestStringFloat64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_float64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -58911,7 +74853,16 @@ func (s *Server) handleTestRequestStringFloat64NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58923,8 +74874,27 @@ func (s *Server) handleTestRequestStringFloat64NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59000,6 +74970,8 @@ func (s *Server) handleTestRequestStringFloat64NullableArrayArrayRequest(args [0 // // POST /test_request_string_hostname func (s *Server) handleTestRequestStringHostnameRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_hostname"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59021,7 +74993,16 @@ func (s *Server) handleTestRequestStringHostnameRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59033,8 +75014,27 @@ func (s *Server) handleTestRequestStringHostnameRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59110,6 +75110,8 @@ func (s *Server) handleTestRequestStringHostnameRequest(args [0]string, argsEsca // // POST /test_request_string_hostname_array func (s *Server) handleTestRequestStringHostnameArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_hostname_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59131,7 +75133,16 @@ func (s *Server) handleTestRequestStringHostnameArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59143,8 +75154,27 @@ func (s *Server) handleTestRequestStringHostnameArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59220,6 +75250,8 @@ func (s *Server) handleTestRequestStringHostnameArrayRequest(args [0]string, arg // // POST /test_request_string_hostname_array_array func (s *Server) handleTestRequestStringHostnameArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_hostname_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59241,7 +75273,16 @@ func (s *Server) handleTestRequestStringHostnameArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59253,8 +75294,27 @@ func (s *Server) handleTestRequestStringHostnameArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59330,6 +75390,8 @@ func (s *Server) handleTestRequestStringHostnameArrayArrayRequest(args [0]string // // POST /test_request_string_hostname_nullable func (s *Server) handleTestRequestStringHostnameNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_hostname_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59351,7 +75413,16 @@ func (s *Server) handleTestRequestStringHostnameNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59363,8 +75434,27 @@ func (s *Server) handleTestRequestStringHostnameNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59440,6 +75530,8 @@ func (s *Server) handleTestRequestStringHostnameNullableRequest(args [0]string, // // POST /test_request_string_hostname_nullable_array func (s *Server) handleTestRequestStringHostnameNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_hostname_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59461,7 +75553,16 @@ func (s *Server) handleTestRequestStringHostnameNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59473,8 +75574,27 @@ func (s *Server) handleTestRequestStringHostnameNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59550,6 +75670,8 @@ func (s *Server) handleTestRequestStringHostnameNullableArrayRequest(args [0]str // // POST /test_request_string_hostname_nullable_array_array func (s *Server) handleTestRequestStringHostnameNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_hostname_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59571,7 +75693,16 @@ func (s *Server) handleTestRequestStringHostnameNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59583,8 +75714,27 @@ func (s *Server) handleTestRequestStringHostnameNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59660,6 +75810,8 @@ func (s *Server) handleTestRequestStringHostnameNullableArrayArrayRequest(args [ // // POST /test_request_string_ip func (s *Server) handleTestRequestStringIPRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ip"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59681,7 +75833,16 @@ func (s *Server) handleTestRequestStringIPRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59693,8 +75854,27 @@ func (s *Server) handleTestRequestStringIPRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59770,6 +75950,8 @@ func (s *Server) handleTestRequestStringIPRequest(args [0]string, argsEscaped bo // // POST /test_request_string_ip_array func (s *Server) handleTestRequestStringIPArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ip_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59791,7 +75973,16 @@ func (s *Server) handleTestRequestStringIPArrayRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59803,8 +75994,27 @@ func (s *Server) handleTestRequestStringIPArrayRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59880,6 +76090,8 @@ func (s *Server) handleTestRequestStringIPArrayRequest(args [0]string, argsEscap // // POST /test_request_string_ip_array_array func (s *Server) handleTestRequestStringIPArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ip_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -59901,7 +76113,16 @@ func (s *Server) handleTestRequestStringIPArrayArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59913,8 +76134,27 @@ func (s *Server) handleTestRequestStringIPArrayArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -59990,6 +76230,8 @@ func (s *Server) handleTestRequestStringIPArrayArrayRequest(args [0]string, args // // POST /test_request_string_ip_nullable func (s *Server) handleTestRequestStringIPNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ip_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60011,7 +76253,16 @@ func (s *Server) handleTestRequestStringIPNullableRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60023,8 +76274,27 @@ func (s *Server) handleTestRequestStringIPNullableRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60100,6 +76370,8 @@ func (s *Server) handleTestRequestStringIPNullableRequest(args [0]string, argsEs // // POST /test_request_string_ip_nullable_array func (s *Server) handleTestRequestStringIPNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ip_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60121,7 +76393,16 @@ func (s *Server) handleTestRequestStringIPNullableArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60133,8 +76414,27 @@ func (s *Server) handleTestRequestStringIPNullableArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60210,6 +76510,8 @@ func (s *Server) handleTestRequestStringIPNullableArrayRequest(args [0]string, a // // POST /test_request_string_ip_nullable_array_array func (s *Server) handleTestRequestStringIPNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ip_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60231,7 +76533,16 @@ func (s *Server) handleTestRequestStringIPNullableArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60243,8 +76554,27 @@ func (s *Server) handleTestRequestStringIPNullableArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60320,6 +76650,8 @@ func (s *Server) handleTestRequestStringIPNullableArrayArrayRequest(args [0]stri // // POST /test_request_string_int func (s *Server) handleTestRequestStringIntRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60341,7 +76673,16 @@ func (s *Server) handleTestRequestStringIntRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60353,8 +76694,27 @@ func (s *Server) handleTestRequestStringIntRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60430,6 +76790,8 @@ func (s *Server) handleTestRequestStringIntRequest(args [0]string, argsEscaped b // // POST /test_request_string_int16 func (s *Server) handleTestRequestStringInt16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60451,7 +76813,16 @@ func (s *Server) handleTestRequestStringInt16Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60463,8 +76834,27 @@ func (s *Server) handleTestRequestStringInt16Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60540,6 +76930,8 @@ func (s *Server) handleTestRequestStringInt16Request(args [0]string, argsEscaped // // POST /test_request_string_int16_array func (s *Server) handleTestRequestStringInt16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60561,7 +76953,16 @@ func (s *Server) handleTestRequestStringInt16ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60573,8 +76974,27 @@ func (s *Server) handleTestRequestStringInt16ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60650,6 +77070,8 @@ func (s *Server) handleTestRequestStringInt16ArrayRequest(args [0]string, argsEs // // POST /test_request_string_int16_array_array func (s *Server) handleTestRequestStringInt16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60671,7 +77093,16 @@ func (s *Server) handleTestRequestStringInt16ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60683,8 +77114,27 @@ func (s *Server) handleTestRequestStringInt16ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60760,6 +77210,8 @@ func (s *Server) handleTestRequestStringInt16ArrayArrayRequest(args [0]string, a // // POST /test_request_string_int16_nullable func (s *Server) handleTestRequestStringInt16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60781,7 +77233,16 @@ func (s *Server) handleTestRequestStringInt16NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60793,8 +77254,27 @@ func (s *Server) handleTestRequestStringInt16NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60870,6 +77350,8 @@ func (s *Server) handleTestRequestStringInt16NullableRequest(args [0]string, arg // // POST /test_request_string_int16_nullable_array func (s *Server) handleTestRequestStringInt16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -60891,7 +77373,16 @@ func (s *Server) handleTestRequestStringInt16NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -60903,8 +77394,27 @@ func (s *Server) handleTestRequestStringInt16NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -60980,6 +77490,8 @@ func (s *Server) handleTestRequestStringInt16NullableArrayRequest(args [0]string // // POST /test_request_string_int16_nullable_array_array func (s *Server) handleTestRequestStringInt16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61001,7 +77513,16 @@ func (s *Server) handleTestRequestStringInt16NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61013,8 +77534,27 @@ func (s *Server) handleTestRequestStringInt16NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61090,6 +77630,8 @@ func (s *Server) handleTestRequestStringInt16NullableArrayArrayRequest(args [0]s // // POST /test_request_string_int32 func (s *Server) handleTestRequestStringInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61111,7 +77653,16 @@ func (s *Server) handleTestRequestStringInt32Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61123,8 +77674,27 @@ func (s *Server) handleTestRequestStringInt32Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61200,6 +77770,8 @@ func (s *Server) handleTestRequestStringInt32Request(args [0]string, argsEscaped // // POST /test_request_string_int32_array func (s *Server) handleTestRequestStringInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61221,7 +77793,16 @@ func (s *Server) handleTestRequestStringInt32ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61233,8 +77814,27 @@ func (s *Server) handleTestRequestStringInt32ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61310,6 +77910,8 @@ func (s *Server) handleTestRequestStringInt32ArrayRequest(args [0]string, argsEs // // POST /test_request_string_int32_array_array func (s *Server) handleTestRequestStringInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61331,7 +77933,16 @@ func (s *Server) handleTestRequestStringInt32ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61343,8 +77954,27 @@ func (s *Server) handleTestRequestStringInt32ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61420,6 +78050,8 @@ func (s *Server) handleTestRequestStringInt32ArrayArrayRequest(args [0]string, a // // POST /test_request_string_int32_nullable func (s *Server) handleTestRequestStringInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61441,7 +78073,16 @@ func (s *Server) handleTestRequestStringInt32NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61453,8 +78094,27 @@ func (s *Server) handleTestRequestStringInt32NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61530,6 +78190,8 @@ func (s *Server) handleTestRequestStringInt32NullableRequest(args [0]string, arg // // POST /test_request_string_int32_nullable_array func (s *Server) handleTestRequestStringInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61551,7 +78213,16 @@ func (s *Server) handleTestRequestStringInt32NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61563,8 +78234,27 @@ func (s *Server) handleTestRequestStringInt32NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61640,6 +78330,8 @@ func (s *Server) handleTestRequestStringInt32NullableArrayRequest(args [0]string // // POST /test_request_string_int32_nullable_array_array func (s *Server) handleTestRequestStringInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61661,7 +78353,16 @@ func (s *Server) handleTestRequestStringInt32NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61673,8 +78374,27 @@ func (s *Server) handleTestRequestStringInt32NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61750,6 +78470,8 @@ func (s *Server) handleTestRequestStringInt32NullableArrayArrayRequest(args [0]s // // POST /test_request_string_int64 func (s *Server) handleTestRequestStringInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61771,7 +78493,16 @@ func (s *Server) handleTestRequestStringInt64Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61783,8 +78514,27 @@ func (s *Server) handleTestRequestStringInt64Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61860,6 +78610,8 @@ func (s *Server) handleTestRequestStringInt64Request(args [0]string, argsEscaped // // POST /test_request_string_int64_array func (s *Server) handleTestRequestStringInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61881,7 +78633,16 @@ func (s *Server) handleTestRequestStringInt64ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -61893,8 +78654,27 @@ func (s *Server) handleTestRequestStringInt64ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -61970,6 +78750,8 @@ func (s *Server) handleTestRequestStringInt64ArrayRequest(args [0]string, argsEs // // POST /test_request_string_int64_array_array func (s *Server) handleTestRequestStringInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -61991,7 +78773,16 @@ func (s *Server) handleTestRequestStringInt64ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62003,8 +78794,27 @@ func (s *Server) handleTestRequestStringInt64ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62080,6 +78890,8 @@ func (s *Server) handleTestRequestStringInt64ArrayArrayRequest(args [0]string, a // // POST /test_request_string_int64_nullable func (s *Server) handleTestRequestStringInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62101,7 +78913,16 @@ func (s *Server) handleTestRequestStringInt64NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62113,8 +78934,27 @@ func (s *Server) handleTestRequestStringInt64NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62190,6 +79030,8 @@ func (s *Server) handleTestRequestStringInt64NullableRequest(args [0]string, arg // // POST /test_request_string_int64_nullable_array func (s *Server) handleTestRequestStringInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62211,7 +79053,16 @@ func (s *Server) handleTestRequestStringInt64NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62223,8 +79074,27 @@ func (s *Server) handleTestRequestStringInt64NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62300,6 +79170,8 @@ func (s *Server) handleTestRequestStringInt64NullableArrayRequest(args [0]string // // POST /test_request_string_int64_nullable_array_array func (s *Server) handleTestRequestStringInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62321,7 +79193,16 @@ func (s *Server) handleTestRequestStringInt64NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62333,8 +79214,27 @@ func (s *Server) handleTestRequestStringInt64NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62410,6 +79310,8 @@ func (s *Server) handleTestRequestStringInt64NullableArrayArrayRequest(args [0]s // // POST /test_request_string_int8 func (s *Server) handleTestRequestStringInt8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62431,7 +79333,16 @@ func (s *Server) handleTestRequestStringInt8Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62443,8 +79354,27 @@ func (s *Server) handleTestRequestStringInt8Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62520,6 +79450,8 @@ func (s *Server) handleTestRequestStringInt8Request(args [0]string, argsEscaped // // POST /test_request_string_int8_array func (s *Server) handleTestRequestStringInt8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62541,7 +79473,16 @@ func (s *Server) handleTestRequestStringInt8ArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62553,8 +79494,27 @@ func (s *Server) handleTestRequestStringInt8ArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62630,6 +79590,8 @@ func (s *Server) handleTestRequestStringInt8ArrayRequest(args [0]string, argsEsc // // POST /test_request_string_int8_array_array func (s *Server) handleTestRequestStringInt8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62651,7 +79613,16 @@ func (s *Server) handleTestRequestStringInt8ArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62663,8 +79634,27 @@ func (s *Server) handleTestRequestStringInt8ArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62740,6 +79730,8 @@ func (s *Server) handleTestRequestStringInt8ArrayArrayRequest(args [0]string, ar // // POST /test_request_string_int8_nullable func (s *Server) handleTestRequestStringInt8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62761,7 +79753,16 @@ func (s *Server) handleTestRequestStringInt8NullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62773,8 +79774,27 @@ func (s *Server) handleTestRequestStringInt8NullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62850,6 +79870,8 @@ func (s *Server) handleTestRequestStringInt8NullableRequest(args [0]string, args // // POST /test_request_string_int8_nullable_array func (s *Server) handleTestRequestStringInt8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62871,7 +79893,16 @@ func (s *Server) handleTestRequestStringInt8NullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62883,8 +79914,27 @@ func (s *Server) handleTestRequestStringInt8NullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -62960,6 +80010,8 @@ func (s *Server) handleTestRequestStringInt8NullableArrayRequest(args [0]string, // // POST /test_request_string_int8_nullable_array_array func (s *Server) handleTestRequestStringInt8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -62981,7 +80033,16 @@ func (s *Server) handleTestRequestStringInt8NullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -62993,8 +80054,27 @@ func (s *Server) handleTestRequestStringInt8NullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63070,6 +80150,8 @@ func (s *Server) handleTestRequestStringInt8NullableArrayArrayRequest(args [0]st // // POST /test_request_string_int_array func (s *Server) handleTestRequestStringIntArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63091,7 +80173,16 @@ func (s *Server) handleTestRequestStringIntArrayRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63103,8 +80194,27 @@ func (s *Server) handleTestRequestStringIntArrayRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63180,6 +80290,8 @@ func (s *Server) handleTestRequestStringIntArrayRequest(args [0]string, argsEsca // // POST /test_request_string_int_array_array func (s *Server) handleTestRequestStringIntArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63201,7 +80313,16 @@ func (s *Server) handleTestRequestStringIntArrayArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63213,8 +80334,27 @@ func (s *Server) handleTestRequestStringIntArrayArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63290,6 +80430,8 @@ func (s *Server) handleTestRequestStringIntArrayArrayRequest(args [0]string, arg // // POST /test_request_string_int_nullable func (s *Server) handleTestRequestStringIntNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63311,7 +80453,16 @@ func (s *Server) handleTestRequestStringIntNullableRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63323,8 +80474,27 @@ func (s *Server) handleTestRequestStringIntNullableRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63400,6 +80570,8 @@ func (s *Server) handleTestRequestStringIntNullableRequest(args [0]string, argsE // // POST /test_request_string_int_nullable_array func (s *Server) handleTestRequestStringIntNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63421,7 +80593,16 @@ func (s *Server) handleTestRequestStringIntNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63433,8 +80614,27 @@ func (s *Server) handleTestRequestStringIntNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63510,6 +80710,8 @@ func (s *Server) handleTestRequestStringIntNullableArrayRequest(args [0]string, // // POST /test_request_string_int_nullable_array_array func (s *Server) handleTestRequestStringIntNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_int_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63531,7 +80733,16 @@ func (s *Server) handleTestRequestStringIntNullableArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63543,8 +80754,27 @@ func (s *Server) handleTestRequestStringIntNullableArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63620,6 +80850,8 @@ func (s *Server) handleTestRequestStringIntNullableArrayArrayRequest(args [0]str // // POST /test_request_string_ipv4 func (s *Server) handleTestRequestStringIpv4Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv4"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63641,7 +80873,16 @@ func (s *Server) handleTestRequestStringIpv4Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63653,8 +80894,27 @@ func (s *Server) handleTestRequestStringIpv4Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63730,6 +80990,8 @@ func (s *Server) handleTestRequestStringIpv4Request(args [0]string, argsEscaped // // POST /test_request_string_ipv4_array func (s *Server) handleTestRequestStringIpv4ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv4_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63751,7 +81013,16 @@ func (s *Server) handleTestRequestStringIpv4ArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63763,8 +81034,27 @@ func (s *Server) handleTestRequestStringIpv4ArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63840,6 +81130,8 @@ func (s *Server) handleTestRequestStringIpv4ArrayRequest(args [0]string, argsEsc // // POST /test_request_string_ipv4_array_array func (s *Server) handleTestRequestStringIpv4ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv4_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63861,7 +81153,16 @@ func (s *Server) handleTestRequestStringIpv4ArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63873,8 +81174,27 @@ func (s *Server) handleTestRequestStringIpv4ArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -63950,6 +81270,8 @@ func (s *Server) handleTestRequestStringIpv4ArrayArrayRequest(args [0]string, ar // // POST /test_request_string_ipv4_nullable func (s *Server) handleTestRequestStringIpv4NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv4_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -63971,7 +81293,16 @@ func (s *Server) handleTestRequestStringIpv4NullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -63983,8 +81314,27 @@ func (s *Server) handleTestRequestStringIpv4NullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64060,6 +81410,8 @@ func (s *Server) handleTestRequestStringIpv4NullableRequest(args [0]string, args // // POST /test_request_string_ipv4_nullable_array func (s *Server) handleTestRequestStringIpv4NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv4_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64081,7 +81433,16 @@ func (s *Server) handleTestRequestStringIpv4NullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64093,8 +81454,27 @@ func (s *Server) handleTestRequestStringIpv4NullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64170,6 +81550,8 @@ func (s *Server) handleTestRequestStringIpv4NullableArrayRequest(args [0]string, // // POST /test_request_string_ipv4_nullable_array_array func (s *Server) handleTestRequestStringIpv4NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv4_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64191,7 +81573,16 @@ func (s *Server) handleTestRequestStringIpv4NullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64203,8 +81594,27 @@ func (s *Server) handleTestRequestStringIpv4NullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64280,6 +81690,8 @@ func (s *Server) handleTestRequestStringIpv4NullableArrayArrayRequest(args [0]st // // POST /test_request_string_ipv6 func (s *Server) handleTestRequestStringIpv6Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv6"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64301,7 +81713,16 @@ func (s *Server) handleTestRequestStringIpv6Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64313,8 +81734,27 @@ func (s *Server) handleTestRequestStringIpv6Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64390,6 +81830,8 @@ func (s *Server) handleTestRequestStringIpv6Request(args [0]string, argsEscaped // // POST /test_request_string_ipv6_array func (s *Server) handleTestRequestStringIpv6ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv6_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64411,7 +81853,16 @@ func (s *Server) handleTestRequestStringIpv6ArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64423,8 +81874,27 @@ func (s *Server) handleTestRequestStringIpv6ArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64500,6 +81970,8 @@ func (s *Server) handleTestRequestStringIpv6ArrayRequest(args [0]string, argsEsc // // POST /test_request_string_ipv6_array_array func (s *Server) handleTestRequestStringIpv6ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv6_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64521,7 +81993,16 @@ func (s *Server) handleTestRequestStringIpv6ArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64533,8 +82014,27 @@ func (s *Server) handleTestRequestStringIpv6ArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64610,6 +82110,8 @@ func (s *Server) handleTestRequestStringIpv6ArrayArrayRequest(args [0]string, ar // // POST /test_request_string_ipv6_nullable func (s *Server) handleTestRequestStringIpv6NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv6_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64631,7 +82133,16 @@ func (s *Server) handleTestRequestStringIpv6NullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64643,8 +82154,27 @@ func (s *Server) handleTestRequestStringIpv6NullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64720,6 +82250,8 @@ func (s *Server) handleTestRequestStringIpv6NullableRequest(args [0]string, args // // POST /test_request_string_ipv6_nullable_array func (s *Server) handleTestRequestStringIpv6NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv6_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64741,7 +82273,16 @@ func (s *Server) handleTestRequestStringIpv6NullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64753,8 +82294,27 @@ func (s *Server) handleTestRequestStringIpv6NullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64830,6 +82390,8 @@ func (s *Server) handleTestRequestStringIpv6NullableArrayRequest(args [0]string, // // POST /test_request_string_ipv6_nullable_array_array func (s *Server) handleTestRequestStringIpv6NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_ipv6_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64851,7 +82413,16 @@ func (s *Server) handleTestRequestStringIpv6NullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64863,8 +82434,27 @@ func (s *Server) handleTestRequestStringIpv6NullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -64940,6 +82530,8 @@ func (s *Server) handleTestRequestStringIpv6NullableArrayArrayRequest(args [0]st // // POST /test_request_string_mac func (s *Server) handleTestRequestStringMACRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_mac"), semconv.HTTPRequestMethodKey.String("POST"), @@ -64961,7 +82553,16 @@ func (s *Server) handleTestRequestStringMACRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64973,8 +82574,27 @@ func (s *Server) handleTestRequestStringMACRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65050,6 +82670,8 @@ func (s *Server) handleTestRequestStringMACRequest(args [0]string, argsEscaped b // // POST /test_request_string_mac_array func (s *Server) handleTestRequestStringMACArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_mac_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65071,7 +82693,16 @@ func (s *Server) handleTestRequestStringMACArrayRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65083,8 +82714,27 @@ func (s *Server) handleTestRequestStringMACArrayRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65160,6 +82810,8 @@ func (s *Server) handleTestRequestStringMACArrayRequest(args [0]string, argsEsca // // POST /test_request_string_mac_array_array func (s *Server) handleTestRequestStringMACArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_mac_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65181,7 +82833,16 @@ func (s *Server) handleTestRequestStringMACArrayArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65193,8 +82854,27 @@ func (s *Server) handleTestRequestStringMACArrayArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65270,6 +82950,8 @@ func (s *Server) handleTestRequestStringMACArrayArrayRequest(args [0]string, arg // // POST /test_request_string_mac_nullable func (s *Server) handleTestRequestStringMACNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_mac_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65291,7 +82973,16 @@ func (s *Server) handleTestRequestStringMACNullableRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65303,8 +82994,27 @@ func (s *Server) handleTestRequestStringMACNullableRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65380,6 +83090,8 @@ func (s *Server) handleTestRequestStringMACNullableRequest(args [0]string, argsE // // POST /test_request_string_mac_nullable_array func (s *Server) handleTestRequestStringMACNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_mac_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65401,7 +83113,16 @@ func (s *Server) handleTestRequestStringMACNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65413,8 +83134,27 @@ func (s *Server) handleTestRequestStringMACNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65490,6 +83230,8 @@ func (s *Server) handleTestRequestStringMACNullableArrayRequest(args [0]string, // // POST /test_request_string_mac_nullable_array_array func (s *Server) handleTestRequestStringMACNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_mac_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65511,7 +83253,16 @@ func (s *Server) handleTestRequestStringMACNullableArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65523,8 +83274,27 @@ func (s *Server) handleTestRequestStringMACNullableArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65600,6 +83370,8 @@ func (s *Server) handleTestRequestStringMACNullableArrayArrayRequest(args [0]str // // POST /test_request_string_nullable func (s *Server) handleTestRequestStringNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65621,7 +83393,16 @@ func (s *Server) handleTestRequestStringNullableRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65633,8 +83414,27 @@ func (s *Server) handleTestRequestStringNullableRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65710,6 +83510,8 @@ func (s *Server) handleTestRequestStringNullableRequest(args [0]string, argsEsca // // POST /test_request_string_nullable_array func (s *Server) handleTestRequestStringNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65731,7 +83533,16 @@ func (s *Server) handleTestRequestStringNullableArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65743,8 +83554,27 @@ func (s *Server) handleTestRequestStringNullableArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65820,6 +83650,8 @@ func (s *Server) handleTestRequestStringNullableArrayRequest(args [0]string, arg // // POST /test_request_string_nullable_array_array func (s *Server) handleTestRequestStringNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65841,7 +83673,16 @@ func (s *Server) handleTestRequestStringNullableArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65853,8 +83694,27 @@ func (s *Server) handleTestRequestStringNullableArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -65930,6 +83790,8 @@ func (s *Server) handleTestRequestStringNullableArrayArrayRequest(args [0]string // // POST /test_request_string_password func (s *Server) handleTestRequestStringPasswordRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_password"), semconv.HTTPRequestMethodKey.String("POST"), @@ -65951,7 +83813,16 @@ func (s *Server) handleTestRequestStringPasswordRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -65963,8 +83834,27 @@ func (s *Server) handleTestRequestStringPasswordRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66040,6 +83930,8 @@ func (s *Server) handleTestRequestStringPasswordRequest(args [0]string, argsEsca // // POST /test_request_string_password_array func (s *Server) handleTestRequestStringPasswordArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_password_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66061,7 +83953,16 @@ func (s *Server) handleTestRequestStringPasswordArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66073,8 +83974,27 @@ func (s *Server) handleTestRequestStringPasswordArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66150,6 +84070,8 @@ func (s *Server) handleTestRequestStringPasswordArrayRequest(args [0]string, arg // // POST /test_request_string_password_array_array func (s *Server) handleTestRequestStringPasswordArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_password_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66171,7 +84093,16 @@ func (s *Server) handleTestRequestStringPasswordArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66183,8 +84114,27 @@ func (s *Server) handleTestRequestStringPasswordArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66260,6 +84210,8 @@ func (s *Server) handleTestRequestStringPasswordArrayArrayRequest(args [0]string // // POST /test_request_string_password_nullable func (s *Server) handleTestRequestStringPasswordNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_password_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66281,7 +84233,16 @@ func (s *Server) handleTestRequestStringPasswordNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66293,8 +84254,27 @@ func (s *Server) handleTestRequestStringPasswordNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66370,6 +84350,8 @@ func (s *Server) handleTestRequestStringPasswordNullableRequest(args [0]string, // // POST /test_request_string_password_nullable_array func (s *Server) handleTestRequestStringPasswordNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_password_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66391,7 +84373,16 @@ func (s *Server) handleTestRequestStringPasswordNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66403,8 +84394,27 @@ func (s *Server) handleTestRequestStringPasswordNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66480,6 +84490,8 @@ func (s *Server) handleTestRequestStringPasswordNullableArrayRequest(args [0]str // // POST /test_request_string_password_nullable_array_array func (s *Server) handleTestRequestStringPasswordNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_password_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66501,7 +84513,16 @@ func (s *Server) handleTestRequestStringPasswordNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66513,8 +84534,27 @@ func (s *Server) handleTestRequestStringPasswordNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66590,6 +84630,8 @@ func (s *Server) handleTestRequestStringPasswordNullableArrayArrayRequest(args [ // // POST /test_request_string_time func (s *Server) handleTestRequestStringTimeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_time"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66611,7 +84653,16 @@ func (s *Server) handleTestRequestStringTimeRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66623,8 +84674,27 @@ func (s *Server) handleTestRequestStringTimeRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66700,6 +84770,8 @@ func (s *Server) handleTestRequestStringTimeRequest(args [0]string, argsEscaped // // POST /test_request_string_time_array func (s *Server) handleTestRequestStringTimeArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_time_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66721,7 +84793,16 @@ func (s *Server) handleTestRequestStringTimeArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66733,8 +84814,27 @@ func (s *Server) handleTestRequestStringTimeArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66810,6 +84910,8 @@ func (s *Server) handleTestRequestStringTimeArrayRequest(args [0]string, argsEsc // // POST /test_request_string_time_array_array func (s *Server) handleTestRequestStringTimeArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_time_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66831,7 +84933,16 @@ func (s *Server) handleTestRequestStringTimeArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66843,8 +84954,27 @@ func (s *Server) handleTestRequestStringTimeArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -66920,6 +85050,8 @@ func (s *Server) handleTestRequestStringTimeArrayArrayRequest(args [0]string, ar // // POST /test_request_string_time_nullable func (s *Server) handleTestRequestStringTimeNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_time_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -66941,7 +85073,16 @@ func (s *Server) handleTestRequestStringTimeNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -66953,8 +85094,27 @@ func (s *Server) handleTestRequestStringTimeNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67030,6 +85190,8 @@ func (s *Server) handleTestRequestStringTimeNullableRequest(args [0]string, args // // POST /test_request_string_time_nullable_array func (s *Server) handleTestRequestStringTimeNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_time_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67051,7 +85213,16 @@ func (s *Server) handleTestRequestStringTimeNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67063,8 +85234,27 @@ func (s *Server) handleTestRequestStringTimeNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67140,6 +85330,8 @@ func (s *Server) handleTestRequestStringTimeNullableArrayRequest(args [0]string, // // POST /test_request_string_time_nullable_array_array func (s *Server) handleTestRequestStringTimeNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_time_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67161,7 +85353,16 @@ func (s *Server) handleTestRequestStringTimeNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67173,8 +85374,27 @@ func (s *Server) handleTestRequestStringTimeNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67250,6 +85470,8 @@ func (s *Server) handleTestRequestStringTimeNullableArrayArrayRequest(args [0]st // // POST /test_request_string_uri func (s *Server) handleTestRequestStringURIRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uri"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67271,7 +85493,16 @@ func (s *Server) handleTestRequestStringURIRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67283,8 +85514,27 @@ func (s *Server) handleTestRequestStringURIRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67360,6 +85610,8 @@ func (s *Server) handleTestRequestStringURIRequest(args [0]string, argsEscaped b // // POST /test_request_string_uri_array func (s *Server) handleTestRequestStringURIArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uri_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67381,7 +85633,16 @@ func (s *Server) handleTestRequestStringURIArrayRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67393,8 +85654,27 @@ func (s *Server) handleTestRequestStringURIArrayRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67470,6 +85750,8 @@ func (s *Server) handleTestRequestStringURIArrayRequest(args [0]string, argsEsca // // POST /test_request_string_uri_array_array func (s *Server) handleTestRequestStringURIArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uri_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67491,7 +85773,16 @@ func (s *Server) handleTestRequestStringURIArrayArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67503,8 +85794,27 @@ func (s *Server) handleTestRequestStringURIArrayArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67580,6 +85890,8 @@ func (s *Server) handleTestRequestStringURIArrayArrayRequest(args [0]string, arg // // POST /test_request_string_uri_nullable func (s *Server) handleTestRequestStringURINullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uri_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67601,7 +85913,16 @@ func (s *Server) handleTestRequestStringURINullableRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67613,8 +85934,27 @@ func (s *Server) handleTestRequestStringURINullableRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67690,6 +86030,8 @@ func (s *Server) handleTestRequestStringURINullableRequest(args [0]string, argsE // // POST /test_request_string_uri_nullable_array func (s *Server) handleTestRequestStringURINullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uri_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67711,7 +86053,16 @@ func (s *Server) handleTestRequestStringURINullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67723,8 +86074,27 @@ func (s *Server) handleTestRequestStringURINullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67800,6 +86170,8 @@ func (s *Server) handleTestRequestStringURINullableArrayRequest(args [0]string, // // POST /test_request_string_uri_nullable_array_array func (s *Server) handleTestRequestStringURINullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uri_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67821,7 +86193,16 @@ func (s *Server) handleTestRequestStringURINullableArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67833,8 +86214,27 @@ func (s *Server) handleTestRequestStringURINullableArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -67910,6 +86310,8 @@ func (s *Server) handleTestRequestStringURINullableArrayArrayRequest(args [0]str // // POST /test_request_string_uuid func (s *Server) handleTestRequestStringUUIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uuid"), semconv.HTTPRequestMethodKey.String("POST"), @@ -67931,7 +86333,16 @@ func (s *Server) handleTestRequestStringUUIDRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -67943,8 +86354,27 @@ func (s *Server) handleTestRequestStringUUIDRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68020,6 +86450,8 @@ func (s *Server) handleTestRequestStringUUIDRequest(args [0]string, argsEscaped // // POST /test_request_string_uuid_array func (s *Server) handleTestRequestStringUUIDArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uuid_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68041,7 +86473,16 @@ func (s *Server) handleTestRequestStringUUIDArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68053,8 +86494,27 @@ func (s *Server) handleTestRequestStringUUIDArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68130,6 +86590,8 @@ func (s *Server) handleTestRequestStringUUIDArrayRequest(args [0]string, argsEsc // // POST /test_request_string_uuid_array_array func (s *Server) handleTestRequestStringUUIDArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uuid_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68151,7 +86613,16 @@ func (s *Server) handleTestRequestStringUUIDArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68163,8 +86634,27 @@ func (s *Server) handleTestRequestStringUUIDArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68240,6 +86730,8 @@ func (s *Server) handleTestRequestStringUUIDArrayArrayRequest(args [0]string, ar // // POST /test_request_string_uuid_nullable func (s *Server) handleTestRequestStringUUIDNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uuid_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68261,7 +86753,16 @@ func (s *Server) handleTestRequestStringUUIDNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68273,8 +86774,27 @@ func (s *Server) handleTestRequestStringUUIDNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68350,6 +86870,8 @@ func (s *Server) handleTestRequestStringUUIDNullableRequest(args [0]string, args // // POST /test_request_string_uuid_nullable_array func (s *Server) handleTestRequestStringUUIDNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uuid_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68371,7 +86893,16 @@ func (s *Server) handleTestRequestStringUUIDNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68383,8 +86914,27 @@ func (s *Server) handleTestRequestStringUUIDNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68460,6 +87010,8 @@ func (s *Server) handleTestRequestStringUUIDNullableArrayRequest(args [0]string, // // POST /test_request_string_uuid_nullable_array_array func (s *Server) handleTestRequestStringUUIDNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uuid_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68481,7 +87033,16 @@ func (s *Server) handleTestRequestStringUUIDNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68493,8 +87054,27 @@ func (s *Server) handleTestRequestStringUUIDNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68570,6 +87150,8 @@ func (s *Server) handleTestRequestStringUUIDNullableArrayArrayRequest(args [0]st // // POST /test_request_string_uint func (s *Server) handleTestRequestStringUintRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68591,7 +87173,16 @@ func (s *Server) handleTestRequestStringUintRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68603,8 +87194,27 @@ func (s *Server) handleTestRequestStringUintRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68680,6 +87290,8 @@ func (s *Server) handleTestRequestStringUintRequest(args [0]string, argsEscaped // // POST /test_request_string_uint16 func (s *Server) handleTestRequestStringUint16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68701,7 +87313,16 @@ func (s *Server) handleTestRequestStringUint16Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68713,8 +87334,27 @@ func (s *Server) handleTestRequestStringUint16Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68790,6 +87430,8 @@ func (s *Server) handleTestRequestStringUint16Request(args [0]string, argsEscape // // POST /test_request_string_uint16_array func (s *Server) handleTestRequestStringUint16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68811,7 +87453,16 @@ func (s *Server) handleTestRequestStringUint16ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68823,8 +87474,27 @@ func (s *Server) handleTestRequestStringUint16ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -68900,6 +87570,8 @@ func (s *Server) handleTestRequestStringUint16ArrayRequest(args [0]string, argsE // // POST /test_request_string_uint16_array_array func (s *Server) handleTestRequestStringUint16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -68921,7 +87593,16 @@ func (s *Server) handleTestRequestStringUint16ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -68933,8 +87614,27 @@ func (s *Server) handleTestRequestStringUint16ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69010,6 +87710,8 @@ func (s *Server) handleTestRequestStringUint16ArrayArrayRequest(args [0]string, // // POST /test_request_string_uint16_nullable func (s *Server) handleTestRequestStringUint16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69031,7 +87733,16 @@ func (s *Server) handleTestRequestStringUint16NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69043,8 +87754,27 @@ func (s *Server) handleTestRequestStringUint16NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69120,6 +87850,8 @@ func (s *Server) handleTestRequestStringUint16NullableRequest(args [0]string, ar // // POST /test_request_string_uint16_nullable_array func (s *Server) handleTestRequestStringUint16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69141,7 +87873,16 @@ func (s *Server) handleTestRequestStringUint16NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69153,8 +87894,27 @@ func (s *Server) handleTestRequestStringUint16NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69230,6 +87990,8 @@ func (s *Server) handleTestRequestStringUint16NullableArrayRequest(args [0]strin // // POST /test_request_string_uint16_nullable_array_array func (s *Server) handleTestRequestStringUint16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69251,7 +88013,16 @@ func (s *Server) handleTestRequestStringUint16NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69263,8 +88034,27 @@ func (s *Server) handleTestRequestStringUint16NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69340,6 +88130,8 @@ func (s *Server) handleTestRequestStringUint16NullableArrayArrayRequest(args [0] // // POST /test_request_string_uint32 func (s *Server) handleTestRequestStringUint32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69361,7 +88153,16 @@ func (s *Server) handleTestRequestStringUint32Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69373,8 +88174,27 @@ func (s *Server) handleTestRequestStringUint32Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69450,6 +88270,8 @@ func (s *Server) handleTestRequestStringUint32Request(args [0]string, argsEscape // // POST /test_request_string_uint32_array func (s *Server) handleTestRequestStringUint32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69471,7 +88293,16 @@ func (s *Server) handleTestRequestStringUint32ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69483,8 +88314,27 @@ func (s *Server) handleTestRequestStringUint32ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69560,6 +88410,8 @@ func (s *Server) handleTestRequestStringUint32ArrayRequest(args [0]string, argsE // // POST /test_request_string_uint32_array_array func (s *Server) handleTestRequestStringUint32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69581,7 +88433,16 @@ func (s *Server) handleTestRequestStringUint32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69593,8 +88454,27 @@ func (s *Server) handleTestRequestStringUint32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69670,6 +88550,8 @@ func (s *Server) handleTestRequestStringUint32ArrayArrayRequest(args [0]string, // // POST /test_request_string_uint32_nullable func (s *Server) handleTestRequestStringUint32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69691,7 +88573,16 @@ func (s *Server) handleTestRequestStringUint32NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69703,8 +88594,27 @@ func (s *Server) handleTestRequestStringUint32NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69780,6 +88690,8 @@ func (s *Server) handleTestRequestStringUint32NullableRequest(args [0]string, ar // // POST /test_request_string_uint32_nullable_array func (s *Server) handleTestRequestStringUint32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69801,7 +88713,16 @@ func (s *Server) handleTestRequestStringUint32NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69813,8 +88734,27 @@ func (s *Server) handleTestRequestStringUint32NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -69890,6 +88830,8 @@ func (s *Server) handleTestRequestStringUint32NullableArrayRequest(args [0]strin // // POST /test_request_string_uint32_nullable_array_array func (s *Server) handleTestRequestStringUint32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -69911,7 +88853,16 @@ func (s *Server) handleTestRequestStringUint32NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -69923,8 +88874,27 @@ func (s *Server) handleTestRequestStringUint32NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70000,6 +88970,8 @@ func (s *Server) handleTestRequestStringUint32NullableArrayArrayRequest(args [0] // // POST /test_request_string_uint64 func (s *Server) handleTestRequestStringUint64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70021,7 +88993,16 @@ func (s *Server) handleTestRequestStringUint64Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70033,8 +89014,27 @@ func (s *Server) handleTestRequestStringUint64Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70110,6 +89110,8 @@ func (s *Server) handleTestRequestStringUint64Request(args [0]string, argsEscape // // POST /test_request_string_uint64_array func (s *Server) handleTestRequestStringUint64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70131,7 +89133,16 @@ func (s *Server) handleTestRequestStringUint64ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70143,8 +89154,27 @@ func (s *Server) handleTestRequestStringUint64ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70220,6 +89250,8 @@ func (s *Server) handleTestRequestStringUint64ArrayRequest(args [0]string, argsE // // POST /test_request_string_uint64_array_array func (s *Server) handleTestRequestStringUint64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70241,7 +89273,16 @@ func (s *Server) handleTestRequestStringUint64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70253,8 +89294,27 @@ func (s *Server) handleTestRequestStringUint64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70330,6 +89390,8 @@ func (s *Server) handleTestRequestStringUint64ArrayArrayRequest(args [0]string, // // POST /test_request_string_uint64_nullable func (s *Server) handleTestRequestStringUint64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70351,7 +89413,16 @@ func (s *Server) handleTestRequestStringUint64NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70363,8 +89434,27 @@ func (s *Server) handleTestRequestStringUint64NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70440,6 +89530,8 @@ func (s *Server) handleTestRequestStringUint64NullableRequest(args [0]string, ar // // POST /test_request_string_uint64_nullable_array func (s *Server) handleTestRequestStringUint64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70461,7 +89553,16 @@ func (s *Server) handleTestRequestStringUint64NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70473,8 +89574,27 @@ func (s *Server) handleTestRequestStringUint64NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70550,6 +89670,8 @@ func (s *Server) handleTestRequestStringUint64NullableArrayRequest(args [0]strin // // POST /test_request_string_uint64_nullable_array_array func (s *Server) handleTestRequestStringUint64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70571,7 +89693,16 @@ func (s *Server) handleTestRequestStringUint64NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70583,8 +89714,27 @@ func (s *Server) handleTestRequestStringUint64NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70660,6 +89810,8 @@ func (s *Server) handleTestRequestStringUint64NullableArrayArrayRequest(args [0] // // POST /test_request_string_uint8 func (s *Server) handleTestRequestStringUint8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70681,7 +89833,16 @@ func (s *Server) handleTestRequestStringUint8Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70693,8 +89854,27 @@ func (s *Server) handleTestRequestStringUint8Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70770,6 +89950,8 @@ func (s *Server) handleTestRequestStringUint8Request(args [0]string, argsEscaped // // POST /test_request_string_uint8_array func (s *Server) handleTestRequestStringUint8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70791,7 +89973,16 @@ func (s *Server) handleTestRequestStringUint8ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70803,8 +89994,27 @@ func (s *Server) handleTestRequestStringUint8ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70880,6 +90090,8 @@ func (s *Server) handleTestRequestStringUint8ArrayRequest(args [0]string, argsEs // // POST /test_request_string_uint8_array_array func (s *Server) handleTestRequestStringUint8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -70901,7 +90113,16 @@ func (s *Server) handleTestRequestStringUint8ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -70913,8 +90134,27 @@ func (s *Server) handleTestRequestStringUint8ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -70990,6 +90230,8 @@ func (s *Server) handleTestRequestStringUint8ArrayArrayRequest(args [0]string, a // // POST /test_request_string_uint8_nullable func (s *Server) handleTestRequestStringUint8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71011,7 +90253,16 @@ func (s *Server) handleTestRequestStringUint8NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71023,8 +90274,27 @@ func (s *Server) handleTestRequestStringUint8NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71100,6 +90370,8 @@ func (s *Server) handleTestRequestStringUint8NullableRequest(args [0]string, arg // // POST /test_request_string_uint8_nullable_array func (s *Server) handleTestRequestStringUint8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71121,7 +90393,16 @@ func (s *Server) handleTestRequestStringUint8NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71133,8 +90414,27 @@ func (s *Server) handleTestRequestStringUint8NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71210,6 +90510,8 @@ func (s *Server) handleTestRequestStringUint8NullableArrayRequest(args [0]string // // POST /test_request_string_uint8_nullable_array_array func (s *Server) handleTestRequestStringUint8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71231,7 +90533,16 @@ func (s *Server) handleTestRequestStringUint8NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71243,8 +90554,27 @@ func (s *Server) handleTestRequestStringUint8NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71320,6 +90650,8 @@ func (s *Server) handleTestRequestStringUint8NullableArrayArrayRequest(args [0]s // // POST /test_request_string_uint_array func (s *Server) handleTestRequestStringUintArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71341,7 +90673,16 @@ func (s *Server) handleTestRequestStringUintArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71353,8 +90694,27 @@ func (s *Server) handleTestRequestStringUintArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71430,6 +90790,8 @@ func (s *Server) handleTestRequestStringUintArrayRequest(args [0]string, argsEsc // // POST /test_request_string_uint_array_array func (s *Server) handleTestRequestStringUintArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71451,7 +90813,16 @@ func (s *Server) handleTestRequestStringUintArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71463,8 +90834,27 @@ func (s *Server) handleTestRequestStringUintArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71540,6 +90930,8 @@ func (s *Server) handleTestRequestStringUintArrayArrayRequest(args [0]string, ar // // POST /test_request_string_uint_nullable func (s *Server) handleTestRequestStringUintNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71561,7 +90953,16 @@ func (s *Server) handleTestRequestStringUintNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71573,8 +90974,27 @@ func (s *Server) handleTestRequestStringUintNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71650,6 +91070,8 @@ func (s *Server) handleTestRequestStringUintNullableRequest(args [0]string, args // // POST /test_request_string_uint_nullable_array func (s *Server) handleTestRequestStringUintNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71671,7 +91093,16 @@ func (s *Server) handleTestRequestStringUintNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71683,8 +91114,27 @@ func (s *Server) handleTestRequestStringUintNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71760,6 +91210,8 @@ func (s *Server) handleTestRequestStringUintNullableArrayRequest(args [0]string, // // POST /test_request_string_uint_nullable_array_array func (s *Server) handleTestRequestStringUintNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_uint_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71781,7 +91233,16 @@ func (s *Server) handleTestRequestStringUintNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71793,8 +91254,27 @@ func (s *Server) handleTestRequestStringUintNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71870,6 +91350,8 @@ func (s *Server) handleTestRequestStringUintNullableArrayArrayRequest(args [0]st // // POST /test_request_string_unix func (s *Server) handleTestRequestStringUnixRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix"), semconv.HTTPRequestMethodKey.String("POST"), @@ -71891,7 +91373,16 @@ func (s *Server) handleTestRequestStringUnixRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -71903,8 +91394,27 @@ func (s *Server) handleTestRequestStringUnixRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -71980,6 +91490,8 @@ func (s *Server) handleTestRequestStringUnixRequest(args [0]string, argsEscaped // // POST /test_request_string_unix_array func (s *Server) handleTestRequestStringUnixArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72001,7 +91513,16 @@ func (s *Server) handleTestRequestStringUnixArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72013,8 +91534,27 @@ func (s *Server) handleTestRequestStringUnixArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72090,6 +91630,8 @@ func (s *Server) handleTestRequestStringUnixArrayRequest(args [0]string, argsEsc // // POST /test_request_string_unix_array_array func (s *Server) handleTestRequestStringUnixArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72111,7 +91653,16 @@ func (s *Server) handleTestRequestStringUnixArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72123,8 +91674,27 @@ func (s *Server) handleTestRequestStringUnixArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72200,6 +91770,8 @@ func (s *Server) handleTestRequestStringUnixArrayArrayRequest(args [0]string, ar // // POST /test_request_string_unix-micro func (s *Server) handleTestRequestStringUnixMicroRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-micro"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72221,7 +91793,16 @@ func (s *Server) handleTestRequestStringUnixMicroRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72233,8 +91814,27 @@ func (s *Server) handleTestRequestStringUnixMicroRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72310,6 +91910,8 @@ func (s *Server) handleTestRequestStringUnixMicroRequest(args [0]string, argsEsc // // POST /test_request_string_unix-micro_array func (s *Server) handleTestRequestStringUnixMicroArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-micro_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72331,7 +91933,16 @@ func (s *Server) handleTestRequestStringUnixMicroArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72343,8 +91954,27 @@ func (s *Server) handleTestRequestStringUnixMicroArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72420,6 +92050,8 @@ func (s *Server) handleTestRequestStringUnixMicroArrayRequest(args [0]string, ar // // POST /test_request_string_unix-micro_array_array func (s *Server) handleTestRequestStringUnixMicroArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-micro_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72441,7 +92073,16 @@ func (s *Server) handleTestRequestStringUnixMicroArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72453,8 +92094,27 @@ func (s *Server) handleTestRequestStringUnixMicroArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72530,6 +92190,8 @@ func (s *Server) handleTestRequestStringUnixMicroArrayArrayRequest(args [0]strin // // POST /test_request_string_unix-micro_nullable func (s *Server) handleTestRequestStringUnixMicroNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-micro_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72551,7 +92213,16 @@ func (s *Server) handleTestRequestStringUnixMicroNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72563,8 +92234,27 @@ func (s *Server) handleTestRequestStringUnixMicroNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72640,6 +92330,8 @@ func (s *Server) handleTestRequestStringUnixMicroNullableRequest(args [0]string, // // POST /test_request_string_unix-micro_nullable_array func (s *Server) handleTestRequestStringUnixMicroNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-micro_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72661,7 +92353,16 @@ func (s *Server) handleTestRequestStringUnixMicroNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72673,8 +92374,27 @@ func (s *Server) handleTestRequestStringUnixMicroNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72750,6 +92470,8 @@ func (s *Server) handleTestRequestStringUnixMicroNullableArrayRequest(args [0]st // // POST /test_request_string_unix-micro_nullable_array_array func (s *Server) handleTestRequestStringUnixMicroNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-micro_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72771,7 +92493,16 @@ func (s *Server) handleTestRequestStringUnixMicroNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72783,8 +92514,27 @@ func (s *Server) handleTestRequestStringUnixMicroNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72860,6 +92610,8 @@ func (s *Server) handleTestRequestStringUnixMicroNullableArrayArrayRequest(args // // POST /test_request_string_unix-milli func (s *Server) handleTestRequestStringUnixMilliRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-milli"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72881,7 +92633,16 @@ func (s *Server) handleTestRequestStringUnixMilliRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -72893,8 +92654,27 @@ func (s *Server) handleTestRequestStringUnixMilliRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -72970,6 +92750,8 @@ func (s *Server) handleTestRequestStringUnixMilliRequest(args [0]string, argsEsc // // POST /test_request_string_unix-milli_array func (s *Server) handleTestRequestStringUnixMilliArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-milli_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -72991,7 +92773,16 @@ func (s *Server) handleTestRequestStringUnixMilliArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73003,8 +92794,27 @@ func (s *Server) handleTestRequestStringUnixMilliArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73080,6 +92890,8 @@ func (s *Server) handleTestRequestStringUnixMilliArrayRequest(args [0]string, ar // // POST /test_request_string_unix-milli_array_array func (s *Server) handleTestRequestStringUnixMilliArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-milli_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73101,7 +92913,16 @@ func (s *Server) handleTestRequestStringUnixMilliArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73113,8 +92934,27 @@ func (s *Server) handleTestRequestStringUnixMilliArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73190,6 +93030,8 @@ func (s *Server) handleTestRequestStringUnixMilliArrayArrayRequest(args [0]strin // // POST /test_request_string_unix-milli_nullable func (s *Server) handleTestRequestStringUnixMilliNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-milli_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73211,7 +93053,16 @@ func (s *Server) handleTestRequestStringUnixMilliNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73223,8 +93074,27 @@ func (s *Server) handleTestRequestStringUnixMilliNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73300,6 +93170,8 @@ func (s *Server) handleTestRequestStringUnixMilliNullableRequest(args [0]string, // // POST /test_request_string_unix-milli_nullable_array func (s *Server) handleTestRequestStringUnixMilliNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-milli_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73321,7 +93193,16 @@ func (s *Server) handleTestRequestStringUnixMilliNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73333,8 +93214,27 @@ func (s *Server) handleTestRequestStringUnixMilliNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73410,6 +93310,8 @@ func (s *Server) handleTestRequestStringUnixMilliNullableArrayRequest(args [0]st // // POST /test_request_string_unix-milli_nullable_array_array func (s *Server) handleTestRequestStringUnixMilliNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-milli_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73431,7 +93333,16 @@ func (s *Server) handleTestRequestStringUnixMilliNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73443,8 +93354,27 @@ func (s *Server) handleTestRequestStringUnixMilliNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73520,6 +93450,8 @@ func (s *Server) handleTestRequestStringUnixMilliNullableArrayArrayRequest(args // // POST /test_request_string_unix-nano func (s *Server) handleTestRequestStringUnixNanoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-nano"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73541,7 +93473,16 @@ func (s *Server) handleTestRequestStringUnixNanoRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73553,8 +93494,27 @@ func (s *Server) handleTestRequestStringUnixNanoRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73630,6 +93590,8 @@ func (s *Server) handleTestRequestStringUnixNanoRequest(args [0]string, argsEsca // // POST /test_request_string_unix-nano_array func (s *Server) handleTestRequestStringUnixNanoArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-nano_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73651,7 +93613,16 @@ func (s *Server) handleTestRequestStringUnixNanoArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73663,8 +93634,27 @@ func (s *Server) handleTestRequestStringUnixNanoArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73740,6 +93730,8 @@ func (s *Server) handleTestRequestStringUnixNanoArrayRequest(args [0]string, arg // // POST /test_request_string_unix-nano_array_array func (s *Server) handleTestRequestStringUnixNanoArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-nano_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73761,7 +93753,16 @@ func (s *Server) handleTestRequestStringUnixNanoArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73773,8 +93774,27 @@ func (s *Server) handleTestRequestStringUnixNanoArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73850,6 +93870,8 @@ func (s *Server) handleTestRequestStringUnixNanoArrayArrayRequest(args [0]string // // POST /test_request_string_unix-nano_nullable func (s *Server) handleTestRequestStringUnixNanoNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-nano_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73871,7 +93893,16 @@ func (s *Server) handleTestRequestStringUnixNanoNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73883,8 +93914,27 @@ func (s *Server) handleTestRequestStringUnixNanoNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -73960,6 +94010,8 @@ func (s *Server) handleTestRequestStringUnixNanoNullableRequest(args [0]string, // // POST /test_request_string_unix-nano_nullable_array func (s *Server) handleTestRequestStringUnixNanoNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-nano_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -73981,7 +94033,16 @@ func (s *Server) handleTestRequestStringUnixNanoNullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -73993,8 +94054,27 @@ func (s *Server) handleTestRequestStringUnixNanoNullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74070,6 +94150,8 @@ func (s *Server) handleTestRequestStringUnixNanoNullableArrayRequest(args [0]str // // POST /test_request_string_unix-nano_nullable_array_array func (s *Server) handleTestRequestStringUnixNanoNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-nano_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74091,7 +94173,16 @@ func (s *Server) handleTestRequestStringUnixNanoNullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74103,8 +94194,27 @@ func (s *Server) handleTestRequestStringUnixNanoNullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74180,6 +94290,8 @@ func (s *Server) handleTestRequestStringUnixNanoNullableArrayArrayRequest(args [ // // POST /test_request_string_unix_nullable func (s *Server) handleTestRequestStringUnixNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74201,7 +94313,16 @@ func (s *Server) handleTestRequestStringUnixNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74213,8 +94334,27 @@ func (s *Server) handleTestRequestStringUnixNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74290,6 +94430,8 @@ func (s *Server) handleTestRequestStringUnixNullableRequest(args [0]string, args // // POST /test_request_string_unix_nullable_array func (s *Server) handleTestRequestStringUnixNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74311,7 +94453,16 @@ func (s *Server) handleTestRequestStringUnixNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74323,8 +94474,27 @@ func (s *Server) handleTestRequestStringUnixNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74400,6 +94570,8 @@ func (s *Server) handleTestRequestStringUnixNullableArrayRequest(args [0]string, // // POST /test_request_string_unix_nullable_array_array func (s *Server) handleTestRequestStringUnixNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74421,7 +94593,16 @@ func (s *Server) handleTestRequestStringUnixNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74433,8 +94614,27 @@ func (s *Server) handleTestRequestStringUnixNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74510,6 +94710,8 @@ func (s *Server) handleTestRequestStringUnixNullableArrayArrayRequest(args [0]st // // POST /test_request_string_unix-seconds func (s *Server) handleTestRequestStringUnixSecondsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-seconds"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74531,7 +94733,16 @@ func (s *Server) handleTestRequestStringUnixSecondsRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74543,8 +94754,27 @@ func (s *Server) handleTestRequestStringUnixSecondsRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74620,6 +94850,8 @@ func (s *Server) handleTestRequestStringUnixSecondsRequest(args [0]string, argsE // // POST /test_request_string_unix-seconds_array func (s *Server) handleTestRequestStringUnixSecondsArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-seconds_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74641,7 +94873,16 @@ func (s *Server) handleTestRequestStringUnixSecondsArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74653,8 +94894,27 @@ func (s *Server) handleTestRequestStringUnixSecondsArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74730,6 +94990,8 @@ func (s *Server) handleTestRequestStringUnixSecondsArrayRequest(args [0]string, // // POST /test_request_string_unix-seconds_array_array func (s *Server) handleTestRequestStringUnixSecondsArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-seconds_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74751,7 +95013,16 @@ func (s *Server) handleTestRequestStringUnixSecondsArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74763,8 +95034,27 @@ func (s *Server) handleTestRequestStringUnixSecondsArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74840,6 +95130,8 @@ func (s *Server) handleTestRequestStringUnixSecondsArrayArrayRequest(args [0]str // // POST /test_request_string_unix-seconds_nullable func (s *Server) handleTestRequestStringUnixSecondsNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-seconds_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74861,7 +95153,16 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74873,8 +95174,27 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -74950,6 +95270,8 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableRequest(args [0]strin // // POST /test_request_string_unix-seconds_nullable_array func (s *Server) handleTestRequestStringUnixSecondsNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-seconds_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -74971,7 +95293,16 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -74983,8 +95314,27 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75060,6 +95410,8 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableArrayRequest(args [0] // // POST /test_request_string_unix-seconds_nullable_array_array func (s *Server) handleTestRequestStringUnixSecondsNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_request_string_unix-seconds_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75081,7 +95433,16 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75093,8 +95454,27 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75170,6 +95550,8 @@ func (s *Server) handleTestRequestStringUnixSecondsNullableArrayArrayRequest(arg // // POST /test_response_Any func (s *Server) handleTestResponseAnyRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_Any"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75191,7 +95573,16 @@ func (s *Server) handleTestResponseAnyRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75203,8 +95594,27 @@ func (s *Server) handleTestResponseAnyRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75280,6 +95690,8 @@ func (s *Server) handleTestResponseAnyRequest(args [0]string, argsEscaped bool, // // POST /test_response_boolean func (s *Server) handleTestResponseBooleanRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_boolean"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75301,7 +95713,16 @@ func (s *Server) handleTestResponseBooleanRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75313,8 +95734,27 @@ func (s *Server) handleTestResponseBooleanRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75390,6 +95830,8 @@ func (s *Server) handleTestResponseBooleanRequest(args [0]string, argsEscaped bo // // POST /test_response_boolean_array func (s *Server) handleTestResponseBooleanArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_boolean_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75411,7 +95853,16 @@ func (s *Server) handleTestResponseBooleanArrayRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75423,8 +95874,27 @@ func (s *Server) handleTestResponseBooleanArrayRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75500,6 +95970,8 @@ func (s *Server) handleTestResponseBooleanArrayRequest(args [0]string, argsEscap // // POST /test_response_boolean_array_array func (s *Server) handleTestResponseBooleanArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_boolean_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75521,7 +95993,16 @@ func (s *Server) handleTestResponseBooleanArrayArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75533,8 +96014,27 @@ func (s *Server) handleTestResponseBooleanArrayArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75610,6 +96110,8 @@ func (s *Server) handleTestResponseBooleanArrayArrayRequest(args [0]string, args // // POST /test_response_boolean_nullable func (s *Server) handleTestResponseBooleanNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_boolean_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75631,7 +96133,16 @@ func (s *Server) handleTestResponseBooleanNullableRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75643,8 +96154,27 @@ func (s *Server) handleTestResponseBooleanNullableRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75720,6 +96250,8 @@ func (s *Server) handleTestResponseBooleanNullableRequest(args [0]string, argsEs // // POST /test_response_boolean_nullable_array func (s *Server) handleTestResponseBooleanNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_boolean_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75741,7 +96273,16 @@ func (s *Server) handleTestResponseBooleanNullableArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75753,8 +96294,27 @@ func (s *Server) handleTestResponseBooleanNullableArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75830,6 +96390,8 @@ func (s *Server) handleTestResponseBooleanNullableArrayRequest(args [0]string, a // // POST /test_response_boolean_nullable_array_array func (s *Server) handleTestResponseBooleanNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_boolean_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75851,7 +96413,16 @@ func (s *Server) handleTestResponseBooleanNullableArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75863,8 +96434,27 @@ func (s *Server) handleTestResponseBooleanNullableArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -75940,6 +96530,8 @@ func (s *Server) handleTestResponseBooleanNullableArrayArrayRequest(args [0]stri // // POST /test_response_EmptyStruct func (s *Server) handleTestResponseEmptyStructRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_EmptyStruct"), semconv.HTTPRequestMethodKey.String("POST"), @@ -75961,7 +96553,16 @@ func (s *Server) handleTestResponseEmptyStructRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -75973,8 +96574,27 @@ func (s *Server) handleTestResponseEmptyStructRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76050,6 +96670,8 @@ func (s *Server) handleTestResponseEmptyStructRequest(args [0]string, argsEscape // // POST /test_response_FormatTest func (s *Server) handleTestResponseFormatTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_FormatTest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76071,7 +96693,16 @@ func (s *Server) handleTestResponseFormatTestRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76083,8 +96714,27 @@ func (s *Server) handleTestResponseFormatTestRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76160,6 +96810,8 @@ func (s *Server) handleTestResponseFormatTestRequest(args [0]string, argsEscaped // // POST /test_response_integer func (s *Server) handleTestResponseIntegerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76181,7 +96833,16 @@ func (s *Server) handleTestResponseIntegerRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76193,8 +96854,27 @@ func (s *Server) handleTestResponseIntegerRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76270,6 +96950,8 @@ func (s *Server) handleTestResponseIntegerRequest(args [0]string, argsEscaped bo // // POST /test_response_integer_array func (s *Server) handleTestResponseIntegerArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76291,7 +96973,16 @@ func (s *Server) handleTestResponseIntegerArrayRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76303,8 +96994,27 @@ func (s *Server) handleTestResponseIntegerArrayRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76380,6 +97090,8 @@ func (s *Server) handleTestResponseIntegerArrayRequest(args [0]string, argsEscap // // POST /test_response_integer_array_array func (s *Server) handleTestResponseIntegerArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76401,7 +97113,16 @@ func (s *Server) handleTestResponseIntegerArrayArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76413,8 +97134,27 @@ func (s *Server) handleTestResponseIntegerArrayArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76490,6 +97230,8 @@ func (s *Server) handleTestResponseIntegerArrayArrayRequest(args [0]string, args // // POST /test_response_integer_int16 func (s *Server) handleTestResponseIntegerInt16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76511,7 +97253,16 @@ func (s *Server) handleTestResponseIntegerInt16Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76523,8 +97274,27 @@ func (s *Server) handleTestResponseIntegerInt16Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76600,6 +97370,8 @@ func (s *Server) handleTestResponseIntegerInt16Request(args [0]string, argsEscap // // POST /test_response_integer_int16_array func (s *Server) handleTestResponseIntegerInt16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76621,7 +97393,16 @@ func (s *Server) handleTestResponseIntegerInt16ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76633,8 +97414,27 @@ func (s *Server) handleTestResponseIntegerInt16ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76710,6 +97510,8 @@ func (s *Server) handleTestResponseIntegerInt16ArrayRequest(args [0]string, args // // POST /test_response_integer_int16_array_array func (s *Server) handleTestResponseIntegerInt16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76731,7 +97533,16 @@ func (s *Server) handleTestResponseIntegerInt16ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76743,8 +97554,27 @@ func (s *Server) handleTestResponseIntegerInt16ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76820,6 +97650,8 @@ func (s *Server) handleTestResponseIntegerInt16ArrayArrayRequest(args [0]string, // // POST /test_response_integer_int16_nullable func (s *Server) handleTestResponseIntegerInt16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76841,7 +97673,16 @@ func (s *Server) handleTestResponseIntegerInt16NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76853,8 +97694,27 @@ func (s *Server) handleTestResponseIntegerInt16NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -76930,6 +97790,8 @@ func (s *Server) handleTestResponseIntegerInt16NullableRequest(args [0]string, a // // POST /test_response_integer_int16_nullable_array func (s *Server) handleTestResponseIntegerInt16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -76951,7 +97813,16 @@ func (s *Server) handleTestResponseIntegerInt16NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -76963,8 +97834,27 @@ func (s *Server) handleTestResponseIntegerInt16NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77040,6 +97930,8 @@ func (s *Server) handleTestResponseIntegerInt16NullableArrayRequest(args [0]stri // // POST /test_response_integer_int16_nullable_array_array func (s *Server) handleTestResponseIntegerInt16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77061,7 +97953,16 @@ func (s *Server) handleTestResponseIntegerInt16NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77073,8 +97974,27 @@ func (s *Server) handleTestResponseIntegerInt16NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77150,6 +98070,8 @@ func (s *Server) handleTestResponseIntegerInt16NullableArrayArrayRequest(args [0 // // POST /test_response_integer_int32 func (s *Server) handleTestResponseIntegerInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77171,7 +98093,16 @@ func (s *Server) handleTestResponseIntegerInt32Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77183,8 +98114,27 @@ func (s *Server) handleTestResponseIntegerInt32Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77260,6 +98210,8 @@ func (s *Server) handleTestResponseIntegerInt32Request(args [0]string, argsEscap // // POST /test_response_integer_int32_array func (s *Server) handleTestResponseIntegerInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77281,7 +98233,16 @@ func (s *Server) handleTestResponseIntegerInt32ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77293,8 +98254,27 @@ func (s *Server) handleTestResponseIntegerInt32ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77370,6 +98350,8 @@ func (s *Server) handleTestResponseIntegerInt32ArrayRequest(args [0]string, args // // POST /test_response_integer_int32_array_array func (s *Server) handleTestResponseIntegerInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77391,7 +98373,16 @@ func (s *Server) handleTestResponseIntegerInt32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77403,8 +98394,27 @@ func (s *Server) handleTestResponseIntegerInt32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77480,6 +98490,8 @@ func (s *Server) handleTestResponseIntegerInt32ArrayArrayRequest(args [0]string, // // POST /test_response_integer_int32_nullable func (s *Server) handleTestResponseIntegerInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77501,7 +98513,16 @@ func (s *Server) handleTestResponseIntegerInt32NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77513,8 +98534,27 @@ func (s *Server) handleTestResponseIntegerInt32NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77590,6 +98630,8 @@ func (s *Server) handleTestResponseIntegerInt32NullableRequest(args [0]string, a // // POST /test_response_integer_int32_nullable_array func (s *Server) handleTestResponseIntegerInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77611,7 +98653,16 @@ func (s *Server) handleTestResponseIntegerInt32NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77623,8 +98674,27 @@ func (s *Server) handleTestResponseIntegerInt32NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77700,6 +98770,8 @@ func (s *Server) handleTestResponseIntegerInt32NullableArrayRequest(args [0]stri // // POST /test_response_integer_int32_nullable_array_array func (s *Server) handleTestResponseIntegerInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77721,7 +98793,16 @@ func (s *Server) handleTestResponseIntegerInt32NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77733,8 +98814,27 @@ func (s *Server) handleTestResponseIntegerInt32NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77810,6 +98910,8 @@ func (s *Server) handleTestResponseIntegerInt32NullableArrayArrayRequest(args [0 // // POST /test_response_integer_int64 func (s *Server) handleTestResponseIntegerInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77831,7 +98933,16 @@ func (s *Server) handleTestResponseIntegerInt64Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77843,8 +98954,27 @@ func (s *Server) handleTestResponseIntegerInt64Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -77920,6 +99050,8 @@ func (s *Server) handleTestResponseIntegerInt64Request(args [0]string, argsEscap // // POST /test_response_integer_int64_array func (s *Server) handleTestResponseIntegerInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -77941,7 +99073,16 @@ func (s *Server) handleTestResponseIntegerInt64ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -77953,8 +99094,27 @@ func (s *Server) handleTestResponseIntegerInt64ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78030,6 +99190,8 @@ func (s *Server) handleTestResponseIntegerInt64ArrayRequest(args [0]string, args // // POST /test_response_integer_int64_array_array func (s *Server) handleTestResponseIntegerInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78051,7 +99213,16 @@ func (s *Server) handleTestResponseIntegerInt64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78063,8 +99234,27 @@ func (s *Server) handleTestResponseIntegerInt64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78140,6 +99330,8 @@ func (s *Server) handleTestResponseIntegerInt64ArrayArrayRequest(args [0]string, // // POST /test_response_integer_int64_nullable func (s *Server) handleTestResponseIntegerInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78161,7 +99353,16 @@ func (s *Server) handleTestResponseIntegerInt64NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78173,8 +99374,27 @@ func (s *Server) handleTestResponseIntegerInt64NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78250,6 +99470,8 @@ func (s *Server) handleTestResponseIntegerInt64NullableRequest(args [0]string, a // // POST /test_response_integer_int64_nullable_array func (s *Server) handleTestResponseIntegerInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78271,7 +99493,16 @@ func (s *Server) handleTestResponseIntegerInt64NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78283,8 +99514,27 @@ func (s *Server) handleTestResponseIntegerInt64NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78360,6 +99610,8 @@ func (s *Server) handleTestResponseIntegerInt64NullableArrayRequest(args [0]stri // // POST /test_response_integer_int64_nullable_array_array func (s *Server) handleTestResponseIntegerInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78381,7 +99633,16 @@ func (s *Server) handleTestResponseIntegerInt64NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78393,8 +99654,27 @@ func (s *Server) handleTestResponseIntegerInt64NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78470,6 +99750,8 @@ func (s *Server) handleTestResponseIntegerInt64NullableArrayArrayRequest(args [0 // // POST /test_response_integer_int8 func (s *Server) handleTestResponseIntegerInt8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78491,7 +99773,16 @@ func (s *Server) handleTestResponseIntegerInt8Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78503,8 +99794,27 @@ func (s *Server) handleTestResponseIntegerInt8Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78580,6 +99890,8 @@ func (s *Server) handleTestResponseIntegerInt8Request(args [0]string, argsEscape // // POST /test_response_integer_int8_array func (s *Server) handleTestResponseIntegerInt8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78601,7 +99913,16 @@ func (s *Server) handleTestResponseIntegerInt8ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78613,8 +99934,27 @@ func (s *Server) handleTestResponseIntegerInt8ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78690,6 +100030,8 @@ func (s *Server) handleTestResponseIntegerInt8ArrayRequest(args [0]string, argsE // // POST /test_response_integer_int8_array_array func (s *Server) handleTestResponseIntegerInt8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78711,7 +100053,16 @@ func (s *Server) handleTestResponseIntegerInt8ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78723,8 +100074,27 @@ func (s *Server) handleTestResponseIntegerInt8ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78800,6 +100170,8 @@ func (s *Server) handleTestResponseIntegerInt8ArrayArrayRequest(args [0]string, // // POST /test_response_integer_int8_nullable func (s *Server) handleTestResponseIntegerInt8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78821,7 +100193,16 @@ func (s *Server) handleTestResponseIntegerInt8NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78833,8 +100214,27 @@ func (s *Server) handleTestResponseIntegerInt8NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -78910,6 +100310,8 @@ func (s *Server) handleTestResponseIntegerInt8NullableRequest(args [0]string, ar // // POST /test_response_integer_int8_nullable_array func (s *Server) handleTestResponseIntegerInt8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -78931,7 +100333,16 @@ func (s *Server) handleTestResponseIntegerInt8NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -78943,8 +100354,27 @@ func (s *Server) handleTestResponseIntegerInt8NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79020,6 +100450,8 @@ func (s *Server) handleTestResponseIntegerInt8NullableArrayRequest(args [0]strin // // POST /test_response_integer_int8_nullable_array_array func (s *Server) handleTestResponseIntegerInt8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_int8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79041,7 +100473,16 @@ func (s *Server) handleTestResponseIntegerInt8NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79053,8 +100494,27 @@ func (s *Server) handleTestResponseIntegerInt8NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79130,6 +100590,8 @@ func (s *Server) handleTestResponseIntegerInt8NullableArrayArrayRequest(args [0] // // POST /test_response_integer_nullable func (s *Server) handleTestResponseIntegerNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79151,7 +100613,16 @@ func (s *Server) handleTestResponseIntegerNullableRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79163,8 +100634,27 @@ func (s *Server) handleTestResponseIntegerNullableRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79240,6 +100730,8 @@ func (s *Server) handleTestResponseIntegerNullableRequest(args [0]string, argsEs // // POST /test_response_integer_nullable_array func (s *Server) handleTestResponseIntegerNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79261,7 +100753,16 @@ func (s *Server) handleTestResponseIntegerNullableArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79273,8 +100774,27 @@ func (s *Server) handleTestResponseIntegerNullableArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79350,6 +100870,8 @@ func (s *Server) handleTestResponseIntegerNullableArrayRequest(args [0]string, a // // POST /test_response_integer_nullable_array_array func (s *Server) handleTestResponseIntegerNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79371,7 +100893,16 @@ func (s *Server) handleTestResponseIntegerNullableArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79383,8 +100914,27 @@ func (s *Server) handleTestResponseIntegerNullableArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79460,6 +101010,8 @@ func (s *Server) handleTestResponseIntegerNullableArrayArrayRequest(args [0]stri // // POST /test_response_integer_uint func (s *Server) handleTestResponseIntegerUintRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79481,7 +101033,16 @@ func (s *Server) handleTestResponseIntegerUintRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79493,8 +101054,27 @@ func (s *Server) handleTestResponseIntegerUintRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79570,6 +101150,8 @@ func (s *Server) handleTestResponseIntegerUintRequest(args [0]string, argsEscape // // POST /test_response_integer_uint16 func (s *Server) handleTestResponseIntegerUint16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79591,7 +101173,16 @@ func (s *Server) handleTestResponseIntegerUint16Request(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79603,8 +101194,27 @@ func (s *Server) handleTestResponseIntegerUint16Request(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79680,6 +101290,8 @@ func (s *Server) handleTestResponseIntegerUint16Request(args [0]string, argsEsca // // POST /test_response_integer_uint16_array func (s *Server) handleTestResponseIntegerUint16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79701,7 +101313,16 @@ func (s *Server) handleTestResponseIntegerUint16ArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79713,8 +101334,27 @@ func (s *Server) handleTestResponseIntegerUint16ArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79790,6 +101430,8 @@ func (s *Server) handleTestResponseIntegerUint16ArrayRequest(args [0]string, arg // // POST /test_response_integer_uint16_array_array func (s *Server) handleTestResponseIntegerUint16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79811,7 +101453,16 @@ func (s *Server) handleTestResponseIntegerUint16ArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79823,8 +101474,27 @@ func (s *Server) handleTestResponseIntegerUint16ArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -79900,6 +101570,8 @@ func (s *Server) handleTestResponseIntegerUint16ArrayArrayRequest(args [0]string // // POST /test_response_integer_uint16_nullable func (s *Server) handleTestResponseIntegerUint16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -79921,7 +101593,16 @@ func (s *Server) handleTestResponseIntegerUint16NullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79933,8 +101614,27 @@ func (s *Server) handleTestResponseIntegerUint16NullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80010,6 +101710,8 @@ func (s *Server) handleTestResponseIntegerUint16NullableRequest(args [0]string, // // POST /test_response_integer_uint16_nullable_array func (s *Server) handleTestResponseIntegerUint16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80031,7 +101733,16 @@ func (s *Server) handleTestResponseIntegerUint16NullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80043,8 +101754,27 @@ func (s *Server) handleTestResponseIntegerUint16NullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80120,6 +101850,8 @@ func (s *Server) handleTestResponseIntegerUint16NullableArrayRequest(args [0]str // // POST /test_response_integer_uint16_nullable_array_array func (s *Server) handleTestResponseIntegerUint16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80141,7 +101873,16 @@ func (s *Server) handleTestResponseIntegerUint16NullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80153,8 +101894,27 @@ func (s *Server) handleTestResponseIntegerUint16NullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80230,6 +101990,8 @@ func (s *Server) handleTestResponseIntegerUint16NullableArrayArrayRequest(args [ // // POST /test_response_integer_uint32 func (s *Server) handleTestResponseIntegerUint32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80251,7 +102013,16 @@ func (s *Server) handleTestResponseIntegerUint32Request(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80263,8 +102034,27 @@ func (s *Server) handleTestResponseIntegerUint32Request(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80340,6 +102130,8 @@ func (s *Server) handleTestResponseIntegerUint32Request(args [0]string, argsEsca // // POST /test_response_integer_uint32_array func (s *Server) handleTestResponseIntegerUint32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80361,7 +102153,16 @@ func (s *Server) handleTestResponseIntegerUint32ArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80373,8 +102174,27 @@ func (s *Server) handleTestResponseIntegerUint32ArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80450,6 +102270,8 @@ func (s *Server) handleTestResponseIntegerUint32ArrayRequest(args [0]string, arg // // POST /test_response_integer_uint32_array_array func (s *Server) handleTestResponseIntegerUint32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80471,7 +102293,16 @@ func (s *Server) handleTestResponseIntegerUint32ArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80483,8 +102314,27 @@ func (s *Server) handleTestResponseIntegerUint32ArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80560,6 +102410,8 @@ func (s *Server) handleTestResponseIntegerUint32ArrayArrayRequest(args [0]string // // POST /test_response_integer_uint32_nullable func (s *Server) handleTestResponseIntegerUint32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80581,7 +102433,16 @@ func (s *Server) handleTestResponseIntegerUint32NullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80593,8 +102454,27 @@ func (s *Server) handleTestResponseIntegerUint32NullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80670,6 +102550,8 @@ func (s *Server) handleTestResponseIntegerUint32NullableRequest(args [0]string, // // POST /test_response_integer_uint32_nullable_array func (s *Server) handleTestResponseIntegerUint32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80691,7 +102573,16 @@ func (s *Server) handleTestResponseIntegerUint32NullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80703,8 +102594,27 @@ func (s *Server) handleTestResponseIntegerUint32NullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80780,6 +102690,8 @@ func (s *Server) handleTestResponseIntegerUint32NullableArrayRequest(args [0]str // // POST /test_response_integer_uint32_nullable_array_array func (s *Server) handleTestResponseIntegerUint32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80801,7 +102713,16 @@ func (s *Server) handleTestResponseIntegerUint32NullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80813,8 +102734,27 @@ func (s *Server) handleTestResponseIntegerUint32NullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -80890,6 +102830,8 @@ func (s *Server) handleTestResponseIntegerUint32NullableArrayArrayRequest(args [ // // POST /test_response_integer_uint64 func (s *Server) handleTestResponseIntegerUint64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -80911,7 +102853,16 @@ func (s *Server) handleTestResponseIntegerUint64Request(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -80923,8 +102874,27 @@ func (s *Server) handleTestResponseIntegerUint64Request(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81000,6 +102970,8 @@ func (s *Server) handleTestResponseIntegerUint64Request(args [0]string, argsEsca // // POST /test_response_integer_uint64_array func (s *Server) handleTestResponseIntegerUint64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81021,7 +102993,16 @@ func (s *Server) handleTestResponseIntegerUint64ArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81033,8 +103014,27 @@ func (s *Server) handleTestResponseIntegerUint64ArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81110,6 +103110,8 @@ func (s *Server) handleTestResponseIntegerUint64ArrayRequest(args [0]string, arg // // POST /test_response_integer_uint64_array_array func (s *Server) handleTestResponseIntegerUint64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81131,7 +103133,16 @@ func (s *Server) handleTestResponseIntegerUint64ArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81143,8 +103154,27 @@ func (s *Server) handleTestResponseIntegerUint64ArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81220,6 +103250,8 @@ func (s *Server) handleTestResponseIntegerUint64ArrayArrayRequest(args [0]string // // POST /test_response_integer_uint64_nullable func (s *Server) handleTestResponseIntegerUint64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81241,7 +103273,16 @@ func (s *Server) handleTestResponseIntegerUint64NullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81253,8 +103294,27 @@ func (s *Server) handleTestResponseIntegerUint64NullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81330,6 +103390,8 @@ func (s *Server) handleTestResponseIntegerUint64NullableRequest(args [0]string, // // POST /test_response_integer_uint64_nullable_array func (s *Server) handleTestResponseIntegerUint64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81351,7 +103413,16 @@ func (s *Server) handleTestResponseIntegerUint64NullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81363,8 +103434,27 @@ func (s *Server) handleTestResponseIntegerUint64NullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81440,6 +103530,8 @@ func (s *Server) handleTestResponseIntegerUint64NullableArrayRequest(args [0]str // // POST /test_response_integer_uint64_nullable_array_array func (s *Server) handleTestResponseIntegerUint64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81461,7 +103553,16 @@ func (s *Server) handleTestResponseIntegerUint64NullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81473,8 +103574,27 @@ func (s *Server) handleTestResponseIntegerUint64NullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81550,6 +103670,8 @@ func (s *Server) handleTestResponseIntegerUint64NullableArrayArrayRequest(args [ // // POST /test_response_integer_uint8 func (s *Server) handleTestResponseIntegerUint8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81571,7 +103693,16 @@ func (s *Server) handleTestResponseIntegerUint8Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81583,8 +103714,27 @@ func (s *Server) handleTestResponseIntegerUint8Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81660,6 +103810,8 @@ func (s *Server) handleTestResponseIntegerUint8Request(args [0]string, argsEscap // // POST /test_response_integer_uint8_array func (s *Server) handleTestResponseIntegerUint8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81681,7 +103833,16 @@ func (s *Server) handleTestResponseIntegerUint8ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81693,8 +103854,27 @@ func (s *Server) handleTestResponseIntegerUint8ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81770,6 +103950,8 @@ func (s *Server) handleTestResponseIntegerUint8ArrayRequest(args [0]string, args // // POST /test_response_integer_uint8_array_array func (s *Server) handleTestResponseIntegerUint8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81791,7 +103973,16 @@ func (s *Server) handleTestResponseIntegerUint8ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81803,8 +103994,27 @@ func (s *Server) handleTestResponseIntegerUint8ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81880,6 +104090,8 @@ func (s *Server) handleTestResponseIntegerUint8ArrayArrayRequest(args [0]string, // // POST /test_response_integer_uint8_nullable func (s *Server) handleTestResponseIntegerUint8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -81901,7 +104113,16 @@ func (s *Server) handleTestResponseIntegerUint8NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -81913,8 +104134,27 @@ func (s *Server) handleTestResponseIntegerUint8NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -81990,6 +104230,8 @@ func (s *Server) handleTestResponseIntegerUint8NullableRequest(args [0]string, a // // POST /test_response_integer_uint8_nullable_array func (s *Server) handleTestResponseIntegerUint8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82011,7 +104253,16 @@ func (s *Server) handleTestResponseIntegerUint8NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82023,8 +104274,27 @@ func (s *Server) handleTestResponseIntegerUint8NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82100,6 +104370,8 @@ func (s *Server) handleTestResponseIntegerUint8NullableArrayRequest(args [0]stri // // POST /test_response_integer_uint8_nullable_array_array func (s *Server) handleTestResponseIntegerUint8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82121,7 +104393,16 @@ func (s *Server) handleTestResponseIntegerUint8NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82133,8 +104414,27 @@ func (s *Server) handleTestResponseIntegerUint8NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82210,6 +104510,8 @@ func (s *Server) handleTestResponseIntegerUint8NullableArrayArrayRequest(args [0 // // POST /test_response_integer_uint_array func (s *Server) handleTestResponseIntegerUintArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82231,7 +104533,16 @@ func (s *Server) handleTestResponseIntegerUintArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82243,8 +104554,27 @@ func (s *Server) handleTestResponseIntegerUintArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82320,6 +104650,8 @@ func (s *Server) handleTestResponseIntegerUintArrayRequest(args [0]string, argsE // // POST /test_response_integer_uint_array_array func (s *Server) handleTestResponseIntegerUintArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82341,7 +104673,16 @@ func (s *Server) handleTestResponseIntegerUintArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82353,8 +104694,27 @@ func (s *Server) handleTestResponseIntegerUintArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82430,6 +104790,8 @@ func (s *Server) handleTestResponseIntegerUintArrayArrayRequest(args [0]string, // // POST /test_response_integer_uint_nullable func (s *Server) handleTestResponseIntegerUintNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82451,7 +104813,16 @@ func (s *Server) handleTestResponseIntegerUintNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82463,8 +104834,27 @@ func (s *Server) handleTestResponseIntegerUintNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82540,6 +104930,8 @@ func (s *Server) handleTestResponseIntegerUintNullableRequest(args [0]string, ar // // POST /test_response_integer_uint_nullable_array func (s *Server) handleTestResponseIntegerUintNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82561,7 +104953,16 @@ func (s *Server) handleTestResponseIntegerUintNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82573,8 +104974,27 @@ func (s *Server) handleTestResponseIntegerUintNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82650,6 +105070,8 @@ func (s *Server) handleTestResponseIntegerUintNullableArrayRequest(args [0]strin // // POST /test_response_integer_uint_nullable_array_array func (s *Server) handleTestResponseIntegerUintNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_uint_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82671,7 +105093,16 @@ func (s *Server) handleTestResponseIntegerUintNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82683,8 +105114,27 @@ func (s *Server) handleTestResponseIntegerUintNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82760,6 +105210,8 @@ func (s *Server) handleTestResponseIntegerUintNullableArrayArrayRequest(args [0] // // POST /test_response_integer_unix func (s *Server) handleTestResponseIntegerUnixRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82781,7 +105233,16 @@ func (s *Server) handleTestResponseIntegerUnixRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82793,8 +105254,27 @@ func (s *Server) handleTestResponseIntegerUnixRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82870,6 +105350,8 @@ func (s *Server) handleTestResponseIntegerUnixRequest(args [0]string, argsEscape // // POST /test_response_integer_unix_array func (s *Server) handleTestResponseIntegerUnixArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -82891,7 +105373,16 @@ func (s *Server) handleTestResponseIntegerUnixArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -82903,8 +105394,27 @@ func (s *Server) handleTestResponseIntegerUnixArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -82980,6 +105490,8 @@ func (s *Server) handleTestResponseIntegerUnixArrayRequest(args [0]string, argsE // // POST /test_response_integer_unix_array_array func (s *Server) handleTestResponseIntegerUnixArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83001,7 +105513,16 @@ func (s *Server) handleTestResponseIntegerUnixArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83013,8 +105534,27 @@ func (s *Server) handleTestResponseIntegerUnixArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83090,6 +105630,8 @@ func (s *Server) handleTestResponseIntegerUnixArrayArrayRequest(args [0]string, // // POST /test_response_integer_unix-micro func (s *Server) handleTestResponseIntegerUnixMicroRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-micro"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83111,7 +105653,16 @@ func (s *Server) handleTestResponseIntegerUnixMicroRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83123,8 +105674,27 @@ func (s *Server) handleTestResponseIntegerUnixMicroRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83200,6 +105770,8 @@ func (s *Server) handleTestResponseIntegerUnixMicroRequest(args [0]string, argsE // // POST /test_response_integer_unix-micro_array func (s *Server) handleTestResponseIntegerUnixMicroArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-micro_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83221,7 +105793,16 @@ func (s *Server) handleTestResponseIntegerUnixMicroArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83233,8 +105814,27 @@ func (s *Server) handleTestResponseIntegerUnixMicroArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83310,6 +105910,8 @@ func (s *Server) handleTestResponseIntegerUnixMicroArrayRequest(args [0]string, // // POST /test_response_integer_unix-micro_array_array func (s *Server) handleTestResponseIntegerUnixMicroArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-micro_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83331,7 +105933,16 @@ func (s *Server) handleTestResponseIntegerUnixMicroArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83343,8 +105954,27 @@ func (s *Server) handleTestResponseIntegerUnixMicroArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83420,6 +106050,8 @@ func (s *Server) handleTestResponseIntegerUnixMicroArrayArrayRequest(args [0]str // // POST /test_response_integer_unix-micro_nullable func (s *Server) handleTestResponseIntegerUnixMicroNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-micro_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83441,7 +106073,16 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83453,8 +106094,27 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83530,6 +106190,8 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableRequest(args [0]strin // // POST /test_response_integer_unix-micro_nullable_array func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-micro_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83551,7 +106213,16 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83563,8 +106234,27 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83640,6 +106330,8 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayRequest(args [0] // // POST /test_response_integer_unix-micro_nullable_array_array func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-micro_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83661,7 +106353,16 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83673,8 +106374,27 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83750,6 +106470,8 @@ func (s *Server) handleTestResponseIntegerUnixMicroNullableArrayArrayRequest(arg // // POST /test_response_integer_unix-milli func (s *Server) handleTestResponseIntegerUnixMilliRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-milli"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83771,7 +106493,16 @@ func (s *Server) handleTestResponseIntegerUnixMilliRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83783,8 +106514,27 @@ func (s *Server) handleTestResponseIntegerUnixMilliRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83860,6 +106610,8 @@ func (s *Server) handleTestResponseIntegerUnixMilliRequest(args [0]string, argsE // // POST /test_response_integer_unix-milli_array func (s *Server) handleTestResponseIntegerUnixMilliArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-milli_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83881,7 +106633,16 @@ func (s *Server) handleTestResponseIntegerUnixMilliArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -83893,8 +106654,27 @@ func (s *Server) handleTestResponseIntegerUnixMilliArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -83970,6 +106750,8 @@ func (s *Server) handleTestResponseIntegerUnixMilliArrayRequest(args [0]string, // // POST /test_response_integer_unix-milli_array_array func (s *Server) handleTestResponseIntegerUnixMilliArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-milli_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -83991,7 +106773,16 @@ func (s *Server) handleTestResponseIntegerUnixMilliArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84003,8 +106794,27 @@ func (s *Server) handleTestResponseIntegerUnixMilliArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84080,6 +106890,8 @@ func (s *Server) handleTestResponseIntegerUnixMilliArrayArrayRequest(args [0]str // // POST /test_response_integer_unix-milli_nullable func (s *Server) handleTestResponseIntegerUnixMilliNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-milli_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84101,7 +106913,16 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84113,8 +106934,27 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84190,6 +107030,8 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableRequest(args [0]strin // // POST /test_response_integer_unix-milli_nullable_array func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-milli_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84211,7 +107053,16 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84223,8 +107074,27 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84300,6 +107170,8 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayRequest(args [0] // // POST /test_response_integer_unix-milli_nullable_array_array func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-milli_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84321,7 +107193,16 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayArrayRequest(arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84333,8 +107214,27 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayArrayRequest(arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84410,6 +107310,8 @@ func (s *Server) handleTestResponseIntegerUnixMilliNullableArrayArrayRequest(arg // // POST /test_response_integer_unix-nano func (s *Server) handleTestResponseIntegerUnixNanoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-nano"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84431,7 +107333,16 @@ func (s *Server) handleTestResponseIntegerUnixNanoRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84443,8 +107354,27 @@ func (s *Server) handleTestResponseIntegerUnixNanoRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84520,6 +107450,8 @@ func (s *Server) handleTestResponseIntegerUnixNanoRequest(args [0]string, argsEs // // POST /test_response_integer_unix-nano_array func (s *Server) handleTestResponseIntegerUnixNanoArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-nano_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84541,7 +107473,16 @@ func (s *Server) handleTestResponseIntegerUnixNanoArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84553,8 +107494,27 @@ func (s *Server) handleTestResponseIntegerUnixNanoArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84630,6 +107590,8 @@ func (s *Server) handleTestResponseIntegerUnixNanoArrayRequest(args [0]string, a // // POST /test_response_integer_unix-nano_array_array func (s *Server) handleTestResponseIntegerUnixNanoArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-nano_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84651,7 +107613,16 @@ func (s *Server) handleTestResponseIntegerUnixNanoArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84663,8 +107634,27 @@ func (s *Server) handleTestResponseIntegerUnixNanoArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84740,6 +107730,8 @@ func (s *Server) handleTestResponseIntegerUnixNanoArrayArrayRequest(args [0]stri // // POST /test_response_integer_unix-nano_nullable func (s *Server) handleTestResponseIntegerUnixNanoNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-nano_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84761,7 +107753,16 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84773,8 +107774,27 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84850,6 +107870,8 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableRequest(args [0]string // // POST /test_response_integer_unix-nano_nullable_array func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-nano_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84871,7 +107893,16 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84883,8 +107914,27 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -84960,6 +108010,8 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayRequest(args [0]s // // POST /test_response_integer_unix-nano_nullable_array_array func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-nano_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -84981,7 +108033,16 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -84993,8 +108054,27 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85070,6 +108150,8 @@ func (s *Server) handleTestResponseIntegerUnixNanoNullableArrayArrayRequest(args // // POST /test_response_integer_unix_nullable func (s *Server) handleTestResponseIntegerUnixNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85091,7 +108173,16 @@ func (s *Server) handleTestResponseIntegerUnixNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85103,8 +108194,27 @@ func (s *Server) handleTestResponseIntegerUnixNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85180,6 +108290,8 @@ func (s *Server) handleTestResponseIntegerUnixNullableRequest(args [0]string, ar // // POST /test_response_integer_unix_nullable_array func (s *Server) handleTestResponseIntegerUnixNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85201,7 +108313,16 @@ func (s *Server) handleTestResponseIntegerUnixNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85213,8 +108334,27 @@ func (s *Server) handleTestResponseIntegerUnixNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85290,6 +108430,8 @@ func (s *Server) handleTestResponseIntegerUnixNullableArrayRequest(args [0]strin // // POST /test_response_integer_unix_nullable_array_array func (s *Server) handleTestResponseIntegerUnixNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85311,7 +108453,16 @@ func (s *Server) handleTestResponseIntegerUnixNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85323,8 +108474,27 @@ func (s *Server) handleTestResponseIntegerUnixNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85400,6 +108570,8 @@ func (s *Server) handleTestResponseIntegerUnixNullableArrayArrayRequest(args [0] // // POST /test_response_integer_unix-seconds func (s *Server) handleTestResponseIntegerUnixSecondsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-seconds"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85421,7 +108593,16 @@ func (s *Server) handleTestResponseIntegerUnixSecondsRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85433,8 +108614,27 @@ func (s *Server) handleTestResponseIntegerUnixSecondsRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85510,6 +108710,8 @@ func (s *Server) handleTestResponseIntegerUnixSecondsRequest(args [0]string, arg // // POST /test_response_integer_unix-seconds_array func (s *Server) handleTestResponseIntegerUnixSecondsArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-seconds_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85531,7 +108733,16 @@ func (s *Server) handleTestResponseIntegerUnixSecondsArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85543,8 +108754,27 @@ func (s *Server) handleTestResponseIntegerUnixSecondsArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85620,6 +108850,8 @@ func (s *Server) handleTestResponseIntegerUnixSecondsArrayRequest(args [0]string // // POST /test_response_integer_unix-seconds_array_array func (s *Server) handleTestResponseIntegerUnixSecondsArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-seconds_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85641,7 +108873,16 @@ func (s *Server) handleTestResponseIntegerUnixSecondsArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85653,8 +108894,27 @@ func (s *Server) handleTestResponseIntegerUnixSecondsArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85730,6 +108990,8 @@ func (s *Server) handleTestResponseIntegerUnixSecondsArrayArrayRequest(args [0]s // // POST /test_response_integer_unix-seconds_nullable func (s *Server) handleTestResponseIntegerUnixSecondsNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-seconds_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85751,7 +109013,16 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85763,8 +109034,27 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85840,6 +109130,8 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableRequest(args [0]str // // POST /test_response_integer_unix-seconds_nullable_array func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-seconds_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85861,7 +109153,16 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85873,8 +109174,27 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -85950,6 +109270,8 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayRequest(args [ // // POST /test_response_integer_unix-seconds_nullable_array_array func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_integer_unix-seconds_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -85971,7 +109293,16 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayArrayRequest(a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -85983,8 +109314,27 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayArrayRequest(a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86060,6 +109410,8 @@ func (s *Server) handleTestResponseIntegerUnixSecondsNullableArrayArrayRequest(a // // POST /test_response_null func (s *Server) handleTestResponseNullRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_null"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86081,7 +109433,16 @@ func (s *Server) handleTestResponseNullRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86093,8 +109454,27 @@ func (s *Server) handleTestResponseNullRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86170,6 +109550,8 @@ func (s *Server) handleTestResponseNullRequest(args [0]string, argsEscaped bool, // // POST /test_response_null_array func (s *Server) handleTestResponseNullArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_null_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86191,7 +109573,16 @@ func (s *Server) handleTestResponseNullArrayRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86203,8 +109594,27 @@ func (s *Server) handleTestResponseNullArrayRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86280,6 +109690,8 @@ func (s *Server) handleTestResponseNullArrayRequest(args [0]string, argsEscaped // // POST /test_response_null_array_array func (s *Server) handleTestResponseNullArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_null_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86301,7 +109713,16 @@ func (s *Server) handleTestResponseNullArrayArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86313,8 +109734,27 @@ func (s *Server) handleTestResponseNullArrayArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86390,6 +109830,8 @@ func (s *Server) handleTestResponseNullArrayArrayRequest(args [0]string, argsEsc // // POST /test_response_null_nullable func (s *Server) handleTestResponseNullNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_null_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86411,7 +109853,16 @@ func (s *Server) handleTestResponseNullNullableRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86423,8 +109874,27 @@ func (s *Server) handleTestResponseNullNullableRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86500,6 +109970,8 @@ func (s *Server) handleTestResponseNullNullableRequest(args [0]string, argsEscap // // POST /test_response_null_nullable_array func (s *Server) handleTestResponseNullNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_null_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86521,7 +109993,16 @@ func (s *Server) handleTestResponseNullNullableArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86533,8 +110014,27 @@ func (s *Server) handleTestResponseNullNullableArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86610,6 +110110,8 @@ func (s *Server) handleTestResponseNullNullableArrayRequest(args [0]string, args // // POST /test_response_null_nullable_array_array func (s *Server) handleTestResponseNullNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_null_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86631,7 +110133,16 @@ func (s *Server) handleTestResponseNullNullableArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86643,8 +110154,27 @@ func (s *Server) handleTestResponseNullNullableArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86720,6 +110250,8 @@ func (s *Server) handleTestResponseNullNullableArrayArrayRequest(args [0]string, // // POST /test_response_number func (s *Server) handleTestResponseNumberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86741,7 +110273,16 @@ func (s *Server) handleTestResponseNumberRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86753,8 +110294,27 @@ func (s *Server) handleTestResponseNumberRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86830,6 +110390,8 @@ func (s *Server) handleTestResponseNumberRequest(args [0]string, argsEscaped boo // // POST /test_response_number_array func (s *Server) handleTestResponseNumberArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86851,7 +110413,16 @@ func (s *Server) handleTestResponseNumberArrayRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86863,8 +110434,27 @@ func (s *Server) handleTestResponseNumberArrayRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -86940,6 +110530,8 @@ func (s *Server) handleTestResponseNumberArrayRequest(args [0]string, argsEscape // // POST /test_response_number_array_array func (s *Server) handleTestResponseNumberArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -86961,7 +110553,16 @@ func (s *Server) handleTestResponseNumberArrayArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -86973,8 +110574,27 @@ func (s *Server) handleTestResponseNumberArrayArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87050,6 +110670,8 @@ func (s *Server) handleTestResponseNumberArrayArrayRequest(args [0]string, argsE // // POST /test_response_number_double func (s *Server) handleTestResponseNumberDoubleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_double"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87071,7 +110693,16 @@ func (s *Server) handleTestResponseNumberDoubleRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87083,8 +110714,27 @@ func (s *Server) handleTestResponseNumberDoubleRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87160,6 +110810,8 @@ func (s *Server) handleTestResponseNumberDoubleRequest(args [0]string, argsEscap // // POST /test_response_number_double_array func (s *Server) handleTestResponseNumberDoubleArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_double_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87181,7 +110833,16 @@ func (s *Server) handleTestResponseNumberDoubleArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87193,8 +110854,27 @@ func (s *Server) handleTestResponseNumberDoubleArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87270,6 +110950,8 @@ func (s *Server) handleTestResponseNumberDoubleArrayRequest(args [0]string, args // // POST /test_response_number_double_array_array func (s *Server) handleTestResponseNumberDoubleArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_double_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87291,7 +110973,16 @@ func (s *Server) handleTestResponseNumberDoubleArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87303,8 +110994,27 @@ func (s *Server) handleTestResponseNumberDoubleArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87380,6 +111090,8 @@ func (s *Server) handleTestResponseNumberDoubleArrayArrayRequest(args [0]string, // // POST /test_response_number_double_nullable func (s *Server) handleTestResponseNumberDoubleNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_double_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87401,7 +111113,16 @@ func (s *Server) handleTestResponseNumberDoubleNullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87413,8 +111134,27 @@ func (s *Server) handleTestResponseNumberDoubleNullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87490,6 +111230,8 @@ func (s *Server) handleTestResponseNumberDoubleNullableRequest(args [0]string, a // // POST /test_response_number_double_nullable_array func (s *Server) handleTestResponseNumberDoubleNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_double_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87511,7 +111253,16 @@ func (s *Server) handleTestResponseNumberDoubleNullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87523,8 +111274,27 @@ func (s *Server) handleTestResponseNumberDoubleNullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87600,6 +111370,8 @@ func (s *Server) handleTestResponseNumberDoubleNullableArrayRequest(args [0]stri // // POST /test_response_number_double_nullable_array_array func (s *Server) handleTestResponseNumberDoubleNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_double_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87621,7 +111393,16 @@ func (s *Server) handleTestResponseNumberDoubleNullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87633,8 +111414,27 @@ func (s *Server) handleTestResponseNumberDoubleNullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87710,6 +111510,8 @@ func (s *Server) handleTestResponseNumberDoubleNullableArrayArrayRequest(args [0 // // POST /test_response_number_float func (s *Server) handleTestResponseNumberFloatRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_float"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87731,7 +111533,16 @@ func (s *Server) handleTestResponseNumberFloatRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87743,8 +111554,27 @@ func (s *Server) handleTestResponseNumberFloatRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87820,6 +111650,8 @@ func (s *Server) handleTestResponseNumberFloatRequest(args [0]string, argsEscape // // POST /test_response_number_float_array func (s *Server) handleTestResponseNumberFloatArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_float_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87841,7 +111673,16 @@ func (s *Server) handleTestResponseNumberFloatArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87853,8 +111694,27 @@ func (s *Server) handleTestResponseNumberFloatArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -87930,6 +111790,8 @@ func (s *Server) handleTestResponseNumberFloatArrayRequest(args [0]string, argsE // // POST /test_response_number_float_array_array func (s *Server) handleTestResponseNumberFloatArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_float_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -87951,7 +111813,16 @@ func (s *Server) handleTestResponseNumberFloatArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -87963,8 +111834,27 @@ func (s *Server) handleTestResponseNumberFloatArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88040,6 +111930,8 @@ func (s *Server) handleTestResponseNumberFloatArrayArrayRequest(args [0]string, // // POST /test_response_number_float_nullable func (s *Server) handleTestResponseNumberFloatNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_float_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88061,7 +111953,16 @@ func (s *Server) handleTestResponseNumberFloatNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88073,8 +111974,27 @@ func (s *Server) handleTestResponseNumberFloatNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88150,6 +112070,8 @@ func (s *Server) handleTestResponseNumberFloatNullableRequest(args [0]string, ar // // POST /test_response_number_float_nullable_array func (s *Server) handleTestResponseNumberFloatNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_float_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88171,7 +112093,16 @@ func (s *Server) handleTestResponseNumberFloatNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88183,8 +112114,27 @@ func (s *Server) handleTestResponseNumberFloatNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88260,6 +112210,8 @@ func (s *Server) handleTestResponseNumberFloatNullableArrayRequest(args [0]strin // // POST /test_response_number_float_nullable_array_array func (s *Server) handleTestResponseNumberFloatNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_float_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88281,7 +112233,16 @@ func (s *Server) handleTestResponseNumberFloatNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88293,8 +112254,27 @@ func (s *Server) handleTestResponseNumberFloatNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88370,6 +112350,8 @@ func (s *Server) handleTestResponseNumberFloatNullableArrayArrayRequest(args [0] // // POST /test_response_number_int32 func (s *Server) handleTestResponseNumberInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88391,7 +112373,16 @@ func (s *Server) handleTestResponseNumberInt32Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88403,8 +112394,27 @@ func (s *Server) handleTestResponseNumberInt32Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88480,6 +112490,8 @@ func (s *Server) handleTestResponseNumberInt32Request(args [0]string, argsEscape // // POST /test_response_number_int32_array func (s *Server) handleTestResponseNumberInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88501,7 +112513,16 @@ func (s *Server) handleTestResponseNumberInt32ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88513,8 +112534,27 @@ func (s *Server) handleTestResponseNumberInt32ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88590,6 +112630,8 @@ func (s *Server) handleTestResponseNumberInt32ArrayRequest(args [0]string, argsE // // POST /test_response_number_int32_array_array func (s *Server) handleTestResponseNumberInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88611,7 +112653,16 @@ func (s *Server) handleTestResponseNumberInt32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88623,8 +112674,27 @@ func (s *Server) handleTestResponseNumberInt32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88700,6 +112770,8 @@ func (s *Server) handleTestResponseNumberInt32ArrayArrayRequest(args [0]string, // // POST /test_response_number_int32_nullable func (s *Server) handleTestResponseNumberInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88721,7 +112793,16 @@ func (s *Server) handleTestResponseNumberInt32NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88733,8 +112814,27 @@ func (s *Server) handleTestResponseNumberInt32NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88810,6 +112910,8 @@ func (s *Server) handleTestResponseNumberInt32NullableRequest(args [0]string, ar // // POST /test_response_number_int32_nullable_array func (s *Server) handleTestResponseNumberInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88831,7 +112933,16 @@ func (s *Server) handleTestResponseNumberInt32NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88843,8 +112954,27 @@ func (s *Server) handleTestResponseNumberInt32NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -88920,6 +113050,8 @@ func (s *Server) handleTestResponseNumberInt32NullableArrayRequest(args [0]strin // // POST /test_response_number_int32_nullable_array_array func (s *Server) handleTestResponseNumberInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -88941,7 +113073,16 @@ func (s *Server) handleTestResponseNumberInt32NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -88953,8 +113094,27 @@ func (s *Server) handleTestResponseNumberInt32NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89030,6 +113190,8 @@ func (s *Server) handleTestResponseNumberInt32NullableArrayArrayRequest(args [0] // // POST /test_response_number_int64 func (s *Server) handleTestResponseNumberInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89051,7 +113213,16 @@ func (s *Server) handleTestResponseNumberInt64Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89063,8 +113234,27 @@ func (s *Server) handleTestResponseNumberInt64Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89140,6 +113330,8 @@ func (s *Server) handleTestResponseNumberInt64Request(args [0]string, argsEscape // // POST /test_response_number_int64_array func (s *Server) handleTestResponseNumberInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89161,7 +113353,16 @@ func (s *Server) handleTestResponseNumberInt64ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89173,8 +113374,27 @@ func (s *Server) handleTestResponseNumberInt64ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89250,6 +113470,8 @@ func (s *Server) handleTestResponseNumberInt64ArrayRequest(args [0]string, argsE // // POST /test_response_number_int64_array_array func (s *Server) handleTestResponseNumberInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89271,7 +113493,16 @@ func (s *Server) handleTestResponseNumberInt64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89283,8 +113514,27 @@ func (s *Server) handleTestResponseNumberInt64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89360,6 +113610,8 @@ func (s *Server) handleTestResponseNumberInt64ArrayArrayRequest(args [0]string, // // POST /test_response_number_int64_nullable func (s *Server) handleTestResponseNumberInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89381,7 +113633,16 @@ func (s *Server) handleTestResponseNumberInt64NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89393,8 +113654,27 @@ func (s *Server) handleTestResponseNumberInt64NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89470,6 +113750,8 @@ func (s *Server) handleTestResponseNumberInt64NullableRequest(args [0]string, ar // // POST /test_response_number_int64_nullable_array func (s *Server) handleTestResponseNumberInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89491,7 +113773,16 @@ func (s *Server) handleTestResponseNumberInt64NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89503,8 +113794,27 @@ func (s *Server) handleTestResponseNumberInt64NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89580,6 +113890,8 @@ func (s *Server) handleTestResponseNumberInt64NullableArrayRequest(args [0]strin // // POST /test_response_number_int64_nullable_array_array func (s *Server) handleTestResponseNumberInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89601,7 +113913,16 @@ func (s *Server) handleTestResponseNumberInt64NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89613,8 +113934,27 @@ func (s *Server) handleTestResponseNumberInt64NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89690,6 +114030,8 @@ func (s *Server) handleTestResponseNumberInt64NullableArrayArrayRequest(args [0] // // POST /test_response_number_nullable func (s *Server) handleTestResponseNumberNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89711,7 +114053,16 @@ func (s *Server) handleTestResponseNumberNullableRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89723,8 +114074,27 @@ func (s *Server) handleTestResponseNumberNullableRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89800,6 +114170,8 @@ func (s *Server) handleTestResponseNumberNullableRequest(args [0]string, argsEsc // // POST /test_response_number_nullable_array func (s *Server) handleTestResponseNumberNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89821,7 +114193,16 @@ func (s *Server) handleTestResponseNumberNullableArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89833,8 +114214,27 @@ func (s *Server) handleTestResponseNumberNullableArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -89910,6 +114310,8 @@ func (s *Server) handleTestResponseNumberNullableArrayRequest(args [0]string, ar // // POST /test_response_number_nullable_array_array func (s *Server) handleTestResponseNumberNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_number_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -89931,7 +114333,16 @@ func (s *Server) handleTestResponseNumberNullableArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -89943,8 +114354,27 @@ func (s *Server) handleTestResponseNumberNullableArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90020,6 +114450,8 @@ func (s *Server) handleTestResponseNumberNullableArrayArrayRequest(args [0]strin // // POST /test_response_string func (s *Server) handleTestResponseStringRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90041,7 +114473,16 @@ func (s *Server) handleTestResponseStringRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90053,8 +114494,27 @@ func (s *Server) handleTestResponseStringRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90130,6 +114590,8 @@ func (s *Server) handleTestResponseStringRequest(args [0]string, argsEscaped boo // // POST /test_response_string_array func (s *Server) handleTestResponseStringArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90151,7 +114613,16 @@ func (s *Server) handleTestResponseStringArrayRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90163,8 +114634,27 @@ func (s *Server) handleTestResponseStringArrayRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90240,6 +114730,8 @@ func (s *Server) handleTestResponseStringArrayRequest(args [0]string, argsEscape // // POST /test_response_string_array_array func (s *Server) handleTestResponseStringArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90261,7 +114753,16 @@ func (s *Server) handleTestResponseStringArrayArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90273,8 +114774,27 @@ func (s *Server) handleTestResponseStringArrayArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90350,6 +114870,8 @@ func (s *Server) handleTestResponseStringArrayArrayRequest(args [0]string, argsE // // POST /test_response_string_base64 func (s *Server) handleTestResponseStringBase64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_base64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90371,7 +114893,16 @@ func (s *Server) handleTestResponseStringBase64Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90383,8 +114914,27 @@ func (s *Server) handleTestResponseStringBase64Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90460,6 +115010,8 @@ func (s *Server) handleTestResponseStringBase64Request(args [0]string, argsEscap // // POST /test_response_string_base64_array func (s *Server) handleTestResponseStringBase64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_base64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90481,7 +115033,16 @@ func (s *Server) handleTestResponseStringBase64ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90493,8 +115054,27 @@ func (s *Server) handleTestResponseStringBase64ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90570,6 +115150,8 @@ func (s *Server) handleTestResponseStringBase64ArrayRequest(args [0]string, args // // POST /test_response_string_base64_array_array func (s *Server) handleTestResponseStringBase64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_base64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90591,7 +115173,16 @@ func (s *Server) handleTestResponseStringBase64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90603,8 +115194,27 @@ func (s *Server) handleTestResponseStringBase64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90680,6 +115290,8 @@ func (s *Server) handleTestResponseStringBase64ArrayArrayRequest(args [0]string, // // POST /test_response_string_base64_nullable func (s *Server) handleTestResponseStringBase64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_base64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90701,7 +115313,16 @@ func (s *Server) handleTestResponseStringBase64NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90713,8 +115334,27 @@ func (s *Server) handleTestResponseStringBase64NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90790,6 +115430,8 @@ func (s *Server) handleTestResponseStringBase64NullableRequest(args [0]string, a // // POST /test_response_string_base64_nullable_array func (s *Server) handleTestResponseStringBase64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_base64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90811,7 +115453,16 @@ func (s *Server) handleTestResponseStringBase64NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90823,8 +115474,27 @@ func (s *Server) handleTestResponseStringBase64NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -90900,6 +115570,8 @@ func (s *Server) handleTestResponseStringBase64NullableArrayRequest(args [0]stri // // POST /test_response_string_base64_nullable_array_array func (s *Server) handleTestResponseStringBase64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_base64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -90921,7 +115593,16 @@ func (s *Server) handleTestResponseStringBase64NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -90933,8 +115614,27 @@ func (s *Server) handleTestResponseStringBase64NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91010,6 +115710,8 @@ func (s *Server) handleTestResponseStringBase64NullableArrayArrayRequest(args [0 // // POST /test_response_string_binary func (s *Server) handleTestResponseStringBinaryRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_binary"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91031,7 +115733,16 @@ func (s *Server) handleTestResponseStringBinaryRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91043,8 +115754,27 @@ func (s *Server) handleTestResponseStringBinaryRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91120,6 +115850,8 @@ func (s *Server) handleTestResponseStringBinaryRequest(args [0]string, argsEscap // // POST /test_response_string_binary_array func (s *Server) handleTestResponseStringBinaryArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_binary_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91141,7 +115873,16 @@ func (s *Server) handleTestResponseStringBinaryArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91153,8 +115894,27 @@ func (s *Server) handleTestResponseStringBinaryArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91230,6 +115990,8 @@ func (s *Server) handleTestResponseStringBinaryArrayRequest(args [0]string, args // // POST /test_response_string_binary_array_array func (s *Server) handleTestResponseStringBinaryArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_binary_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91251,7 +116013,16 @@ func (s *Server) handleTestResponseStringBinaryArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91263,8 +116034,27 @@ func (s *Server) handleTestResponseStringBinaryArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91340,6 +116130,8 @@ func (s *Server) handleTestResponseStringBinaryArrayArrayRequest(args [0]string, // // POST /test_response_string_binary_nullable func (s *Server) handleTestResponseStringBinaryNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_binary_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91361,7 +116153,16 @@ func (s *Server) handleTestResponseStringBinaryNullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91373,8 +116174,27 @@ func (s *Server) handleTestResponseStringBinaryNullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91450,6 +116270,8 @@ func (s *Server) handleTestResponseStringBinaryNullableRequest(args [0]string, a // // POST /test_response_string_binary_nullable_array func (s *Server) handleTestResponseStringBinaryNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_binary_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91471,7 +116293,16 @@ func (s *Server) handleTestResponseStringBinaryNullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91483,8 +116314,27 @@ func (s *Server) handleTestResponseStringBinaryNullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91560,6 +116410,8 @@ func (s *Server) handleTestResponseStringBinaryNullableArrayRequest(args [0]stri // // POST /test_response_string_binary_nullable_array_array func (s *Server) handleTestResponseStringBinaryNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_binary_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91581,7 +116433,16 @@ func (s *Server) handleTestResponseStringBinaryNullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91593,8 +116454,27 @@ func (s *Server) handleTestResponseStringBinaryNullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91670,6 +116550,8 @@ func (s *Server) handleTestResponseStringBinaryNullableArrayArrayRequest(args [0 // // POST /test_response_string_byte func (s *Server) handleTestResponseStringByteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_byte"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91691,7 +116573,16 @@ func (s *Server) handleTestResponseStringByteRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91703,8 +116594,27 @@ func (s *Server) handleTestResponseStringByteRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91780,6 +116690,8 @@ func (s *Server) handleTestResponseStringByteRequest(args [0]string, argsEscaped // // POST /test_response_string_byte_array func (s *Server) handleTestResponseStringByteArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_byte_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91801,7 +116713,16 @@ func (s *Server) handleTestResponseStringByteArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91813,8 +116734,27 @@ func (s *Server) handleTestResponseStringByteArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -91890,6 +116830,8 @@ func (s *Server) handleTestResponseStringByteArrayRequest(args [0]string, argsEs // // POST /test_response_string_byte_array_array func (s *Server) handleTestResponseStringByteArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_byte_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -91911,7 +116853,16 @@ func (s *Server) handleTestResponseStringByteArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -91923,8 +116874,27 @@ func (s *Server) handleTestResponseStringByteArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92000,6 +116970,8 @@ func (s *Server) handleTestResponseStringByteArrayArrayRequest(args [0]string, a // // POST /test_response_string_byte_nullable func (s *Server) handleTestResponseStringByteNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_byte_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92021,7 +116993,16 @@ func (s *Server) handleTestResponseStringByteNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92033,8 +117014,27 @@ func (s *Server) handleTestResponseStringByteNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92110,6 +117110,8 @@ func (s *Server) handleTestResponseStringByteNullableRequest(args [0]string, arg // // POST /test_response_string_byte_nullable_array func (s *Server) handleTestResponseStringByteNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_byte_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92131,7 +117133,16 @@ func (s *Server) handleTestResponseStringByteNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92143,8 +117154,27 @@ func (s *Server) handleTestResponseStringByteNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92220,6 +117250,8 @@ func (s *Server) handleTestResponseStringByteNullableArrayRequest(args [0]string // // POST /test_response_string_byte_nullable_array_array func (s *Server) handleTestResponseStringByteNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_byte_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92241,7 +117273,16 @@ func (s *Server) handleTestResponseStringByteNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92253,8 +117294,27 @@ func (s *Server) handleTestResponseStringByteNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92330,6 +117390,8 @@ func (s *Server) handleTestResponseStringByteNullableArrayArrayRequest(args [0]s // // POST /test_response_string_date func (s *Server) handleTestResponseStringDateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92351,7 +117413,16 @@ func (s *Server) handleTestResponseStringDateRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92363,8 +117434,27 @@ func (s *Server) handleTestResponseStringDateRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92440,6 +117530,8 @@ func (s *Server) handleTestResponseStringDateRequest(args [0]string, argsEscaped // // POST /test_response_string_date_array func (s *Server) handleTestResponseStringDateArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92461,7 +117553,16 @@ func (s *Server) handleTestResponseStringDateArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92473,8 +117574,27 @@ func (s *Server) handleTestResponseStringDateArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92550,6 +117670,8 @@ func (s *Server) handleTestResponseStringDateArrayRequest(args [0]string, argsEs // // POST /test_response_string_date_array_array func (s *Server) handleTestResponseStringDateArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92571,7 +117693,16 @@ func (s *Server) handleTestResponseStringDateArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92583,8 +117714,27 @@ func (s *Server) handleTestResponseStringDateArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92660,6 +117810,8 @@ func (s *Server) handleTestResponseStringDateArrayArrayRequest(args [0]string, a // // POST /test_response_string_date_nullable func (s *Server) handleTestResponseStringDateNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92681,7 +117833,16 @@ func (s *Server) handleTestResponseStringDateNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92693,8 +117854,27 @@ func (s *Server) handleTestResponseStringDateNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92770,6 +117950,8 @@ func (s *Server) handleTestResponseStringDateNullableRequest(args [0]string, arg // // POST /test_response_string_date_nullable_array func (s *Server) handleTestResponseStringDateNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92791,7 +117973,16 @@ func (s *Server) handleTestResponseStringDateNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92803,8 +117994,27 @@ func (s *Server) handleTestResponseStringDateNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92880,6 +118090,8 @@ func (s *Server) handleTestResponseStringDateNullableArrayRequest(args [0]string // // POST /test_response_string_date_nullable_array_array func (s *Server) handleTestResponseStringDateNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -92901,7 +118113,16 @@ func (s *Server) handleTestResponseStringDateNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -92913,8 +118134,27 @@ func (s *Server) handleTestResponseStringDateNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -92990,6 +118230,8 @@ func (s *Server) handleTestResponseStringDateNullableArrayArrayRequest(args [0]s // // POST /test_response_string_date-time func (s *Server) handleTestResponseStringDateTimeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date-time"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93011,7 +118253,16 @@ func (s *Server) handleTestResponseStringDateTimeRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93023,8 +118274,27 @@ func (s *Server) handleTestResponseStringDateTimeRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93100,6 +118370,8 @@ func (s *Server) handleTestResponseStringDateTimeRequest(args [0]string, argsEsc // // POST /test_response_string_date-time_array func (s *Server) handleTestResponseStringDateTimeArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date-time_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93121,7 +118393,16 @@ func (s *Server) handleTestResponseStringDateTimeArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93133,8 +118414,27 @@ func (s *Server) handleTestResponseStringDateTimeArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93210,6 +118510,8 @@ func (s *Server) handleTestResponseStringDateTimeArrayRequest(args [0]string, ar // // POST /test_response_string_date-time_array_array func (s *Server) handleTestResponseStringDateTimeArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date-time_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93231,7 +118533,16 @@ func (s *Server) handleTestResponseStringDateTimeArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93243,8 +118554,27 @@ func (s *Server) handleTestResponseStringDateTimeArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93320,6 +118650,8 @@ func (s *Server) handleTestResponseStringDateTimeArrayArrayRequest(args [0]strin // // POST /test_response_string_date-time_nullable func (s *Server) handleTestResponseStringDateTimeNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date-time_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93341,7 +118673,16 @@ func (s *Server) handleTestResponseStringDateTimeNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93353,8 +118694,27 @@ func (s *Server) handleTestResponseStringDateTimeNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93430,6 +118790,8 @@ func (s *Server) handleTestResponseStringDateTimeNullableRequest(args [0]string, // // POST /test_response_string_date-time_nullable_array func (s *Server) handleTestResponseStringDateTimeNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date-time_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93451,7 +118813,16 @@ func (s *Server) handleTestResponseStringDateTimeNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93463,8 +118834,27 @@ func (s *Server) handleTestResponseStringDateTimeNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93540,6 +118930,8 @@ func (s *Server) handleTestResponseStringDateTimeNullableArrayRequest(args [0]st // // POST /test_response_string_date-time_nullable_array_array func (s *Server) handleTestResponseStringDateTimeNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_date-time_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93561,7 +118953,16 @@ func (s *Server) handleTestResponseStringDateTimeNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93573,8 +118974,27 @@ func (s *Server) handleTestResponseStringDateTimeNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93650,6 +119070,8 @@ func (s *Server) handleTestResponseStringDateTimeNullableArrayArrayRequest(args // // POST /test_response_string_duration func (s *Server) handleTestResponseStringDurationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_duration"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93671,7 +119093,16 @@ func (s *Server) handleTestResponseStringDurationRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93683,8 +119114,27 @@ func (s *Server) handleTestResponseStringDurationRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93760,6 +119210,8 @@ func (s *Server) handleTestResponseStringDurationRequest(args [0]string, argsEsc // // POST /test_response_string_duration_array func (s *Server) handleTestResponseStringDurationArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_duration_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93781,7 +119233,16 @@ func (s *Server) handleTestResponseStringDurationArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93793,8 +119254,27 @@ func (s *Server) handleTestResponseStringDurationArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93870,6 +119350,8 @@ func (s *Server) handleTestResponseStringDurationArrayRequest(args [0]string, ar // // POST /test_response_string_duration_array_array func (s *Server) handleTestResponseStringDurationArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_duration_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -93891,7 +119373,16 @@ func (s *Server) handleTestResponseStringDurationArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -93903,8 +119394,27 @@ func (s *Server) handleTestResponseStringDurationArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -93980,6 +119490,8 @@ func (s *Server) handleTestResponseStringDurationArrayArrayRequest(args [0]strin // // POST /test_response_string_duration_nullable func (s *Server) handleTestResponseStringDurationNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_duration_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94001,7 +119513,16 @@ func (s *Server) handleTestResponseStringDurationNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94013,8 +119534,27 @@ func (s *Server) handleTestResponseStringDurationNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94090,6 +119630,8 @@ func (s *Server) handleTestResponseStringDurationNullableRequest(args [0]string, // // POST /test_response_string_duration_nullable_array func (s *Server) handleTestResponseStringDurationNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_duration_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94111,7 +119653,16 @@ func (s *Server) handleTestResponseStringDurationNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94123,8 +119674,27 @@ func (s *Server) handleTestResponseStringDurationNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94200,6 +119770,8 @@ func (s *Server) handleTestResponseStringDurationNullableArrayRequest(args [0]st // // POST /test_response_string_duration_nullable_array_array func (s *Server) handleTestResponseStringDurationNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_duration_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94221,7 +119793,16 @@ func (s *Server) handleTestResponseStringDurationNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94233,8 +119814,27 @@ func (s *Server) handleTestResponseStringDurationNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94310,6 +119910,8 @@ func (s *Server) handleTestResponseStringDurationNullableArrayArrayRequest(args // // POST /test_response_string_email func (s *Server) handleTestResponseStringEmailRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_email"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94331,7 +119933,16 @@ func (s *Server) handleTestResponseStringEmailRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94343,8 +119954,27 @@ func (s *Server) handleTestResponseStringEmailRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94420,6 +120050,8 @@ func (s *Server) handleTestResponseStringEmailRequest(args [0]string, argsEscape // // POST /test_response_string_email_array func (s *Server) handleTestResponseStringEmailArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_email_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94441,7 +120073,16 @@ func (s *Server) handleTestResponseStringEmailArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94453,8 +120094,27 @@ func (s *Server) handleTestResponseStringEmailArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94530,6 +120190,8 @@ func (s *Server) handleTestResponseStringEmailArrayRequest(args [0]string, argsE // // POST /test_response_string_email_array_array func (s *Server) handleTestResponseStringEmailArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_email_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94551,7 +120213,16 @@ func (s *Server) handleTestResponseStringEmailArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94563,8 +120234,27 @@ func (s *Server) handleTestResponseStringEmailArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94640,6 +120330,8 @@ func (s *Server) handleTestResponseStringEmailArrayArrayRequest(args [0]string, // // POST /test_response_string_email_nullable func (s *Server) handleTestResponseStringEmailNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_email_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94661,7 +120353,16 @@ func (s *Server) handleTestResponseStringEmailNullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94673,8 +120374,27 @@ func (s *Server) handleTestResponseStringEmailNullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94750,6 +120470,8 @@ func (s *Server) handleTestResponseStringEmailNullableRequest(args [0]string, ar // // POST /test_response_string_email_nullable_array func (s *Server) handleTestResponseStringEmailNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_email_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94771,7 +120493,16 @@ func (s *Server) handleTestResponseStringEmailNullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94783,8 +120514,27 @@ func (s *Server) handleTestResponseStringEmailNullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94860,6 +120610,8 @@ func (s *Server) handleTestResponseStringEmailNullableArrayRequest(args [0]strin // // POST /test_response_string_email_nullable_array_array func (s *Server) handleTestResponseStringEmailNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_email_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94881,7 +120633,16 @@ func (s *Server) handleTestResponseStringEmailNullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -94893,8 +120654,27 @@ func (s *Server) handleTestResponseStringEmailNullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -94970,6 +120750,8 @@ func (s *Server) handleTestResponseStringEmailNullableArrayArrayRequest(args [0] // // POST /test_response_string_float32 func (s *Server) handleTestResponseStringFloat32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -94991,7 +120773,16 @@ func (s *Server) handleTestResponseStringFloat32Request(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95003,8 +120794,27 @@ func (s *Server) handleTestResponseStringFloat32Request(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95080,6 +120890,8 @@ func (s *Server) handleTestResponseStringFloat32Request(args [0]string, argsEsca // // POST /test_response_string_float32_array func (s *Server) handleTestResponseStringFloat32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95101,7 +120913,16 @@ func (s *Server) handleTestResponseStringFloat32ArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95113,8 +120934,27 @@ func (s *Server) handleTestResponseStringFloat32ArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95190,6 +121030,8 @@ func (s *Server) handleTestResponseStringFloat32ArrayRequest(args [0]string, arg // // POST /test_response_string_float32_array_array func (s *Server) handleTestResponseStringFloat32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95211,7 +121053,16 @@ func (s *Server) handleTestResponseStringFloat32ArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95223,8 +121074,27 @@ func (s *Server) handleTestResponseStringFloat32ArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95300,6 +121170,8 @@ func (s *Server) handleTestResponseStringFloat32ArrayArrayRequest(args [0]string // // POST /test_response_string_float32_nullable func (s *Server) handleTestResponseStringFloat32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95321,7 +121193,16 @@ func (s *Server) handleTestResponseStringFloat32NullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95333,8 +121214,27 @@ func (s *Server) handleTestResponseStringFloat32NullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95410,6 +121310,8 @@ func (s *Server) handleTestResponseStringFloat32NullableRequest(args [0]string, // // POST /test_response_string_float32_nullable_array func (s *Server) handleTestResponseStringFloat32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95431,7 +121333,16 @@ func (s *Server) handleTestResponseStringFloat32NullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95443,8 +121354,27 @@ func (s *Server) handleTestResponseStringFloat32NullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95520,6 +121450,8 @@ func (s *Server) handleTestResponseStringFloat32NullableArrayRequest(args [0]str // // POST /test_response_string_float32_nullable_array_array func (s *Server) handleTestResponseStringFloat32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95541,7 +121473,16 @@ func (s *Server) handleTestResponseStringFloat32NullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95553,8 +121494,27 @@ func (s *Server) handleTestResponseStringFloat32NullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95630,6 +121590,8 @@ func (s *Server) handleTestResponseStringFloat32NullableArrayArrayRequest(args [ // // POST /test_response_string_float64 func (s *Server) handleTestResponseStringFloat64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95651,7 +121613,16 @@ func (s *Server) handleTestResponseStringFloat64Request(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95663,8 +121634,27 @@ func (s *Server) handleTestResponseStringFloat64Request(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95740,6 +121730,8 @@ func (s *Server) handleTestResponseStringFloat64Request(args [0]string, argsEsca // // POST /test_response_string_float64_array func (s *Server) handleTestResponseStringFloat64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95761,7 +121753,16 @@ func (s *Server) handleTestResponseStringFloat64ArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95773,8 +121774,27 @@ func (s *Server) handleTestResponseStringFloat64ArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95850,6 +121870,8 @@ func (s *Server) handleTestResponseStringFloat64ArrayRequest(args [0]string, arg // // POST /test_response_string_float64_array_array func (s *Server) handleTestResponseStringFloat64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95871,7 +121893,16 @@ func (s *Server) handleTestResponseStringFloat64ArrayArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95883,8 +121914,27 @@ func (s *Server) handleTestResponseStringFloat64ArrayArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -95960,6 +122010,8 @@ func (s *Server) handleTestResponseStringFloat64ArrayArrayRequest(args [0]string // // POST /test_response_string_float64_nullable func (s *Server) handleTestResponseStringFloat64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -95981,7 +122033,16 @@ func (s *Server) handleTestResponseStringFloat64NullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -95993,8 +122054,27 @@ func (s *Server) handleTestResponseStringFloat64NullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96070,6 +122150,8 @@ func (s *Server) handleTestResponseStringFloat64NullableRequest(args [0]string, // // POST /test_response_string_float64_nullable_array func (s *Server) handleTestResponseStringFloat64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96091,7 +122173,16 @@ func (s *Server) handleTestResponseStringFloat64NullableArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96103,8 +122194,27 @@ func (s *Server) handleTestResponseStringFloat64NullableArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96180,6 +122290,8 @@ func (s *Server) handleTestResponseStringFloat64NullableArrayRequest(args [0]str // // POST /test_response_string_float64_nullable_array_array func (s *Server) handleTestResponseStringFloat64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_float64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96201,7 +122313,16 @@ func (s *Server) handleTestResponseStringFloat64NullableArrayArrayRequest(args [ startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96213,8 +122334,27 @@ func (s *Server) handleTestResponseStringFloat64NullableArrayArrayRequest(args [ var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96290,6 +122430,8 @@ func (s *Server) handleTestResponseStringFloat64NullableArrayArrayRequest(args [ // // POST /test_response_string_hostname func (s *Server) handleTestResponseStringHostnameRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_hostname"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96311,7 +122453,16 @@ func (s *Server) handleTestResponseStringHostnameRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96323,8 +122474,27 @@ func (s *Server) handleTestResponseStringHostnameRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96400,6 +122570,8 @@ func (s *Server) handleTestResponseStringHostnameRequest(args [0]string, argsEsc // // POST /test_response_string_hostname_array func (s *Server) handleTestResponseStringHostnameArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_hostname_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96421,7 +122593,16 @@ func (s *Server) handleTestResponseStringHostnameArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96433,8 +122614,27 @@ func (s *Server) handleTestResponseStringHostnameArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96510,6 +122710,8 @@ func (s *Server) handleTestResponseStringHostnameArrayRequest(args [0]string, ar // // POST /test_response_string_hostname_array_array func (s *Server) handleTestResponseStringHostnameArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_hostname_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96531,7 +122733,16 @@ func (s *Server) handleTestResponseStringHostnameArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96543,8 +122754,27 @@ func (s *Server) handleTestResponseStringHostnameArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96620,6 +122850,8 @@ func (s *Server) handleTestResponseStringHostnameArrayArrayRequest(args [0]strin // // POST /test_response_string_hostname_nullable func (s *Server) handleTestResponseStringHostnameNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_hostname_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96641,7 +122873,16 @@ func (s *Server) handleTestResponseStringHostnameNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96653,8 +122894,27 @@ func (s *Server) handleTestResponseStringHostnameNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96730,6 +122990,8 @@ func (s *Server) handleTestResponseStringHostnameNullableRequest(args [0]string, // // POST /test_response_string_hostname_nullable_array func (s *Server) handleTestResponseStringHostnameNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_hostname_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96751,7 +123013,16 @@ func (s *Server) handleTestResponseStringHostnameNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96763,8 +123034,27 @@ func (s *Server) handleTestResponseStringHostnameNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96840,6 +123130,8 @@ func (s *Server) handleTestResponseStringHostnameNullableArrayRequest(args [0]st // // POST /test_response_string_hostname_nullable_array_array func (s *Server) handleTestResponseStringHostnameNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_hostname_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96861,7 +123153,16 @@ func (s *Server) handleTestResponseStringHostnameNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96873,8 +123174,27 @@ func (s *Server) handleTestResponseStringHostnameNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -96950,6 +123270,8 @@ func (s *Server) handleTestResponseStringHostnameNullableArrayArrayRequest(args // // POST /test_response_string_ip func (s *Server) handleTestResponseStringIPRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ip"), semconv.HTTPRequestMethodKey.String("POST"), @@ -96971,7 +123293,16 @@ func (s *Server) handleTestResponseStringIPRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -96983,8 +123314,27 @@ func (s *Server) handleTestResponseStringIPRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97060,6 +123410,8 @@ func (s *Server) handleTestResponseStringIPRequest(args [0]string, argsEscaped b // // POST /test_response_string_ip_array func (s *Server) handleTestResponseStringIPArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ip_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97081,7 +123433,16 @@ func (s *Server) handleTestResponseStringIPArrayRequest(args [0]string, argsEsca startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97093,8 +123454,27 @@ func (s *Server) handleTestResponseStringIPArrayRequest(args [0]string, argsEsca var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97170,6 +123550,8 @@ func (s *Server) handleTestResponseStringIPArrayRequest(args [0]string, argsEsca // // POST /test_response_string_ip_array_array func (s *Server) handleTestResponseStringIPArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ip_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97191,7 +123573,16 @@ func (s *Server) handleTestResponseStringIPArrayArrayRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97203,8 +123594,27 @@ func (s *Server) handleTestResponseStringIPArrayArrayRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97280,6 +123690,8 @@ func (s *Server) handleTestResponseStringIPArrayArrayRequest(args [0]string, arg // // POST /test_response_string_ip_nullable func (s *Server) handleTestResponseStringIPNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ip_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97301,7 +123713,16 @@ func (s *Server) handleTestResponseStringIPNullableRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97313,8 +123734,27 @@ func (s *Server) handleTestResponseStringIPNullableRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97390,6 +123830,8 @@ func (s *Server) handleTestResponseStringIPNullableRequest(args [0]string, argsE // // POST /test_response_string_ip_nullable_array func (s *Server) handleTestResponseStringIPNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ip_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97411,7 +123853,16 @@ func (s *Server) handleTestResponseStringIPNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97423,8 +123874,27 @@ func (s *Server) handleTestResponseStringIPNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97500,6 +123970,8 @@ func (s *Server) handleTestResponseStringIPNullableArrayRequest(args [0]string, // // POST /test_response_string_ip_nullable_array_array func (s *Server) handleTestResponseStringIPNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ip_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97521,7 +123993,16 @@ func (s *Server) handleTestResponseStringIPNullableArrayArrayRequest(args [0]str startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97533,8 +124014,27 @@ func (s *Server) handleTestResponseStringIPNullableArrayArrayRequest(args [0]str var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97610,6 +124110,8 @@ func (s *Server) handleTestResponseStringIPNullableArrayArrayRequest(args [0]str // // POST /test_response_string_int func (s *Server) handleTestResponseStringIntRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97631,7 +124133,16 @@ func (s *Server) handleTestResponseStringIntRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97643,8 +124154,27 @@ func (s *Server) handleTestResponseStringIntRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97720,6 +124250,8 @@ func (s *Server) handleTestResponseStringIntRequest(args [0]string, argsEscaped // // POST /test_response_string_int16 func (s *Server) handleTestResponseStringInt16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97741,7 +124273,16 @@ func (s *Server) handleTestResponseStringInt16Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97753,8 +124294,27 @@ func (s *Server) handleTestResponseStringInt16Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97830,6 +124390,8 @@ func (s *Server) handleTestResponseStringInt16Request(args [0]string, argsEscape // // POST /test_response_string_int16_array func (s *Server) handleTestResponseStringInt16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97851,7 +124413,16 @@ func (s *Server) handleTestResponseStringInt16ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97863,8 +124434,27 @@ func (s *Server) handleTestResponseStringInt16ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -97940,6 +124530,8 @@ func (s *Server) handleTestResponseStringInt16ArrayRequest(args [0]string, argsE // // POST /test_response_string_int16_array_array func (s *Server) handleTestResponseStringInt16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -97961,7 +124553,16 @@ func (s *Server) handleTestResponseStringInt16ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -97973,8 +124574,27 @@ func (s *Server) handleTestResponseStringInt16ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98050,6 +124670,8 @@ func (s *Server) handleTestResponseStringInt16ArrayArrayRequest(args [0]string, // // POST /test_response_string_int16_nullable func (s *Server) handleTestResponseStringInt16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98071,7 +124693,16 @@ func (s *Server) handleTestResponseStringInt16NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98083,8 +124714,27 @@ func (s *Server) handleTestResponseStringInt16NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98160,6 +124810,8 @@ func (s *Server) handleTestResponseStringInt16NullableRequest(args [0]string, ar // // POST /test_response_string_int16_nullable_array func (s *Server) handleTestResponseStringInt16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98181,7 +124833,16 @@ func (s *Server) handleTestResponseStringInt16NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98193,8 +124854,27 @@ func (s *Server) handleTestResponseStringInt16NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98270,6 +124950,8 @@ func (s *Server) handleTestResponseStringInt16NullableArrayRequest(args [0]strin // // POST /test_response_string_int16_nullable_array_array func (s *Server) handleTestResponseStringInt16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98291,7 +124973,16 @@ func (s *Server) handleTestResponseStringInt16NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98303,8 +124994,27 @@ func (s *Server) handleTestResponseStringInt16NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98380,6 +125090,8 @@ func (s *Server) handleTestResponseStringInt16NullableArrayArrayRequest(args [0] // // POST /test_response_string_int32 func (s *Server) handleTestResponseStringInt32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98401,7 +125113,16 @@ func (s *Server) handleTestResponseStringInt32Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98413,8 +125134,27 @@ func (s *Server) handleTestResponseStringInt32Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98490,6 +125230,8 @@ func (s *Server) handleTestResponseStringInt32Request(args [0]string, argsEscape // // POST /test_response_string_int32_array func (s *Server) handleTestResponseStringInt32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98511,7 +125253,16 @@ func (s *Server) handleTestResponseStringInt32ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98523,8 +125274,27 @@ func (s *Server) handleTestResponseStringInt32ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98600,6 +125370,8 @@ func (s *Server) handleTestResponseStringInt32ArrayRequest(args [0]string, argsE // // POST /test_response_string_int32_array_array func (s *Server) handleTestResponseStringInt32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98621,7 +125393,16 @@ func (s *Server) handleTestResponseStringInt32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98633,8 +125414,27 @@ func (s *Server) handleTestResponseStringInt32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98710,6 +125510,8 @@ func (s *Server) handleTestResponseStringInt32ArrayArrayRequest(args [0]string, // // POST /test_response_string_int32_nullable func (s *Server) handleTestResponseStringInt32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98731,7 +125533,16 @@ func (s *Server) handleTestResponseStringInt32NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98743,8 +125554,27 @@ func (s *Server) handleTestResponseStringInt32NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98820,6 +125650,8 @@ func (s *Server) handleTestResponseStringInt32NullableRequest(args [0]string, ar // // POST /test_response_string_int32_nullable_array func (s *Server) handleTestResponseStringInt32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98841,7 +125673,16 @@ func (s *Server) handleTestResponseStringInt32NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98853,8 +125694,27 @@ func (s *Server) handleTestResponseStringInt32NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -98930,6 +125790,8 @@ func (s *Server) handleTestResponseStringInt32NullableArrayRequest(args [0]strin // // POST /test_response_string_int32_nullable_array_array func (s *Server) handleTestResponseStringInt32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -98951,7 +125813,16 @@ func (s *Server) handleTestResponseStringInt32NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -98963,8 +125834,27 @@ func (s *Server) handleTestResponseStringInt32NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99040,6 +125930,8 @@ func (s *Server) handleTestResponseStringInt32NullableArrayArrayRequest(args [0] // // POST /test_response_string_int64 func (s *Server) handleTestResponseStringInt64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99061,7 +125953,16 @@ func (s *Server) handleTestResponseStringInt64Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99073,8 +125974,27 @@ func (s *Server) handleTestResponseStringInt64Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99150,6 +126070,8 @@ func (s *Server) handleTestResponseStringInt64Request(args [0]string, argsEscape // // POST /test_response_string_int64_array func (s *Server) handleTestResponseStringInt64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99171,7 +126093,16 @@ func (s *Server) handleTestResponseStringInt64ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99183,8 +126114,27 @@ func (s *Server) handleTestResponseStringInt64ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99260,6 +126210,8 @@ func (s *Server) handleTestResponseStringInt64ArrayRequest(args [0]string, argsE // // POST /test_response_string_int64_array_array func (s *Server) handleTestResponseStringInt64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99281,7 +126233,16 @@ func (s *Server) handleTestResponseStringInt64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99293,8 +126254,27 @@ func (s *Server) handleTestResponseStringInt64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99370,6 +126350,8 @@ func (s *Server) handleTestResponseStringInt64ArrayArrayRequest(args [0]string, // // POST /test_response_string_int64_nullable func (s *Server) handleTestResponseStringInt64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99391,7 +126373,16 @@ func (s *Server) handleTestResponseStringInt64NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99403,8 +126394,27 @@ func (s *Server) handleTestResponseStringInt64NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99480,6 +126490,8 @@ func (s *Server) handleTestResponseStringInt64NullableRequest(args [0]string, ar // // POST /test_response_string_int64_nullable_array func (s *Server) handleTestResponseStringInt64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99501,7 +126513,16 @@ func (s *Server) handleTestResponseStringInt64NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99513,8 +126534,27 @@ func (s *Server) handleTestResponseStringInt64NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99590,6 +126630,8 @@ func (s *Server) handleTestResponseStringInt64NullableArrayRequest(args [0]strin // // POST /test_response_string_int64_nullable_array_array func (s *Server) handleTestResponseStringInt64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99611,7 +126653,16 @@ func (s *Server) handleTestResponseStringInt64NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99623,8 +126674,27 @@ func (s *Server) handleTestResponseStringInt64NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99700,6 +126770,8 @@ func (s *Server) handleTestResponseStringInt64NullableArrayArrayRequest(args [0] // // POST /test_response_string_int8 func (s *Server) handleTestResponseStringInt8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99721,7 +126793,16 @@ func (s *Server) handleTestResponseStringInt8Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99733,8 +126814,27 @@ func (s *Server) handleTestResponseStringInt8Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99810,6 +126910,8 @@ func (s *Server) handleTestResponseStringInt8Request(args [0]string, argsEscaped // // POST /test_response_string_int8_array func (s *Server) handleTestResponseStringInt8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99831,7 +126933,16 @@ func (s *Server) handleTestResponseStringInt8ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99843,8 +126954,27 @@ func (s *Server) handleTestResponseStringInt8ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -99920,6 +127050,8 @@ func (s *Server) handleTestResponseStringInt8ArrayRequest(args [0]string, argsEs // // POST /test_response_string_int8_array_array func (s *Server) handleTestResponseStringInt8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -99941,7 +127073,16 @@ func (s *Server) handleTestResponseStringInt8ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -99953,8 +127094,27 @@ func (s *Server) handleTestResponseStringInt8ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100030,6 +127190,8 @@ func (s *Server) handleTestResponseStringInt8ArrayArrayRequest(args [0]string, a // // POST /test_response_string_int8_nullable func (s *Server) handleTestResponseStringInt8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100051,7 +127213,16 @@ func (s *Server) handleTestResponseStringInt8NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100063,8 +127234,27 @@ func (s *Server) handleTestResponseStringInt8NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100140,6 +127330,8 @@ func (s *Server) handleTestResponseStringInt8NullableRequest(args [0]string, arg // // POST /test_response_string_int8_nullable_array func (s *Server) handleTestResponseStringInt8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100161,7 +127353,16 @@ func (s *Server) handleTestResponseStringInt8NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100173,8 +127374,27 @@ func (s *Server) handleTestResponseStringInt8NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100250,6 +127470,8 @@ func (s *Server) handleTestResponseStringInt8NullableArrayRequest(args [0]string // // POST /test_response_string_int8_nullable_array_array func (s *Server) handleTestResponseStringInt8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100271,7 +127493,16 @@ func (s *Server) handleTestResponseStringInt8NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100283,8 +127514,27 @@ func (s *Server) handleTestResponseStringInt8NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100360,6 +127610,8 @@ func (s *Server) handleTestResponseStringInt8NullableArrayArrayRequest(args [0]s // // POST /test_response_string_int_array func (s *Server) handleTestResponseStringIntArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100381,7 +127633,16 @@ func (s *Server) handleTestResponseStringIntArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100393,8 +127654,27 @@ func (s *Server) handleTestResponseStringIntArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100470,6 +127750,8 @@ func (s *Server) handleTestResponseStringIntArrayRequest(args [0]string, argsEsc // // POST /test_response_string_int_array_array func (s *Server) handleTestResponseStringIntArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100491,7 +127773,16 @@ func (s *Server) handleTestResponseStringIntArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100503,8 +127794,27 @@ func (s *Server) handleTestResponseStringIntArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100580,6 +127890,8 @@ func (s *Server) handleTestResponseStringIntArrayArrayRequest(args [0]string, ar // // POST /test_response_string_int_nullable func (s *Server) handleTestResponseStringIntNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100601,7 +127913,16 @@ func (s *Server) handleTestResponseStringIntNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100613,8 +127934,27 @@ func (s *Server) handleTestResponseStringIntNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100690,6 +128030,8 @@ func (s *Server) handleTestResponseStringIntNullableRequest(args [0]string, args // // POST /test_response_string_int_nullable_array func (s *Server) handleTestResponseStringIntNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100711,7 +128053,16 @@ func (s *Server) handleTestResponseStringIntNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100723,8 +128074,27 @@ func (s *Server) handleTestResponseStringIntNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100800,6 +128170,8 @@ func (s *Server) handleTestResponseStringIntNullableArrayRequest(args [0]string, // // POST /test_response_string_int_nullable_array_array func (s *Server) handleTestResponseStringIntNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_int_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100821,7 +128193,16 @@ func (s *Server) handleTestResponseStringIntNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100833,8 +128214,27 @@ func (s *Server) handleTestResponseStringIntNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -100910,6 +128310,8 @@ func (s *Server) handleTestResponseStringIntNullableArrayArrayRequest(args [0]st // // POST /test_response_string_ipv4 func (s *Server) handleTestResponseStringIpv4Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv4"), semconv.HTTPRequestMethodKey.String("POST"), @@ -100931,7 +128333,16 @@ func (s *Server) handleTestResponseStringIpv4Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -100943,8 +128354,27 @@ func (s *Server) handleTestResponseStringIpv4Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101020,6 +128450,8 @@ func (s *Server) handleTestResponseStringIpv4Request(args [0]string, argsEscaped // // POST /test_response_string_ipv4_array func (s *Server) handleTestResponseStringIpv4ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv4_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101041,7 +128473,16 @@ func (s *Server) handleTestResponseStringIpv4ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101053,8 +128494,27 @@ func (s *Server) handleTestResponseStringIpv4ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101130,6 +128590,8 @@ func (s *Server) handleTestResponseStringIpv4ArrayRequest(args [0]string, argsEs // // POST /test_response_string_ipv4_array_array func (s *Server) handleTestResponseStringIpv4ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv4_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101151,7 +128613,16 @@ func (s *Server) handleTestResponseStringIpv4ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101163,8 +128634,27 @@ func (s *Server) handleTestResponseStringIpv4ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101240,6 +128730,8 @@ func (s *Server) handleTestResponseStringIpv4ArrayArrayRequest(args [0]string, a // // POST /test_response_string_ipv4_nullable func (s *Server) handleTestResponseStringIpv4NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv4_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101261,7 +128753,16 @@ func (s *Server) handleTestResponseStringIpv4NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101273,8 +128774,27 @@ func (s *Server) handleTestResponseStringIpv4NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101350,6 +128870,8 @@ func (s *Server) handleTestResponseStringIpv4NullableRequest(args [0]string, arg // // POST /test_response_string_ipv4_nullable_array func (s *Server) handleTestResponseStringIpv4NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv4_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101371,7 +128893,16 @@ func (s *Server) handleTestResponseStringIpv4NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101383,8 +128914,27 @@ func (s *Server) handleTestResponseStringIpv4NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101460,6 +129010,8 @@ func (s *Server) handleTestResponseStringIpv4NullableArrayRequest(args [0]string // // POST /test_response_string_ipv4_nullable_array_array func (s *Server) handleTestResponseStringIpv4NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv4_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101481,7 +129033,16 @@ func (s *Server) handleTestResponseStringIpv4NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101493,8 +129054,27 @@ func (s *Server) handleTestResponseStringIpv4NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101570,6 +129150,8 @@ func (s *Server) handleTestResponseStringIpv4NullableArrayArrayRequest(args [0]s // // POST /test_response_string_ipv6 func (s *Server) handleTestResponseStringIpv6Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv6"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101591,7 +129173,16 @@ func (s *Server) handleTestResponseStringIpv6Request(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101603,8 +129194,27 @@ func (s *Server) handleTestResponseStringIpv6Request(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101680,6 +129290,8 @@ func (s *Server) handleTestResponseStringIpv6Request(args [0]string, argsEscaped // // POST /test_response_string_ipv6_array func (s *Server) handleTestResponseStringIpv6ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv6_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101701,7 +129313,16 @@ func (s *Server) handleTestResponseStringIpv6ArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101713,8 +129334,27 @@ func (s *Server) handleTestResponseStringIpv6ArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101790,6 +129430,8 @@ func (s *Server) handleTestResponseStringIpv6ArrayRequest(args [0]string, argsEs // // POST /test_response_string_ipv6_array_array func (s *Server) handleTestResponseStringIpv6ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv6_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101811,7 +129453,16 @@ func (s *Server) handleTestResponseStringIpv6ArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101823,8 +129474,27 @@ func (s *Server) handleTestResponseStringIpv6ArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -101900,6 +129570,8 @@ func (s *Server) handleTestResponseStringIpv6ArrayArrayRequest(args [0]string, a // // POST /test_response_string_ipv6_nullable func (s *Server) handleTestResponseStringIpv6NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv6_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -101921,7 +129593,16 @@ func (s *Server) handleTestResponseStringIpv6NullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -101933,8 +129614,27 @@ func (s *Server) handleTestResponseStringIpv6NullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102010,6 +129710,8 @@ func (s *Server) handleTestResponseStringIpv6NullableRequest(args [0]string, arg // // POST /test_response_string_ipv6_nullable_array func (s *Server) handleTestResponseStringIpv6NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv6_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102031,7 +129733,16 @@ func (s *Server) handleTestResponseStringIpv6NullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102043,8 +129754,27 @@ func (s *Server) handleTestResponseStringIpv6NullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102120,6 +129850,8 @@ func (s *Server) handleTestResponseStringIpv6NullableArrayRequest(args [0]string // // POST /test_response_string_ipv6_nullable_array_array func (s *Server) handleTestResponseStringIpv6NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_ipv6_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102141,7 +129873,16 @@ func (s *Server) handleTestResponseStringIpv6NullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102153,8 +129894,27 @@ func (s *Server) handleTestResponseStringIpv6NullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102230,6 +129990,8 @@ func (s *Server) handleTestResponseStringIpv6NullableArrayArrayRequest(args [0]s // // POST /test_response_string_mac func (s *Server) handleTestResponseStringMACRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_mac"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102251,7 +130013,16 @@ func (s *Server) handleTestResponseStringMACRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102263,8 +130034,27 @@ func (s *Server) handleTestResponseStringMACRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102340,6 +130130,8 @@ func (s *Server) handleTestResponseStringMACRequest(args [0]string, argsEscaped // // POST /test_response_string_mac_array func (s *Server) handleTestResponseStringMACArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_mac_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102361,7 +130153,16 @@ func (s *Server) handleTestResponseStringMACArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102373,8 +130174,27 @@ func (s *Server) handleTestResponseStringMACArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102450,6 +130270,8 @@ func (s *Server) handleTestResponseStringMACArrayRequest(args [0]string, argsEsc // // POST /test_response_string_mac_array_array func (s *Server) handleTestResponseStringMACArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_mac_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102471,7 +130293,16 @@ func (s *Server) handleTestResponseStringMACArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102483,8 +130314,27 @@ func (s *Server) handleTestResponseStringMACArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102560,6 +130410,8 @@ func (s *Server) handleTestResponseStringMACArrayArrayRequest(args [0]string, ar // // POST /test_response_string_mac_nullable func (s *Server) handleTestResponseStringMACNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_mac_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102581,7 +130433,16 @@ func (s *Server) handleTestResponseStringMACNullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102593,8 +130454,27 @@ func (s *Server) handleTestResponseStringMACNullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102670,6 +130550,8 @@ func (s *Server) handleTestResponseStringMACNullableRequest(args [0]string, args // // POST /test_response_string_mac_nullable_array func (s *Server) handleTestResponseStringMACNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_mac_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102691,7 +130573,16 @@ func (s *Server) handleTestResponseStringMACNullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102703,8 +130594,27 @@ func (s *Server) handleTestResponseStringMACNullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102780,6 +130690,8 @@ func (s *Server) handleTestResponseStringMACNullableArrayRequest(args [0]string, // // POST /test_response_string_mac_nullable_array_array func (s *Server) handleTestResponseStringMACNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_mac_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102801,7 +130713,16 @@ func (s *Server) handleTestResponseStringMACNullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102813,8 +130734,27 @@ func (s *Server) handleTestResponseStringMACNullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -102890,6 +130830,8 @@ func (s *Server) handleTestResponseStringMACNullableArrayArrayRequest(args [0]st // // POST /test_response_string_nullable func (s *Server) handleTestResponseStringNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -102911,7 +130853,16 @@ func (s *Server) handleTestResponseStringNullableRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -102923,8 +130874,27 @@ func (s *Server) handleTestResponseStringNullableRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103000,6 +130970,8 @@ func (s *Server) handleTestResponseStringNullableRequest(args [0]string, argsEsc // // POST /test_response_string_nullable_array func (s *Server) handleTestResponseStringNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103021,7 +130993,16 @@ func (s *Server) handleTestResponseStringNullableArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103033,8 +131014,27 @@ func (s *Server) handleTestResponseStringNullableArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103110,6 +131110,8 @@ func (s *Server) handleTestResponseStringNullableArrayRequest(args [0]string, ar // // POST /test_response_string_nullable_array_array func (s *Server) handleTestResponseStringNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103131,7 +131133,16 @@ func (s *Server) handleTestResponseStringNullableArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103143,8 +131154,27 @@ func (s *Server) handleTestResponseStringNullableArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103220,6 +131250,8 @@ func (s *Server) handleTestResponseStringNullableArrayArrayRequest(args [0]strin // // POST /test_response_string_password func (s *Server) handleTestResponseStringPasswordRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_password"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103241,7 +131273,16 @@ func (s *Server) handleTestResponseStringPasswordRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103253,8 +131294,27 @@ func (s *Server) handleTestResponseStringPasswordRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103330,6 +131390,8 @@ func (s *Server) handleTestResponseStringPasswordRequest(args [0]string, argsEsc // // POST /test_response_string_password_array func (s *Server) handleTestResponseStringPasswordArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_password_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103351,7 +131413,16 @@ func (s *Server) handleTestResponseStringPasswordArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103363,8 +131434,27 @@ func (s *Server) handleTestResponseStringPasswordArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103440,6 +131530,8 @@ func (s *Server) handleTestResponseStringPasswordArrayRequest(args [0]string, ar // // POST /test_response_string_password_array_array func (s *Server) handleTestResponseStringPasswordArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_password_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103461,7 +131553,16 @@ func (s *Server) handleTestResponseStringPasswordArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103473,8 +131574,27 @@ func (s *Server) handleTestResponseStringPasswordArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103550,6 +131670,8 @@ func (s *Server) handleTestResponseStringPasswordArrayArrayRequest(args [0]strin // // POST /test_response_string_password_nullable func (s *Server) handleTestResponseStringPasswordNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_password_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103571,7 +131693,16 @@ func (s *Server) handleTestResponseStringPasswordNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103583,8 +131714,27 @@ func (s *Server) handleTestResponseStringPasswordNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103660,6 +131810,8 @@ func (s *Server) handleTestResponseStringPasswordNullableRequest(args [0]string, // // POST /test_response_string_password_nullable_array func (s *Server) handleTestResponseStringPasswordNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_password_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103681,7 +131833,16 @@ func (s *Server) handleTestResponseStringPasswordNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103693,8 +131854,27 @@ func (s *Server) handleTestResponseStringPasswordNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103770,6 +131950,8 @@ func (s *Server) handleTestResponseStringPasswordNullableArrayRequest(args [0]st // // POST /test_response_string_password_nullable_array_array func (s *Server) handleTestResponseStringPasswordNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_password_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103791,7 +131973,16 @@ func (s *Server) handleTestResponseStringPasswordNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103803,8 +131994,27 @@ func (s *Server) handleTestResponseStringPasswordNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103880,6 +132090,8 @@ func (s *Server) handleTestResponseStringPasswordNullableArrayArrayRequest(args // // POST /test_response_string_time func (s *Server) handleTestResponseStringTimeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_time"), semconv.HTTPRequestMethodKey.String("POST"), @@ -103901,7 +132113,16 @@ func (s *Server) handleTestResponseStringTimeRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -103913,8 +132134,27 @@ func (s *Server) handleTestResponseStringTimeRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -103990,6 +132230,8 @@ func (s *Server) handleTestResponseStringTimeRequest(args [0]string, argsEscaped // // POST /test_response_string_time_array func (s *Server) handleTestResponseStringTimeArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_time_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104011,7 +132253,16 @@ func (s *Server) handleTestResponseStringTimeArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104023,8 +132274,27 @@ func (s *Server) handleTestResponseStringTimeArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104100,6 +132370,8 @@ func (s *Server) handleTestResponseStringTimeArrayRequest(args [0]string, argsEs // // POST /test_response_string_time_array_array func (s *Server) handleTestResponseStringTimeArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_time_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104121,7 +132393,16 @@ func (s *Server) handleTestResponseStringTimeArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104133,8 +132414,27 @@ func (s *Server) handleTestResponseStringTimeArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104210,6 +132510,8 @@ func (s *Server) handleTestResponseStringTimeArrayArrayRequest(args [0]string, a // // POST /test_response_string_time_nullable func (s *Server) handleTestResponseStringTimeNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_time_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104231,7 +132533,16 @@ func (s *Server) handleTestResponseStringTimeNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104243,8 +132554,27 @@ func (s *Server) handleTestResponseStringTimeNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104320,6 +132650,8 @@ func (s *Server) handleTestResponseStringTimeNullableRequest(args [0]string, arg // // POST /test_response_string_time_nullable_array func (s *Server) handleTestResponseStringTimeNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_time_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104341,7 +132673,16 @@ func (s *Server) handleTestResponseStringTimeNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104353,8 +132694,27 @@ func (s *Server) handleTestResponseStringTimeNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104430,6 +132790,8 @@ func (s *Server) handleTestResponseStringTimeNullableArrayRequest(args [0]string // // POST /test_response_string_time_nullable_array_array func (s *Server) handleTestResponseStringTimeNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_time_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104451,7 +132813,16 @@ func (s *Server) handleTestResponseStringTimeNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104463,8 +132834,27 @@ func (s *Server) handleTestResponseStringTimeNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104540,6 +132930,8 @@ func (s *Server) handleTestResponseStringTimeNullableArrayArrayRequest(args [0]s // // POST /test_response_string_uri func (s *Server) handleTestResponseStringURIRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uri"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104561,7 +132953,16 @@ func (s *Server) handleTestResponseStringURIRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104573,8 +132974,27 @@ func (s *Server) handleTestResponseStringURIRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104650,6 +133070,8 @@ func (s *Server) handleTestResponseStringURIRequest(args [0]string, argsEscaped // // POST /test_response_string_uri_array func (s *Server) handleTestResponseStringURIArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uri_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104671,7 +133093,16 @@ func (s *Server) handleTestResponseStringURIArrayRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104683,8 +133114,27 @@ func (s *Server) handleTestResponseStringURIArrayRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104760,6 +133210,8 @@ func (s *Server) handleTestResponseStringURIArrayRequest(args [0]string, argsEsc // // POST /test_response_string_uri_array_array func (s *Server) handleTestResponseStringURIArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uri_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104781,7 +133233,16 @@ func (s *Server) handleTestResponseStringURIArrayArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104793,8 +133254,27 @@ func (s *Server) handleTestResponseStringURIArrayArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104870,6 +133350,8 @@ func (s *Server) handleTestResponseStringURIArrayArrayRequest(args [0]string, ar // // POST /test_response_string_uri_nullable func (s *Server) handleTestResponseStringURINullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uri_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -104891,7 +133373,16 @@ func (s *Server) handleTestResponseStringURINullableRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -104903,8 +133394,27 @@ func (s *Server) handleTestResponseStringURINullableRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -104980,6 +133490,8 @@ func (s *Server) handleTestResponseStringURINullableRequest(args [0]string, args // // POST /test_response_string_uri_nullable_array func (s *Server) handleTestResponseStringURINullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uri_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105001,7 +133513,16 @@ func (s *Server) handleTestResponseStringURINullableArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105013,8 +133534,27 @@ func (s *Server) handleTestResponseStringURINullableArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105090,6 +133630,8 @@ func (s *Server) handleTestResponseStringURINullableArrayRequest(args [0]string, // // POST /test_response_string_uri_nullable_array_array func (s *Server) handleTestResponseStringURINullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uri_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105111,7 +133653,16 @@ func (s *Server) handleTestResponseStringURINullableArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105123,8 +133674,27 @@ func (s *Server) handleTestResponseStringURINullableArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105200,6 +133770,8 @@ func (s *Server) handleTestResponseStringURINullableArrayArrayRequest(args [0]st // // POST /test_response_string_uuid func (s *Server) handleTestResponseStringUUIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uuid"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105221,7 +133793,16 @@ func (s *Server) handleTestResponseStringUUIDRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105233,8 +133814,27 @@ func (s *Server) handleTestResponseStringUUIDRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105310,6 +133910,8 @@ func (s *Server) handleTestResponseStringUUIDRequest(args [0]string, argsEscaped // // POST /test_response_string_uuid_array func (s *Server) handleTestResponseStringUUIDArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uuid_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105331,7 +133933,16 @@ func (s *Server) handleTestResponseStringUUIDArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105343,8 +133954,27 @@ func (s *Server) handleTestResponseStringUUIDArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105420,6 +134050,8 @@ func (s *Server) handleTestResponseStringUUIDArrayRequest(args [0]string, argsEs // // POST /test_response_string_uuid_array_array func (s *Server) handleTestResponseStringUUIDArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uuid_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105441,7 +134073,16 @@ func (s *Server) handleTestResponseStringUUIDArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105453,8 +134094,27 @@ func (s *Server) handleTestResponseStringUUIDArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105530,6 +134190,8 @@ func (s *Server) handleTestResponseStringUUIDArrayArrayRequest(args [0]string, a // // POST /test_response_string_uuid_nullable func (s *Server) handleTestResponseStringUUIDNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uuid_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105551,7 +134213,16 @@ func (s *Server) handleTestResponseStringUUIDNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105563,8 +134234,27 @@ func (s *Server) handleTestResponseStringUUIDNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105640,6 +134330,8 @@ func (s *Server) handleTestResponseStringUUIDNullableRequest(args [0]string, arg // // POST /test_response_string_uuid_nullable_array func (s *Server) handleTestResponseStringUUIDNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uuid_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105661,7 +134353,16 @@ func (s *Server) handleTestResponseStringUUIDNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105673,8 +134374,27 @@ func (s *Server) handleTestResponseStringUUIDNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105750,6 +134470,8 @@ func (s *Server) handleTestResponseStringUUIDNullableArrayRequest(args [0]string // // POST /test_response_string_uuid_nullable_array_array func (s *Server) handleTestResponseStringUUIDNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uuid_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105771,7 +134493,16 @@ func (s *Server) handleTestResponseStringUUIDNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105783,8 +134514,27 @@ func (s *Server) handleTestResponseStringUUIDNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105860,6 +134610,8 @@ func (s *Server) handleTestResponseStringUUIDNullableArrayArrayRequest(args [0]s // // POST /test_response_string_uint func (s *Server) handleTestResponseStringUintRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105881,7 +134633,16 @@ func (s *Server) handleTestResponseStringUintRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -105893,8 +134654,27 @@ func (s *Server) handleTestResponseStringUintRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -105970,6 +134750,8 @@ func (s *Server) handleTestResponseStringUintRequest(args [0]string, argsEscaped // // POST /test_response_string_uint16 func (s *Server) handleTestResponseStringUint16Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint16"), semconv.HTTPRequestMethodKey.String("POST"), @@ -105991,7 +134773,16 @@ func (s *Server) handleTestResponseStringUint16Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106003,8 +134794,27 @@ func (s *Server) handleTestResponseStringUint16Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106080,6 +134890,8 @@ func (s *Server) handleTestResponseStringUint16Request(args [0]string, argsEscap // // POST /test_response_string_uint16_array func (s *Server) handleTestResponseStringUint16ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint16_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106101,7 +134913,16 @@ func (s *Server) handleTestResponseStringUint16ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106113,8 +134934,27 @@ func (s *Server) handleTestResponseStringUint16ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106190,6 +135030,8 @@ func (s *Server) handleTestResponseStringUint16ArrayRequest(args [0]string, args // // POST /test_response_string_uint16_array_array func (s *Server) handleTestResponseStringUint16ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint16_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106211,7 +135053,16 @@ func (s *Server) handleTestResponseStringUint16ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106223,8 +135074,27 @@ func (s *Server) handleTestResponseStringUint16ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106300,6 +135170,8 @@ func (s *Server) handleTestResponseStringUint16ArrayArrayRequest(args [0]string, // // POST /test_response_string_uint16_nullable func (s *Server) handleTestResponseStringUint16NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint16_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106321,7 +135193,16 @@ func (s *Server) handleTestResponseStringUint16NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106333,8 +135214,27 @@ func (s *Server) handleTestResponseStringUint16NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106410,6 +135310,8 @@ func (s *Server) handleTestResponseStringUint16NullableRequest(args [0]string, a // // POST /test_response_string_uint16_nullable_array func (s *Server) handleTestResponseStringUint16NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint16_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106431,7 +135333,16 @@ func (s *Server) handleTestResponseStringUint16NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106443,8 +135354,27 @@ func (s *Server) handleTestResponseStringUint16NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106520,6 +135450,8 @@ func (s *Server) handleTestResponseStringUint16NullableArrayRequest(args [0]stri // // POST /test_response_string_uint16_nullable_array_array func (s *Server) handleTestResponseStringUint16NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint16_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106541,7 +135473,16 @@ func (s *Server) handleTestResponseStringUint16NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106553,8 +135494,27 @@ func (s *Server) handleTestResponseStringUint16NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106630,6 +135590,8 @@ func (s *Server) handleTestResponseStringUint16NullableArrayArrayRequest(args [0 // // POST /test_response_string_uint32 func (s *Server) handleTestResponseStringUint32Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint32"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106651,7 +135613,16 @@ func (s *Server) handleTestResponseStringUint32Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106663,8 +135634,27 @@ func (s *Server) handleTestResponseStringUint32Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106740,6 +135730,8 @@ func (s *Server) handleTestResponseStringUint32Request(args [0]string, argsEscap // // POST /test_response_string_uint32_array func (s *Server) handleTestResponseStringUint32ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint32_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106761,7 +135753,16 @@ func (s *Server) handleTestResponseStringUint32ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106773,8 +135774,27 @@ func (s *Server) handleTestResponseStringUint32ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106850,6 +135870,8 @@ func (s *Server) handleTestResponseStringUint32ArrayRequest(args [0]string, args // // POST /test_response_string_uint32_array_array func (s *Server) handleTestResponseStringUint32ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint32_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106871,7 +135893,16 @@ func (s *Server) handleTestResponseStringUint32ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106883,8 +135914,27 @@ func (s *Server) handleTestResponseStringUint32ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -106960,6 +136010,8 @@ func (s *Server) handleTestResponseStringUint32ArrayArrayRequest(args [0]string, // // POST /test_response_string_uint32_nullable func (s *Server) handleTestResponseStringUint32NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint32_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -106981,7 +136033,16 @@ func (s *Server) handleTestResponseStringUint32NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -106993,8 +136054,27 @@ func (s *Server) handleTestResponseStringUint32NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107070,6 +136150,8 @@ func (s *Server) handleTestResponseStringUint32NullableRequest(args [0]string, a // // POST /test_response_string_uint32_nullable_array func (s *Server) handleTestResponseStringUint32NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint32_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107091,7 +136173,16 @@ func (s *Server) handleTestResponseStringUint32NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107103,8 +136194,27 @@ func (s *Server) handleTestResponseStringUint32NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107180,6 +136290,8 @@ func (s *Server) handleTestResponseStringUint32NullableArrayRequest(args [0]stri // // POST /test_response_string_uint32_nullable_array_array func (s *Server) handleTestResponseStringUint32NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint32_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107201,7 +136313,16 @@ func (s *Server) handleTestResponseStringUint32NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107213,8 +136334,27 @@ func (s *Server) handleTestResponseStringUint32NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107290,6 +136430,8 @@ func (s *Server) handleTestResponseStringUint32NullableArrayArrayRequest(args [0 // // POST /test_response_string_uint64 func (s *Server) handleTestResponseStringUint64Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint64"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107311,7 +136453,16 @@ func (s *Server) handleTestResponseStringUint64Request(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107323,8 +136474,27 @@ func (s *Server) handleTestResponseStringUint64Request(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107400,6 +136570,8 @@ func (s *Server) handleTestResponseStringUint64Request(args [0]string, argsEscap // // POST /test_response_string_uint64_array func (s *Server) handleTestResponseStringUint64ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint64_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107421,7 +136593,16 @@ func (s *Server) handleTestResponseStringUint64ArrayRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107433,8 +136614,27 @@ func (s *Server) handleTestResponseStringUint64ArrayRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107510,6 +136710,8 @@ func (s *Server) handleTestResponseStringUint64ArrayRequest(args [0]string, args // // POST /test_response_string_uint64_array_array func (s *Server) handleTestResponseStringUint64ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint64_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107531,7 +136733,16 @@ func (s *Server) handleTestResponseStringUint64ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107543,8 +136754,27 @@ func (s *Server) handleTestResponseStringUint64ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107620,6 +136850,8 @@ func (s *Server) handleTestResponseStringUint64ArrayArrayRequest(args [0]string, // // POST /test_response_string_uint64_nullable func (s *Server) handleTestResponseStringUint64NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint64_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107641,7 +136873,16 @@ func (s *Server) handleTestResponseStringUint64NullableRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107653,8 +136894,27 @@ func (s *Server) handleTestResponseStringUint64NullableRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107730,6 +136990,8 @@ func (s *Server) handleTestResponseStringUint64NullableRequest(args [0]string, a // // POST /test_response_string_uint64_nullable_array func (s *Server) handleTestResponseStringUint64NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint64_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107751,7 +137013,16 @@ func (s *Server) handleTestResponseStringUint64NullableArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107763,8 +137034,27 @@ func (s *Server) handleTestResponseStringUint64NullableArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107840,6 +137130,8 @@ func (s *Server) handleTestResponseStringUint64NullableArrayRequest(args [0]stri // // POST /test_response_string_uint64_nullable_array_array func (s *Server) handleTestResponseStringUint64NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint64_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107861,7 +137153,16 @@ func (s *Server) handleTestResponseStringUint64NullableArrayArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107873,8 +137174,27 @@ func (s *Server) handleTestResponseStringUint64NullableArrayArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -107950,6 +137270,8 @@ func (s *Server) handleTestResponseStringUint64NullableArrayArrayRequest(args [0 // // POST /test_response_string_uint8 func (s *Server) handleTestResponseStringUint8Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint8"), semconv.HTTPRequestMethodKey.String("POST"), @@ -107971,7 +137293,16 @@ func (s *Server) handleTestResponseStringUint8Request(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -107983,8 +137314,27 @@ func (s *Server) handleTestResponseStringUint8Request(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108060,6 +137410,8 @@ func (s *Server) handleTestResponseStringUint8Request(args [0]string, argsEscape // // POST /test_response_string_uint8_array func (s *Server) handleTestResponseStringUint8ArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint8_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108081,7 +137433,16 @@ func (s *Server) handleTestResponseStringUint8ArrayRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108093,8 +137454,27 @@ func (s *Server) handleTestResponseStringUint8ArrayRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108170,6 +137550,8 @@ func (s *Server) handleTestResponseStringUint8ArrayRequest(args [0]string, argsE // // POST /test_response_string_uint8_array_array func (s *Server) handleTestResponseStringUint8ArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint8_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108191,7 +137573,16 @@ func (s *Server) handleTestResponseStringUint8ArrayArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108203,8 +137594,27 @@ func (s *Server) handleTestResponseStringUint8ArrayArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108280,6 +137690,8 @@ func (s *Server) handleTestResponseStringUint8ArrayArrayRequest(args [0]string, // // POST /test_response_string_uint8_nullable func (s *Server) handleTestResponseStringUint8NullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint8_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108301,7 +137713,16 @@ func (s *Server) handleTestResponseStringUint8NullableRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108313,8 +137734,27 @@ func (s *Server) handleTestResponseStringUint8NullableRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108390,6 +137830,8 @@ func (s *Server) handleTestResponseStringUint8NullableRequest(args [0]string, ar // // POST /test_response_string_uint8_nullable_array func (s *Server) handleTestResponseStringUint8NullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint8_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108411,7 +137853,16 @@ func (s *Server) handleTestResponseStringUint8NullableArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108423,8 +137874,27 @@ func (s *Server) handleTestResponseStringUint8NullableArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108500,6 +137970,8 @@ func (s *Server) handleTestResponseStringUint8NullableArrayRequest(args [0]strin // // POST /test_response_string_uint8_nullable_array_array func (s *Server) handleTestResponseStringUint8NullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint8_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108521,7 +137993,16 @@ func (s *Server) handleTestResponseStringUint8NullableArrayArrayRequest(args [0] startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108533,8 +138014,27 @@ func (s *Server) handleTestResponseStringUint8NullableArrayArrayRequest(args [0] var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108610,6 +138110,8 @@ func (s *Server) handleTestResponseStringUint8NullableArrayArrayRequest(args [0] // // POST /test_response_string_uint_array func (s *Server) handleTestResponseStringUintArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108631,7 +138133,16 @@ func (s *Server) handleTestResponseStringUintArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108643,8 +138154,27 @@ func (s *Server) handleTestResponseStringUintArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108720,6 +138250,8 @@ func (s *Server) handleTestResponseStringUintArrayRequest(args [0]string, argsEs // // POST /test_response_string_uint_array_array func (s *Server) handleTestResponseStringUintArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108741,7 +138273,16 @@ func (s *Server) handleTestResponseStringUintArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108753,8 +138294,27 @@ func (s *Server) handleTestResponseStringUintArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108830,6 +138390,8 @@ func (s *Server) handleTestResponseStringUintArrayArrayRequest(args [0]string, a // // POST /test_response_string_uint_nullable func (s *Server) handleTestResponseStringUintNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108851,7 +138413,16 @@ func (s *Server) handleTestResponseStringUintNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108863,8 +138434,27 @@ func (s *Server) handleTestResponseStringUintNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -108940,6 +138530,8 @@ func (s *Server) handleTestResponseStringUintNullableRequest(args [0]string, arg // // POST /test_response_string_uint_nullable_array func (s *Server) handleTestResponseStringUintNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -108961,7 +138553,16 @@ func (s *Server) handleTestResponseStringUintNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -108973,8 +138574,27 @@ func (s *Server) handleTestResponseStringUintNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109050,6 +138670,8 @@ func (s *Server) handleTestResponseStringUintNullableArrayRequest(args [0]string // // POST /test_response_string_uint_nullable_array_array func (s *Server) handleTestResponseStringUintNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_uint_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109071,7 +138693,16 @@ func (s *Server) handleTestResponseStringUintNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109083,8 +138714,27 @@ func (s *Server) handleTestResponseStringUintNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109160,6 +138810,8 @@ func (s *Server) handleTestResponseStringUintNullableArrayArrayRequest(args [0]s // // POST /test_response_string_unix func (s *Server) handleTestResponseStringUnixRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109181,7 +138833,16 @@ func (s *Server) handleTestResponseStringUnixRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109193,8 +138854,27 @@ func (s *Server) handleTestResponseStringUnixRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109270,6 +138950,8 @@ func (s *Server) handleTestResponseStringUnixRequest(args [0]string, argsEscaped // // POST /test_response_string_unix_array func (s *Server) handleTestResponseStringUnixArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109291,7 +138973,16 @@ func (s *Server) handleTestResponseStringUnixArrayRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109303,8 +138994,27 @@ func (s *Server) handleTestResponseStringUnixArrayRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109380,6 +139090,8 @@ func (s *Server) handleTestResponseStringUnixArrayRequest(args [0]string, argsEs // // POST /test_response_string_unix_array_array func (s *Server) handleTestResponseStringUnixArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109401,7 +139113,16 @@ func (s *Server) handleTestResponseStringUnixArrayArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109413,8 +139134,27 @@ func (s *Server) handleTestResponseStringUnixArrayArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109490,6 +139230,8 @@ func (s *Server) handleTestResponseStringUnixArrayArrayRequest(args [0]string, a // // POST /test_response_string_unix-micro func (s *Server) handleTestResponseStringUnixMicroRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-micro"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109511,7 +139253,16 @@ func (s *Server) handleTestResponseStringUnixMicroRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109523,8 +139274,27 @@ func (s *Server) handleTestResponseStringUnixMicroRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109600,6 +139370,8 @@ func (s *Server) handleTestResponseStringUnixMicroRequest(args [0]string, argsEs // // POST /test_response_string_unix-micro_array func (s *Server) handleTestResponseStringUnixMicroArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-micro_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109621,7 +139393,16 @@ func (s *Server) handleTestResponseStringUnixMicroArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109633,8 +139414,27 @@ func (s *Server) handleTestResponseStringUnixMicroArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109710,6 +139510,8 @@ func (s *Server) handleTestResponseStringUnixMicroArrayRequest(args [0]string, a // // POST /test_response_string_unix-micro_array_array func (s *Server) handleTestResponseStringUnixMicroArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-micro_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109731,7 +139533,16 @@ func (s *Server) handleTestResponseStringUnixMicroArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109743,8 +139554,27 @@ func (s *Server) handleTestResponseStringUnixMicroArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109820,6 +139650,8 @@ func (s *Server) handleTestResponseStringUnixMicroArrayArrayRequest(args [0]stri // // POST /test_response_string_unix-micro_nullable func (s *Server) handleTestResponseStringUnixMicroNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-micro_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109841,7 +139673,16 @@ func (s *Server) handleTestResponseStringUnixMicroNullableRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109853,8 +139694,27 @@ func (s *Server) handleTestResponseStringUnixMicroNullableRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -109930,6 +139790,8 @@ func (s *Server) handleTestResponseStringUnixMicroNullableRequest(args [0]string // // POST /test_response_string_unix-micro_nullable_array func (s *Server) handleTestResponseStringUnixMicroNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-micro_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -109951,7 +139813,16 @@ func (s *Server) handleTestResponseStringUnixMicroNullableArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -109963,8 +139834,27 @@ func (s *Server) handleTestResponseStringUnixMicroNullableArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110040,6 +139930,8 @@ func (s *Server) handleTestResponseStringUnixMicroNullableArrayRequest(args [0]s // // POST /test_response_string_unix-micro_nullable_array_array func (s *Server) handleTestResponseStringUnixMicroNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-micro_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110061,7 +139953,16 @@ func (s *Server) handleTestResponseStringUnixMicroNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110073,8 +139974,27 @@ func (s *Server) handleTestResponseStringUnixMicroNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110150,6 +140070,8 @@ func (s *Server) handleTestResponseStringUnixMicroNullableArrayArrayRequest(args // // POST /test_response_string_unix-milli func (s *Server) handleTestResponseStringUnixMilliRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-milli"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110171,7 +140093,16 @@ func (s *Server) handleTestResponseStringUnixMilliRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110183,8 +140114,27 @@ func (s *Server) handleTestResponseStringUnixMilliRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110260,6 +140210,8 @@ func (s *Server) handleTestResponseStringUnixMilliRequest(args [0]string, argsEs // // POST /test_response_string_unix-milli_array func (s *Server) handleTestResponseStringUnixMilliArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-milli_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110281,7 +140233,16 @@ func (s *Server) handleTestResponseStringUnixMilliArrayRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110293,8 +140254,27 @@ func (s *Server) handleTestResponseStringUnixMilliArrayRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110370,6 +140350,8 @@ func (s *Server) handleTestResponseStringUnixMilliArrayRequest(args [0]string, a // // POST /test_response_string_unix-milli_array_array func (s *Server) handleTestResponseStringUnixMilliArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-milli_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110391,7 +140373,16 @@ func (s *Server) handleTestResponseStringUnixMilliArrayArrayRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110403,8 +140394,27 @@ func (s *Server) handleTestResponseStringUnixMilliArrayArrayRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110480,6 +140490,8 @@ func (s *Server) handleTestResponseStringUnixMilliArrayArrayRequest(args [0]stri // // POST /test_response_string_unix-milli_nullable func (s *Server) handleTestResponseStringUnixMilliNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-milli_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110501,7 +140513,16 @@ func (s *Server) handleTestResponseStringUnixMilliNullableRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110513,8 +140534,27 @@ func (s *Server) handleTestResponseStringUnixMilliNullableRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110590,6 +140630,8 @@ func (s *Server) handleTestResponseStringUnixMilliNullableRequest(args [0]string // // POST /test_response_string_unix-milli_nullable_array func (s *Server) handleTestResponseStringUnixMilliNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-milli_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110611,7 +140653,16 @@ func (s *Server) handleTestResponseStringUnixMilliNullableArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110623,8 +140674,27 @@ func (s *Server) handleTestResponseStringUnixMilliNullableArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110700,6 +140770,8 @@ func (s *Server) handleTestResponseStringUnixMilliNullableArrayRequest(args [0]s // // POST /test_response_string_unix-milli_nullable_array_array func (s *Server) handleTestResponseStringUnixMilliNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-milli_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110721,7 +140793,16 @@ func (s *Server) handleTestResponseStringUnixMilliNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110733,8 +140814,27 @@ func (s *Server) handleTestResponseStringUnixMilliNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110810,6 +140910,8 @@ func (s *Server) handleTestResponseStringUnixMilliNullableArrayArrayRequest(args // // POST /test_response_string_unix-nano func (s *Server) handleTestResponseStringUnixNanoRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-nano"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110831,7 +140933,16 @@ func (s *Server) handleTestResponseStringUnixNanoRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110843,8 +140954,27 @@ func (s *Server) handleTestResponseStringUnixNanoRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -110920,6 +141050,8 @@ func (s *Server) handleTestResponseStringUnixNanoRequest(args [0]string, argsEsc // // POST /test_response_string_unix-nano_array func (s *Server) handleTestResponseStringUnixNanoArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-nano_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -110941,7 +141073,16 @@ func (s *Server) handleTestResponseStringUnixNanoArrayRequest(args [0]string, ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -110953,8 +141094,27 @@ func (s *Server) handleTestResponseStringUnixNanoArrayRequest(args [0]string, ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111030,6 +141190,8 @@ func (s *Server) handleTestResponseStringUnixNanoArrayRequest(args [0]string, ar // // POST /test_response_string_unix-nano_array_array func (s *Server) handleTestResponseStringUnixNanoArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-nano_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111051,7 +141213,16 @@ func (s *Server) handleTestResponseStringUnixNanoArrayArrayRequest(args [0]strin startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111063,8 +141234,27 @@ func (s *Server) handleTestResponseStringUnixNanoArrayArrayRequest(args [0]strin var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111140,6 +141330,8 @@ func (s *Server) handleTestResponseStringUnixNanoArrayArrayRequest(args [0]strin // // POST /test_response_string_unix-nano_nullable func (s *Server) handleTestResponseStringUnixNanoNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-nano_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111161,7 +141353,16 @@ func (s *Server) handleTestResponseStringUnixNanoNullableRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111173,8 +141374,27 @@ func (s *Server) handleTestResponseStringUnixNanoNullableRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111250,6 +141470,8 @@ func (s *Server) handleTestResponseStringUnixNanoNullableRequest(args [0]string, // // POST /test_response_string_unix-nano_nullable_array func (s *Server) handleTestResponseStringUnixNanoNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-nano_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111271,7 +141493,16 @@ func (s *Server) handleTestResponseStringUnixNanoNullableArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111283,8 +141514,27 @@ func (s *Server) handleTestResponseStringUnixNanoNullableArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111360,6 +141610,8 @@ func (s *Server) handleTestResponseStringUnixNanoNullableArrayRequest(args [0]st // // POST /test_response_string_unix-nano_nullable_array_array func (s *Server) handleTestResponseStringUnixNanoNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-nano_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111381,7 +141633,16 @@ func (s *Server) handleTestResponseStringUnixNanoNullableArrayArrayRequest(args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111393,8 +141654,27 @@ func (s *Server) handleTestResponseStringUnixNanoNullableArrayArrayRequest(args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111470,6 +141750,8 @@ func (s *Server) handleTestResponseStringUnixNanoNullableArrayArrayRequest(args // // POST /test_response_string_unix_nullable func (s *Server) handleTestResponseStringUnixNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111491,7 +141773,16 @@ func (s *Server) handleTestResponseStringUnixNullableRequest(args [0]string, arg startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111503,8 +141794,27 @@ func (s *Server) handleTestResponseStringUnixNullableRequest(args [0]string, arg var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111580,6 +141890,8 @@ func (s *Server) handleTestResponseStringUnixNullableRequest(args [0]string, arg // // POST /test_response_string_unix_nullable_array func (s *Server) handleTestResponseStringUnixNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111601,7 +141913,16 @@ func (s *Server) handleTestResponseStringUnixNullableArrayRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111613,8 +141934,27 @@ func (s *Server) handleTestResponseStringUnixNullableArrayRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111690,6 +142030,8 @@ func (s *Server) handleTestResponseStringUnixNullableArrayRequest(args [0]string // // POST /test_response_string_unix_nullable_array_array func (s *Server) handleTestResponseStringUnixNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111711,7 +142053,16 @@ func (s *Server) handleTestResponseStringUnixNullableArrayArrayRequest(args [0]s startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111723,8 +142074,27 @@ func (s *Server) handleTestResponseStringUnixNullableArrayArrayRequest(args [0]s var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111800,6 +142170,8 @@ func (s *Server) handleTestResponseStringUnixNullableArrayArrayRequest(args [0]s // // POST /test_response_string_unix-seconds func (s *Server) handleTestResponseStringUnixSecondsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-seconds"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111821,7 +142193,16 @@ func (s *Server) handleTestResponseStringUnixSecondsRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111833,8 +142214,27 @@ func (s *Server) handleTestResponseStringUnixSecondsRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -111910,6 +142310,8 @@ func (s *Server) handleTestResponseStringUnixSecondsRequest(args [0]string, args // // POST /test_response_string_unix-seconds_array func (s *Server) handleTestResponseStringUnixSecondsArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-seconds_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -111931,7 +142333,16 @@ func (s *Server) handleTestResponseStringUnixSecondsArrayRequest(args [0]string, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -111943,8 +142354,27 @@ func (s *Server) handleTestResponseStringUnixSecondsArrayRequest(args [0]string, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -112020,6 +142450,8 @@ func (s *Server) handleTestResponseStringUnixSecondsArrayRequest(args [0]string, // // POST /test_response_string_unix-seconds_array_array func (s *Server) handleTestResponseStringUnixSecondsArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-seconds_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -112041,7 +142473,16 @@ func (s *Server) handleTestResponseStringUnixSecondsArrayArrayRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -112053,8 +142494,27 @@ func (s *Server) handleTestResponseStringUnixSecondsArrayArrayRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -112130,6 +142590,8 @@ func (s *Server) handleTestResponseStringUnixSecondsArrayArrayRequest(args [0]st // // POST /test_response_string_unix-seconds_nullable func (s *Server) handleTestResponseStringUnixSecondsNullableRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-seconds_nullable"), semconv.HTTPRequestMethodKey.String("POST"), @@ -112151,7 +142613,16 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableRequest(args [0]stri startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -112163,8 +142634,27 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableRequest(args [0]stri var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -112240,6 +142730,8 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableRequest(args [0]stri // // POST /test_response_string_unix-seconds_nullable_array func (s *Server) handleTestResponseStringUnixSecondsNullableArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-seconds_nullable_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -112261,7 +142753,16 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableArrayRequest(args [0 startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -112273,8 +142774,27 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableArrayRequest(args [0 var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -112350,6 +142870,8 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableArrayRequest(args [0 // // POST /test_response_string_unix-seconds_nullable_array_array func (s *Server) handleTestResponseStringUnixSecondsNullableArrayArrayRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("test_response_string_unix-seconds_nullable_array_array"), semconv.HTTPRequestMethodKey.String("POST"), @@ -112371,7 +142893,16 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableArrayArrayRequest(ar startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -112383,8 +142914,27 @@ func (s *Server) handleTestResponseStringUnixSecondsNullableArrayArrayRequest(ar var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/examples/ex_tinkoff/oas_handlers_gen.go b/examples/ex_tinkoff/oas_handlers_gen.go index b67443ed9..7ab6a8f77 100644 --- a/examples/ex_tinkoff/oas_handlers_gen.go +++ b/examples/ex_tinkoff/oas_handlers_gen.go @@ -19,12 +19,24 @@ import ( "github.com/ogen-go/ogen/ogenerrors" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleMarketBondsGetRequest handles GET /market/bonds operation. // // Получение списка облигаций. // // GET /market/bonds func (s *Server) handleMarketBondsGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/bonds"), @@ -45,7 +57,16 @@ func (s *Server) handleMarketBondsGetRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleMarketBondsGetRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -165,6 +205,8 @@ func (s *Server) handleMarketBondsGetRequest(args [0]string, argsEscaped bool, w // // GET /market/candles func (s *Server) handleMarketCandlesGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/candles"), @@ -185,7 +227,16 @@ func (s *Server) handleMarketCandlesGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -197,8 +248,27 @@ func (s *Server) handleMarketCandlesGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -332,6 +402,8 @@ func (s *Server) handleMarketCandlesGetRequest(args [0]string, argsEscaped bool, // // GET /market/currencies func (s *Server) handleMarketCurrenciesGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/currencies"), @@ -352,7 +424,16 @@ func (s *Server) handleMarketCurrenciesGetRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -364,8 +445,27 @@ func (s *Server) handleMarketCurrenciesGetRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -472,6 +572,8 @@ func (s *Server) handleMarketCurrenciesGetRequest(args [0]string, argsEscaped bo // // GET /market/etfs func (s *Server) handleMarketEtfsGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/etfs"), @@ -492,7 +594,16 @@ func (s *Server) handleMarketEtfsGetRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -504,8 +615,27 @@ func (s *Server) handleMarketEtfsGetRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -612,6 +742,8 @@ func (s *Server) handleMarketEtfsGetRequest(args [0]string, argsEscaped bool, w // // GET /market/orderbook func (s *Server) handleMarketOrderbookGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/orderbook"), @@ -632,7 +764,16 @@ func (s *Server) handleMarketOrderbookGetRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -644,8 +785,27 @@ func (s *Server) handleMarketOrderbookGetRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -771,6 +931,8 @@ func (s *Server) handleMarketOrderbookGetRequest(args [0]string, argsEscaped boo // // GET /market/search/by-figi func (s *Server) handleMarketSearchByFigiGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/search/by-figi"), @@ -791,7 +953,16 @@ func (s *Server) handleMarketSearchByFigiGetRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -803,8 +974,27 @@ func (s *Server) handleMarketSearchByFigiGetRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -926,6 +1116,8 @@ func (s *Server) handleMarketSearchByFigiGetRequest(args [0]string, argsEscaped // // GET /market/search/by-ticker func (s *Server) handleMarketSearchByTickerGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/search/by-ticker"), @@ -946,7 +1138,16 @@ func (s *Server) handleMarketSearchByTickerGetRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -958,8 +1159,27 @@ func (s *Server) handleMarketSearchByTickerGetRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1081,6 +1301,8 @@ func (s *Server) handleMarketSearchByTickerGetRequest(args [0]string, argsEscape // // GET /market/stocks func (s *Server) handleMarketStocksGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/market/stocks"), @@ -1101,7 +1323,16 @@ func (s *Server) handleMarketStocksGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1113,8 +1344,27 @@ func (s *Server) handleMarketStocksGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1221,6 +1471,8 @@ func (s *Server) handleMarketStocksGetRequest(args [0]string, argsEscaped bool, // // GET /operations func (s *Server) handleOperationsGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/operations"), @@ -1241,7 +1493,16 @@ func (s *Server) handleOperationsGetRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1253,8 +1514,27 @@ func (s *Server) handleOperationsGetRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1388,6 +1668,8 @@ func (s *Server) handleOperationsGetRequest(args [0]string, argsEscaped bool, w // // POST /orders/cancel func (s *Server) handleOrdersCancelPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/orders/cancel"), @@ -1408,7 +1690,16 @@ func (s *Server) handleOrdersCancelPostRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1420,8 +1711,27 @@ func (s *Server) handleOrdersCancelPostRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1547,6 +1857,8 @@ func (s *Server) handleOrdersCancelPostRequest(args [0]string, argsEscaped bool, // // GET /orders func (s *Server) handleOrdersGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/orders"), @@ -1567,7 +1879,16 @@ func (s *Server) handleOrdersGetRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1579,8 +1900,27 @@ func (s *Server) handleOrdersGetRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1702,6 +2042,8 @@ func (s *Server) handleOrdersGetRequest(args [0]string, argsEscaped bool, w http // // POST /orders/limit-order func (s *Server) handleOrdersLimitOrderPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/orders/limit-order"), @@ -1722,7 +2064,16 @@ func (s *Server) handleOrdersLimitOrderPostRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1734,8 +2085,27 @@ func (s *Server) handleOrdersLimitOrderPostRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1876,6 +2246,8 @@ func (s *Server) handleOrdersLimitOrderPostRequest(args [0]string, argsEscaped b // // POST /orders/market-order func (s *Server) handleOrdersMarketOrderPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/orders/market-order"), @@ -1896,7 +2268,16 @@ func (s *Server) handleOrdersMarketOrderPostRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1908,8 +2289,27 @@ func (s *Server) handleOrdersMarketOrderPostRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2050,6 +2450,8 @@ func (s *Server) handleOrdersMarketOrderPostRequest(args [0]string, argsEscaped // // GET /portfolio/currencies func (s *Server) handlePortfolioCurrenciesGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/portfolio/currencies"), @@ -2070,7 +2472,16 @@ func (s *Server) handlePortfolioCurrenciesGetRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2082,8 +2493,27 @@ func (s *Server) handlePortfolioCurrenciesGetRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2205,6 +2635,8 @@ func (s *Server) handlePortfolioCurrenciesGetRequest(args [0]string, argsEscaped // // GET /portfolio func (s *Server) handlePortfolioGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/portfolio"), @@ -2225,7 +2657,16 @@ func (s *Server) handlePortfolioGetRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2237,8 +2678,27 @@ func (s *Server) handlePortfolioGetRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2360,6 +2820,8 @@ func (s *Server) handlePortfolioGetRequest(args [0]string, argsEscaped bool, w h // // POST /sandbox/clear func (s *Server) handleSandboxClearPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/sandbox/clear"), @@ -2380,7 +2842,16 @@ func (s *Server) handleSandboxClearPostRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2392,8 +2863,27 @@ func (s *Server) handleSandboxClearPostRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2515,6 +3005,8 @@ func (s *Server) handleSandboxClearPostRequest(args [0]string, argsEscaped bool, // // POST /sandbox/currencies/balance func (s *Server) handleSandboxCurrenciesBalancePostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/sandbox/currencies/balance"), @@ -2535,7 +3027,16 @@ func (s *Server) handleSandboxCurrenciesBalancePostRequest(args [0]string, argsE startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2547,8 +3048,27 @@ func (s *Server) handleSandboxCurrenciesBalancePostRequest(args [0]string, argsE var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2685,6 +3205,8 @@ func (s *Server) handleSandboxCurrenciesBalancePostRequest(args [0]string, argsE // // POST /sandbox/positions/balance func (s *Server) handleSandboxPositionsBalancePostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/sandbox/positions/balance"), @@ -2705,7 +3227,16 @@ func (s *Server) handleSandboxPositionsBalancePostRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2717,8 +3248,27 @@ func (s *Server) handleSandboxPositionsBalancePostRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2855,6 +3405,8 @@ func (s *Server) handleSandboxPositionsBalancePostRequest(args [0]string, argsEs // // POST /sandbox/register func (s *Server) handleSandboxRegisterPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/sandbox/register"), @@ -2875,7 +3427,16 @@ func (s *Server) handleSandboxRegisterPostRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2887,8 +3448,27 @@ func (s *Server) handleSandboxRegisterPostRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3010,6 +3590,8 @@ func (s *Server) handleSandboxRegisterPostRequest(args [0]string, argsEscaped bo // // POST /sandbox/remove func (s *Server) handleSandboxRemovePostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/sandbox/remove"), @@ -3030,7 +3612,16 @@ func (s *Server) handleSandboxRemovePostRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3042,8 +3633,27 @@ func (s *Server) handleSandboxRemovePostRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -3165,6 +3775,8 @@ func (s *Server) handleSandboxRemovePostRequest(args [0]string, argsEscaped bool // // GET /user/accounts func (s *Server) handleUserAccountsGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/user/accounts"), @@ -3185,7 +3797,16 @@ func (s *Server) handleUserAccountsGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3197,8 +3818,27 @@ func (s *Server) handleUserAccountsGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/gen/_template/handlers.tmpl b/gen/_template/handlers.tmpl index 8bc7797a1..43af04911 100644 --- a/gen/_template/handlers.tmpl +++ b/gen/_template/handlers.tmpl @@ -2,6 +2,16 @@ {{- /*gotype: github.com/ogen-go/ogen/gen.TemplateConfig*/ -}} {{ template "header" $ }} +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + {{- if not $.OpenTelemetryEnabled }} {{/* Define static no-op recordError, it would be optimized to nothing. */}} func recordError(string, error) {} @@ -28,7 +38,9 @@ func recordError(string, error) {} // {{- template "godoc_op" $op }} func (s *{{ if $op.WebhookInfo }}Webhook{{ end }}Server) handle{{ $op.Name }}Request(args [{{ $op.PathParamsCount }}]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { - {{- if $.Config.OpenTelemetryEnabled }} + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter + {{- if $.Config.OpenTelemetryEnabled }} {{- $hasOTELAttrs := false }} {{- $ogenAttrs := $op.OTELAttributes }} {{- if or $ogenAttrs (not $op.WebhookInfo) }} @@ -63,7 +75,16 @@ func (s *{{ if $op.WebhookInfo }}Webhook{{ end }}Server) handle{{ $op.Name }}Req startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -79,8 +100,27 @@ func (s *{{ if $op.WebhookInfo }}Webhook{{ end }}Server) handle{{ $op.Name }}Req {{- if $.Config.OpenTelemetryEnabled }} recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status +if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } {{- end }} err error diff --git a/internal/integration/metrics_test.go b/internal/integration/metrics_test.go index 0db025a1f..20134d423 100644 --- a/internal/integration/metrics_test.go +++ b/internal/integration/metrics_test.go @@ -115,6 +115,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("oas.operation", "petNameByID"), attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/name/{id}"), + attribute.Int("http.response.status_code", 200), ), }, }, @@ -133,6 +134,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("oas.operation", "petNameByID"), attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/name/{id}"), + attribute.Int("http.response.status_code", 200), ), }, }, @@ -162,6 +164,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("oas.operation", "petGetByName"), attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/{name}"), + attribute.Int("http.response.status_code", 500), ), }, }, @@ -180,6 +183,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("oas.operation", "petGetByName"), attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/{name}"), + attribute.Int("http.response.status_code", 500), ), }, }, @@ -197,6 +201,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("oas.operation", "petGetByName"), attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/{name}"), + attribute.Int("http.response.status_code", 500), ), }, }, @@ -229,6 +234,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/name/{id}"), attribute.Int("pet_id", 1), + attribute.Int("http.response.status_code", 200), ), }, }, @@ -248,6 +254,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("http.request.method", "GET"), attribute.String("http.route", "/pet/name/{id}"), attribute.Int("pet_id", 1), + attribute.Int("http.response.status_code", 200), ), }, }, @@ -281,6 +288,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("http.route", "/pet/{name}"), attribute.String("pet_name", "Fluffy"), attribute.String("error.type", "timeout"), + attribute.Int("http.response.status_code", 500), ), }, }, @@ -301,6 +309,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("http.route", "/pet/{name}"), attribute.String("pet_name", "Fluffy"), attribute.String("error.type", "timeout"), + attribute.Int("http.response.status_code", 500), ), }, }, @@ -320,6 +329,7 @@ func TestServerMetrics(t *testing.T) { attribute.String("http.route", "/pet/{name}"), attribute.String("pet_name", "Fluffy"), attribute.String("error.type", "timeout"), + attribute.Int("http.response.status_code", 500), ), }, }, diff --git a/internal/integration/referenced_path_item/oas_handlers_gen.go b/internal/integration/referenced_path_item/oas_handlers_gen.go index 849fd7f6a..377f2e927 100644 --- a/internal/integration/referenced_path_item/oas_handlers_gen.go +++ b/internal/integration/referenced_path_item/oas_handlers_gen.go @@ -18,10 +18,22 @@ import ( "github.com/ogen-go/ogen/middleware" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleFooGetRequest handles GET /foo operation. // // GET /foo func (s *Server) handleFooGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/foo"), @@ -42,7 +54,16 @@ func (s *Server) handleFooGetRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54,8 +75,27 @@ func (s *Server) handleFooGetRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/sample_api/oas_handlers_gen.go b/internal/integration/sample_api/oas_handlers_gen.go index f0e81d50d..0222e19cf 100644 --- a/internal/integration/sample_api/oas_handlers_gen.go +++ b/internal/integration/sample_api/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleDataGetFormatRequest handles dataGetFormat operation. // // Retrieve data. // // GET /name/{id}/{foo}1234{bar}-{baz}!{kek} func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataGetFormat"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47,7 +59,16 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -152,6 +192,8 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w // // POST /defaultTest func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("defaultTest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -173,7 +215,16 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -185,8 +236,27 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -279,6 +349,8 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht // // GET /error func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("errorGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -300,7 +372,16 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -312,8 +393,27 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -372,6 +472,8 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. // // GET /foobar func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("foobarGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -393,7 +495,16 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -405,8 +516,27 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -488,6 +618,8 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http // // POST /foobar func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("foobarPost"), semconv.HTTPRequestMethodKey.String("POST"), @@ -509,7 +641,16 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -521,8 +662,27 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -598,6 +758,8 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt // // PUT /foobar func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("PUT"), semconv.HTTPRouteKey.String("/foobar"), @@ -618,7 +780,16 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -630,8 +801,27 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -688,6 +878,8 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http // // GET /noAdditionalPropertiesTest func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("noAdditionalPropertiesTest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -709,7 +901,16 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -721,8 +922,27 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -779,6 +999,8 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc // // GET /nullableDefaultResponse func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("nullableDefaultResponse"), semconv.HTTPRequestMethodKey.String("GET"), @@ -800,7 +1022,16 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -812,8 +1043,27 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -870,6 +1120,8 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape // // POST /oneofBug func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oneofBug"), semconv.HTTPRequestMethodKey.String("POST"), @@ -891,7 +1143,16 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -903,8 +1164,27 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -980,6 +1260,8 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. // // GET /patternRecursiveMap func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/patternRecursiveMap"), @@ -1000,7 +1282,16 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1012,8 +1303,27 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1072,6 +1382,8 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped // // POST /pet func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petCreate"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1093,7 +1405,16 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1105,8 +1426,27 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1184,6 +1524,8 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http // // GET /pet/friendNames/{id} func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petFriendsNamesByID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1205,7 +1547,16 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1217,8 +1568,27 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1296,6 +1666,8 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo // // GET /pet func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1317,7 +1689,16 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1329,8 +1710,27 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1420,6 +1820,8 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re // // GET /pet/avatar func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGetAvatarByID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1441,7 +1843,16 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1453,8 +1864,27 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1532,6 +1962,8 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, // // GET /pet/{name}/avatar func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGetAvatarByName"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1553,7 +1985,16 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1565,8 +2006,27 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1644,6 +2104,8 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo // // GET /pet/{name} func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGetByName"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1665,7 +2127,16 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1677,8 +2148,27 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1756,6 +2246,8 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h // // GET /pet/name/{id} func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petNameByID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1777,7 +2269,16 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1789,8 +2290,27 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1866,6 +2386,8 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht // // POST /pet/updateNameAlias func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/pet/updateNameAlias"), @@ -1886,7 +2408,16 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1898,8 +2429,27 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1975,6 +2525,8 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped // // POST /pet/updateName func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/pet/updateName"), @@ -1995,7 +2547,16 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2007,8 +2568,27 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2086,6 +2666,8 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool // // POST /pet/avatar func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petUploadAvatarByID"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2107,7 +2689,16 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2119,8 +2710,27 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2211,6 +2821,8 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo // // GET /recursiveArray func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/recursiveArray"), @@ -2231,7 +2843,16 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2243,8 +2864,27 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2301,6 +2941,8 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool // // GET /recursiveMap func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/recursiveMap"), @@ -2321,7 +2963,16 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2333,8 +2984,27 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2391,6 +3061,8 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, // // GET /securityTest func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("securityTest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2412,7 +3084,16 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2424,8 +3105,27 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2530,6 +3230,8 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h // // GET /stringIntMap func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/stringIntMap"), @@ -2550,7 +3252,16 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2562,8 +3273,27 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2620,6 +3350,8 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, // // POST /testFloatValidation func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testFloatValidation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2641,7 +3373,16 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2653,8 +3394,27 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2730,6 +3490,8 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo // // GET /testInlineOneof func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testInlineOneof"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2751,7 +3513,16 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2763,8 +3534,27 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2821,6 +3611,8 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, // // GET /testIssue1310 func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testIssue1310"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2842,7 +3634,16 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2854,8 +3655,27 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2912,6 +3732,8 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w // // GET /testNullableOneofs func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testNullableOneofs"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2933,7 +3755,16 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2945,8 +3776,27 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -3003,6 +3853,8 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo // // GET /testTuple func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testTuple"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3024,7 +3876,16 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3036,8 +3897,27 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -3094,6 +3974,8 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http // // GET /testTupleNamed func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testTupleNamed"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3115,7 +3997,16 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3127,8 +4018,27 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -3185,6 +4095,8 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w // // GET /testUniqueItems func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testUniqueItems"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3206,7 +4118,16 @@ func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3218,8 +4139,27 @@ func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/sample_api_nc/oas_handlers_gen.go b/internal/integration/sample_api_nc/oas_handlers_gen.go index f0e81d50d..0222e19cf 100644 --- a/internal/integration/sample_api_nc/oas_handlers_gen.go +++ b/internal/integration/sample_api_nc/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleDataGetFormatRequest handles dataGetFormat operation. // // Retrieve data. // // GET /name/{id}/{foo}1234{bar}-{baz}!{kek} func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataGetFormat"), semconv.HTTPRequestMethodKey.String("GET"), @@ -47,7 +59,16 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -152,6 +192,8 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w // // POST /defaultTest func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("defaultTest"), semconv.HTTPRequestMethodKey.String("POST"), @@ -173,7 +215,16 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -185,8 +236,27 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -279,6 +349,8 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht // // GET /error func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("errorGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -300,7 +372,16 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -312,8 +393,27 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -372,6 +472,8 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. // // GET /foobar func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("foobarGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -393,7 +495,16 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -405,8 +516,27 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -488,6 +618,8 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http // // POST /foobar func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("foobarPost"), semconv.HTTPRequestMethodKey.String("POST"), @@ -509,7 +641,16 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -521,8 +662,27 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -598,6 +758,8 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt // // PUT /foobar func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("PUT"), semconv.HTTPRouteKey.String("/foobar"), @@ -618,7 +780,16 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -630,8 +801,27 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -688,6 +878,8 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http // // GET /noAdditionalPropertiesTest func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("noAdditionalPropertiesTest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -709,7 +901,16 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -721,8 +922,27 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -779,6 +999,8 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc // // GET /nullableDefaultResponse func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("nullableDefaultResponse"), semconv.HTTPRequestMethodKey.String("GET"), @@ -800,7 +1022,16 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -812,8 +1043,27 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -870,6 +1120,8 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape // // POST /oneofBug func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oneofBug"), semconv.HTTPRequestMethodKey.String("POST"), @@ -891,7 +1143,16 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -903,8 +1164,27 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -980,6 +1260,8 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. // // GET /patternRecursiveMap func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/patternRecursiveMap"), @@ -1000,7 +1282,16 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1012,8 +1303,27 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1072,6 +1382,8 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped // // POST /pet func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petCreate"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1093,7 +1405,16 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1105,8 +1426,27 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1184,6 +1524,8 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http // // GET /pet/friendNames/{id} func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petFriendsNamesByID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1205,7 +1547,16 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1217,8 +1568,27 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1296,6 +1666,8 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo // // GET /pet func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1317,7 +1689,16 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1329,8 +1710,27 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1420,6 +1820,8 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re // // GET /pet/avatar func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGetAvatarByID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1441,7 +1843,16 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1453,8 +1864,27 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1532,6 +1962,8 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, // // GET /pet/{name}/avatar func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGetAvatarByName"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1553,7 +1985,16 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1565,8 +2006,27 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1644,6 +2104,8 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo // // GET /pet/{name} func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petGetByName"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1665,7 +2127,16 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1677,8 +2148,27 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1756,6 +2246,8 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h // // GET /pet/name/{id} func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petNameByID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1777,7 +2269,16 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1789,8 +2290,27 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1866,6 +2386,8 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht // // POST /pet/updateNameAlias func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/pet/updateNameAlias"), @@ -1886,7 +2408,16 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1898,8 +2429,27 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1975,6 +2525,8 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped // // POST /pet/updateName func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("POST"), semconv.HTTPRouteKey.String("/pet/updateName"), @@ -1995,7 +2547,16 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2007,8 +2568,27 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2086,6 +2666,8 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool // // POST /pet/avatar func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("petUploadAvatarByID"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2107,7 +2689,16 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2119,8 +2710,27 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2211,6 +2821,8 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo // // GET /recursiveArray func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/recursiveArray"), @@ -2231,7 +2843,16 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2243,8 +2864,27 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2301,6 +2941,8 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool // // GET /recursiveMap func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/recursiveMap"), @@ -2321,7 +2963,16 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2333,8 +2984,27 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2391,6 +3061,8 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, // // GET /securityTest func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("securityTest"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2412,7 +3084,16 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2424,8 +3105,27 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2530,6 +3230,8 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h // // GET /stringIntMap func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/stringIntMap"), @@ -2550,7 +3252,16 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2562,8 +3273,27 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2620,6 +3350,8 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, // // POST /testFloatValidation func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testFloatValidation"), semconv.HTTPRequestMethodKey.String("POST"), @@ -2641,7 +3373,16 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2653,8 +3394,27 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -2730,6 +3490,8 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo // // GET /testInlineOneof func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testInlineOneof"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2751,7 +3513,16 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2763,8 +3534,27 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2821,6 +3611,8 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, // // GET /testIssue1310 func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testIssue1310"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2842,7 +3634,16 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2854,8 +3655,27 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -2912,6 +3732,8 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w // // GET /testNullableOneofs func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testNullableOneofs"), semconv.HTTPRequestMethodKey.String("GET"), @@ -2933,7 +3755,16 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -2945,8 +3776,27 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -3003,6 +3853,8 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo // // GET /testTuple func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testTuple"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3024,7 +3876,16 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3036,8 +3897,27 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -3094,6 +3974,8 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http // // GET /testTupleNamed func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testTupleNamed"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3115,7 +3997,16 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3127,8 +4018,27 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -3185,6 +4095,8 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w // // GET /testUniqueItems func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testUniqueItems"), semconv.HTTPRequestMethodKey.String("GET"), @@ -3206,7 +4118,16 @@ func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -3218,8 +4139,27 @@ func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/sample_api_no_otel/oas_handlers_gen.go b/internal/integration/sample_api_no_otel/oas_handlers_gen.go index 1354bd0ad..ec3aa1f64 100644 --- a/internal/integration/sample_api_no_otel/oas_handlers_gen.go +++ b/internal/integration/sample_api_no_otel/oas_handlers_gen.go @@ -13,6 +13,16 @@ import ( "github.com/ogen-go/ogen/ogenerrors" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + func recordError(string, error) {} // handleDataGetFormatRequest handles dataGetFormat operation. @@ -21,6 +31,8 @@ func recordError(string, error) {} // // GET /name/{id}/{foo}1234{bar}-{baz}!{kek} func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -114,6 +126,8 @@ func (s *Server) handleDataGetFormatRequest(args [5]string, argsEscaped bool, w // // POST /defaultTest func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -208,6 +222,8 @@ func (s *Server) handleDefaultTestRequest(args [0]string, argsEscaped bool, w ht // // GET /error func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -268,6 +284,8 @@ func (s *Server) handleErrorGetRequest(args [0]string, argsEscaped bool, w http. // // GET /foobar func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -351,6 +369,8 @@ func (s *Server) handleFoobarGetRequest(args [0]string, argsEscaped bool, w http // // POST /foobar func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -428,6 +448,8 @@ func (s *Server) handleFoobarPostRequest(args [0]string, argsEscaped bool, w htt // // PUT /foobar func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -486,6 +508,8 @@ func (s *Server) handleFoobarPutRequest(args [0]string, argsEscaped bool, w http // // GET /noAdditionalPropertiesTest func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -544,6 +568,8 @@ func (s *Server) handleNoAdditionalPropertiesTestRequest(args [0]string, argsEsc // // GET /nullableDefaultResponse func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -602,6 +628,8 @@ func (s *Server) handleNullableDefaultResponseRequest(args [0]string, argsEscape // // POST /oneofBug func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -679,6 +707,8 @@ func (s *Server) handleOneofBugRequest(args [0]string, argsEscaped bool, w http. // // GET /patternRecursiveMap func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -739,6 +769,8 @@ func (s *Server) handlePatternRecursiveMapGetRequest(args [0]string, argsEscaped // // POST /pet func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -818,6 +850,8 @@ func (s *Server) handlePetCreateRequest(args [0]string, argsEscaped bool, w http // // GET /pet/friendNames/{id} func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -897,6 +931,8 @@ func (s *Server) handlePetFriendsNamesByIDRequest(args [1]string, argsEscaped bo // // GET /pet func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -988,6 +1024,8 @@ func (s *Server) handlePetGetRequest(args [0]string, argsEscaped bool, w http.Re // // GET /pet/avatar func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1067,6 +1105,8 @@ func (s *Server) handlePetGetAvatarByIDRequest(args [0]string, argsEscaped bool, // // GET /pet/{name}/avatar func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1146,6 +1186,8 @@ func (s *Server) handlePetGetAvatarByNameRequest(args [1]string, argsEscaped boo // // GET /pet/{name} func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1225,6 +1267,8 @@ func (s *Server) handlePetGetByNameRequest(args [1]string, argsEscaped bool, w h // // GET /pet/name/{id} func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1302,6 +1346,8 @@ func (s *Server) handlePetNameByIDRequest(args [1]string, argsEscaped bool, w ht // // POST /pet/updateNameAlias func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1379,6 +1425,8 @@ func (s *Server) handlePetUpdateNameAliasPostRequest(args [0]string, argsEscaped // // POST /pet/updateName func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1458,6 +1506,8 @@ func (s *Server) handlePetUpdateNamePostRequest(args [0]string, argsEscaped bool // // POST /pet/avatar func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1550,6 +1600,8 @@ func (s *Server) handlePetUploadAvatarByIDRequest(args [0]string, argsEscaped bo // // GET /recursiveArray func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1608,6 +1660,8 @@ func (s *Server) handleRecursiveArrayGetRequest(args [0]string, argsEscaped bool // // GET /recursiveMap func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1666,6 +1720,8 @@ func (s *Server) handleRecursiveMapGetRequest(args [0]string, argsEscaped bool, // // GET /securityTest func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1772,6 +1828,8 @@ func (s *Server) handleSecurityTestRequest(args [0]string, argsEscaped bool, w h // // GET /stringIntMap func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1830,6 +1888,8 @@ func (s *Server) handleStringIntMapGetRequest(args [0]string, argsEscaped bool, // // POST /testFloatValidation func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1907,6 +1967,8 @@ func (s *Server) handleTestFloatValidationRequest(args [0]string, argsEscaped bo // // GET /testInlineOneof func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -1965,6 +2027,8 @@ func (s *Server) handleTestInlineOneofRequest(args [0]string, argsEscaped bool, // // GET /testIssue1310 func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -2023,6 +2087,8 @@ func (s *Server) handleTestIssue1310Request(args [0]string, argsEscaped bool, w // // GET /testNullableOneofs func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -2081,6 +2147,8 @@ func (s *Server) handleTestNullableOneofsRequest(args [0]string, argsEscaped boo // // GET /testTuple func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -2139,6 +2207,8 @@ func (s *Server) handleTestTupleRequest(args [0]string, argsEscaped bool, w http // // GET /testTupleNamed func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( @@ -2197,6 +2267,8 @@ func (s *Server) handleTestTupleNamedRequest(args [0]string, argsEscaped bool, w // // GET /testUniqueItems func (s *Server) handleTestUniqueItemsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter ctx := r.Context() var ( diff --git a/internal/integration/sample_err/oas_handlers_gen.go b/internal/integration/sample_err/oas_handlers_gen.go index f969249b0..fc5c46040 100644 --- a/internal/integration/sample_err/oas_handlers_gen.go +++ b/internal/integration/sample_err/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleDataCreateRequest handles dataCreate operation. // // Creates data. // // POST /data func (s *Server) handleDataCreateRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataCreate"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleDataCreateRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleDataCreateRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -149,6 +189,8 @@ func (s *Server) handleDataCreateRequest(args [0]string, argsEscaped bool, w htt // // GET /data func (s *Server) handleDataGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("dataGet"), semconv.HTTPRequestMethodKey.String("GET"), @@ -170,7 +212,16 @@ func (s *Server) handleDataGetRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -182,8 +233,27 @@ func (s *Server) handleDataGetRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/security_reentrant/oas_handlers_gen.go b/internal/integration/security_reentrant/oas_handlers_gen.go index 343cb55e0..6931e4777 100644 --- a/internal/integration/security_reentrant/oas_handlers_gen.go +++ b/internal/integration/security_reentrant/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCustomSecurityRequest handles customSecurity operation. // // GET /customSecurity func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("customSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45,7 +57,16 @@ func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -163,6 +203,8 @@ func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w // // GET /disjointSecurity func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("disjointSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -184,7 +226,16 @@ func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -196,8 +247,27 @@ func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -354,6 +424,8 @@ func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, // // GET /intersectSecurity func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("intersectSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -375,7 +447,16 @@ func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -387,8 +468,27 @@ func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -528,6 +628,8 @@ func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool // // GET /optionalSecurity func (s *Server) handleOptionalSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("optionalSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -549,7 +651,16 @@ func (s *Server) handleOptionalSecurityRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -561,8 +672,27 @@ func (s *Server) handleOptionalSecurityRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/techempower/oas_handlers_gen.go b/internal/integration/techempower/oas_handlers_gen.go index 9e0cfa397..4fae054d2 100644 --- a/internal/integration/techempower/oas_handlers_gen.go +++ b/internal/integration/techempower/oas_handlers_gen.go @@ -20,6 +20,16 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCachingRequest handles Caching operation. // // Test #7. The Caching test exercises the preferred in-memory or separate-process caching technology @@ -31,6 +41,8 @@ import ( // // GET /cached-worlds func (s *Server) handleCachingRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("Caching"), semconv.HTTPRequestMethodKey.String("GET"), @@ -52,7 +64,16 @@ func (s *Server) handleCachingRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -64,8 +85,27 @@ func (s *Server) handleCachingRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -144,6 +184,8 @@ func (s *Server) handleCachingRequest(args [0]string, argsEscaped bool, w http.R // // GET /db func (s *Server) handleDBRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("DB"), semconv.HTTPRequestMethodKey.String("GET"), @@ -165,7 +207,16 @@ func (s *Server) handleDBRequest(args [0]string, argsEscaped bool, w http.Respon startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -177,8 +228,27 @@ func (s *Server) handleDBRequest(args [0]string, argsEscaped bool, w http.Respon var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -239,6 +309,8 @@ func (s *Server) handleDBRequest(args [0]string, argsEscaped bool, w http.Respon // // GET /json func (s *Server) handleJSONRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("json"), semconv.HTTPRequestMethodKey.String("GET"), @@ -260,7 +332,16 @@ func (s *Server) handleJSONRequest(args [0]string, argsEscaped bool, w http.Resp startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -272,8 +353,27 @@ func (s *Server) handleJSONRequest(args [0]string, argsEscaped bool, w http.Resp var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -335,6 +435,8 @@ func (s *Server) handleJSONRequest(args [0]string, argsEscaped bool, w http.Resp // // GET /queries func (s *Server) handleQueriesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("Queries"), semconv.HTTPRequestMethodKey.String("GET"), @@ -356,7 +458,16 @@ func (s *Server) handleQueriesRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -368,8 +479,27 @@ func (s *Server) handleQueriesRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -449,6 +579,8 @@ func (s *Server) handleQueriesRequest(args [0]string, argsEscaped bool, w http.R // // GET /updates func (s *Server) handleUpdatesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("Updates"), semconv.HTTPRequestMethodKey.String("GET"), @@ -470,7 +602,16 @@ func (s *Server) handleUpdatesRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -482,8 +623,27 @@ func (s *Server) handleUpdatesRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_allof/oas_handlers_gen.go b/internal/integration/test_allof/oas_handlers_gen.go index f92007fe3..bf6f24c9f 100644 --- a/internal/integration/test_allof/oas_handlers_gen.go +++ b/internal/integration/test_allof/oas_handlers_gen.go @@ -20,12 +20,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleNullableStringsRequest handles nullableStrings operation. // // Nullable strings. // // POST /nullableStrings func (s *Server) handleNullableStringsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("nullableStrings"), semconv.HTTPRequestMethodKey.String("POST"), @@ -47,7 +59,16 @@ func (s *Server) handleNullableStringsRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -59,8 +80,27 @@ func (s *Server) handleNullableStringsRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -138,6 +178,8 @@ func (s *Server) handleNullableStringsRequest(args [0]string, argsEscaped bool, // // POST /objectsWithConflictingArrayProperty func (s *Server) handleObjectsWithConflictingArrayPropertyRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("objectsWithConflictingArrayProperty"), semconv.HTTPRequestMethodKey.String("POST"), @@ -159,7 +201,16 @@ func (s *Server) handleObjectsWithConflictingArrayPropertyRequest(args [0]string startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -171,8 +222,27 @@ func (s *Server) handleObjectsWithConflictingArrayPropertyRequest(args [0]string var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -250,6 +320,8 @@ func (s *Server) handleObjectsWithConflictingArrayPropertyRequest(args [0]string // // POST /objectsWithConflictingProperties func (s *Server) handleObjectsWithConflictingPropertiesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("objectsWithConflictingProperties"), semconv.HTTPRequestMethodKey.String("POST"), @@ -271,7 +343,16 @@ func (s *Server) handleObjectsWithConflictingPropertiesRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -283,8 +364,27 @@ func (s *Server) handleObjectsWithConflictingPropertiesRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -362,6 +462,8 @@ func (s *Server) handleObjectsWithConflictingPropertiesRequest(args [0]string, a // // POST /referencedAllof func (s *Server) handleReferencedAllofRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("referencedAllof"), semconv.HTTPRequestMethodKey.String("POST"), @@ -383,7 +485,16 @@ func (s *Server) handleReferencedAllofRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -395,8 +506,27 @@ func (s *Server) handleReferencedAllofRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -474,6 +604,8 @@ func (s *Server) handleReferencedAllofRequest(args [0]string, argsEscaped bool, // // POST /referencedAllofOptional func (s *Server) handleReferencedAllofOptionalRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("referencedAllofOptional"), semconv.HTTPRequestMethodKey.String("POST"), @@ -495,7 +627,16 @@ func (s *Server) handleReferencedAllofOptionalRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -507,8 +648,27 @@ func (s *Server) handleReferencedAllofOptionalRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -586,6 +746,8 @@ func (s *Server) handleReferencedAllofOptionalRequest(args [0]string, argsEscape // // POST /simpleInteger func (s *Server) handleSimpleIntegerRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("simpleInteger"), semconv.HTTPRequestMethodKey.String("POST"), @@ -607,7 +769,16 @@ func (s *Server) handleSimpleIntegerRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -619,8 +790,27 @@ func (s *Server) handleSimpleIntegerRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -698,6 +888,8 @@ func (s *Server) handleSimpleIntegerRequest(args [0]string, argsEscaped bool, w // // POST /simpleObjects func (s *Server) handleSimpleObjectsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("simpleObjects"), semconv.HTTPRequestMethodKey.String("POST"), @@ -719,7 +911,16 @@ func (s *Server) handleSimpleObjectsRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -731,8 +932,27 @@ func (s *Server) handleSimpleObjectsRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -808,6 +1028,8 @@ func (s *Server) handleSimpleObjectsRequest(args [0]string, argsEscaped bool, w // // POST /stringsNotype func (s *Server) handleStringsNotypeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("stringsNotype"), semconv.HTTPRequestMethodKey.String("POST"), @@ -829,7 +1051,16 @@ func (s *Server) handleStringsNotypeRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -841,8 +1072,27 @@ func (s *Server) handleStringsNotypeRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_anyof/oas_handlers_gen.go b/internal/integration/test_anyof/oas_handlers_gen.go index ff87f06ec..0ed1f0961 100644 --- a/internal/integration/test_anyof/oas_handlers_gen.go +++ b/internal/integration/test_anyof/oas_handlers_gen.go @@ -19,10 +19,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleIntegerNumberRequest handles integerNumber operation. // // GET /integerNumber func (s *Server) handleIntegerNumberRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("integerNumber"), semconv.HTTPRequestMethodKey.String("GET"), @@ -44,7 +56,16 @@ func (s *Server) handleIntegerNumberRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56,8 +77,27 @@ func (s *Server) handleIntegerNumberRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -114,6 +154,8 @@ func (s *Server) handleIntegerNumberRequest(args [0]string, argsEscaped bool, w // // GET /jaegerAnyOf func (s *Server) handleJaegerAnyOfRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("jaegerAnyOf"), semconv.HTTPRequestMethodKey.String("GET"), @@ -135,7 +177,16 @@ func (s *Server) handleJaegerAnyOfRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -147,8 +198,27 @@ func (s *Server) handleJaegerAnyOfRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -205,6 +275,8 @@ func (s *Server) handleJaegerAnyOfRequest(args [0]string, argsEscaped bool, w ht // // GET /oneUUID func (s *Server) handleOneUUIDRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("oneUUID"), semconv.HTTPRequestMethodKey.String("GET"), @@ -226,7 +298,16 @@ func (s *Server) handleOneUUIDRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -238,8 +319,27 @@ func (s *Server) handleOneUUIDRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/test_enum_naming/oas_handlers_gen.go b/internal/integration/test_enum_naming/oas_handlers_gen.go index 4f6bb594b..4f76395d8 100644 --- a/internal/integration/test_enum_naming/oas_handlers_gen.go +++ b/internal/integration/test_enum_naming/oas_handlers_gen.go @@ -19,12 +19,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleProbeLivenessRequest handles probeLiveness operation. // // Liveness probe for kubernetes. // // GET /healthz func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("probeLiveness"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46,7 +58,16 @@ func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58,8 +79,27 @@ func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/test_form/oas_handlers_gen.go b/internal/integration/test_form/oas_handlers_gen.go index 090adf7e7..81ef89dba 100644 --- a/internal/integration/test_form/oas_handlers_gen.go +++ b/internal/integration/test_form/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleOnlyFormRequest handles onlyForm operation. // // POST /onlyForm func (s *Server) handleOnlyFormRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("onlyForm"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45,7 +57,16 @@ func (s *Server) handleOnlyFormRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleOnlyFormRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -134,6 +174,8 @@ func (s *Server) handleOnlyFormRequest(args [0]string, argsEscaped bool, w http. // // POST /onlyMultipartFile func (s *Server) handleOnlyMultipartFileRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("onlyMultipartFile"), semconv.HTTPRequestMethodKey.String("POST"), @@ -155,7 +197,16 @@ func (s *Server) handleOnlyMultipartFileRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -167,8 +218,27 @@ func (s *Server) handleOnlyMultipartFileRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -244,6 +314,8 @@ func (s *Server) handleOnlyMultipartFileRequest(args [0]string, argsEscaped bool // // POST /onlyMultipartForm func (s *Server) handleOnlyMultipartFormRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("onlyMultipartForm"), semconv.HTTPRequestMethodKey.String("POST"), @@ -265,7 +337,16 @@ func (s *Server) handleOnlyMultipartFormRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -277,8 +358,27 @@ func (s *Server) handleOnlyMultipartFormRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -354,6 +454,8 @@ func (s *Server) handleOnlyMultipartFormRequest(args [0]string, argsEscaped bool // // POST /testFormURLEncoded func (s *Server) handleTestFormURLEncodedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testFormURLEncoded"), semconv.HTTPRequestMethodKey.String("POST"), @@ -375,7 +477,16 @@ func (s *Server) handleTestFormURLEncodedRequest(args [0]string, argsEscaped boo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -387,8 +498,27 @@ func (s *Server) handleTestFormURLEncodedRequest(args [0]string, argsEscaped boo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -464,6 +594,8 @@ func (s *Server) handleTestFormURLEncodedRequest(args [0]string, argsEscaped boo // // POST /testMultipart func (s *Server) handleTestMultipartRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testMultipart"), semconv.HTTPRequestMethodKey.String("POST"), @@ -485,7 +617,16 @@ func (s *Server) handleTestMultipartRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -497,8 +638,27 @@ func (s *Server) handleTestMultipartRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -574,6 +734,8 @@ func (s *Server) handleTestMultipartRequest(args [0]string, argsEscaped bool, w // // POST /testMultipartUpload func (s *Server) handleTestMultipartUploadRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testMultipartUpload"), semconv.HTTPRequestMethodKey.String("POST"), @@ -595,7 +757,16 @@ func (s *Server) handleTestMultipartUploadRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -607,8 +778,27 @@ func (s *Server) handleTestMultipartUploadRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -684,6 +874,8 @@ func (s *Server) handleTestMultipartUploadRequest(args [0]string, argsEscaped bo // // POST /testReuseFormOptionalSchema func (s *Server) handleTestReuseFormOptionalSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testReuseFormOptionalSchema"), semconv.HTTPRequestMethodKey.String("POST"), @@ -705,7 +897,16 @@ func (s *Server) handleTestReuseFormOptionalSchemaRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -717,8 +918,27 @@ func (s *Server) handleTestReuseFormOptionalSchemaRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -794,6 +1014,8 @@ func (s *Server) handleTestReuseFormOptionalSchemaRequest(args [0]string, argsEs // // POST /testReuseFormSchema func (s *Server) handleTestReuseFormSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testReuseFormSchema"), semconv.HTTPRequestMethodKey.String("POST"), @@ -815,7 +1037,16 @@ func (s *Server) handleTestReuseFormSchemaRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -827,8 +1058,27 @@ func (s *Server) handleTestReuseFormSchemaRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -904,6 +1154,8 @@ func (s *Server) handleTestReuseFormSchemaRequest(args [0]string, argsEscaped bo // // POST /testShareFormSchema func (s *Server) handleTestShareFormSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("testShareFormSchema"), semconv.HTTPRequestMethodKey.String("POST"), @@ -925,7 +1177,16 @@ func (s *Server) handleTestShareFormSchemaRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -937,8 +1198,27 @@ func (s *Server) handleTestShareFormSchemaRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_http_requests/oas_handlers_gen.go b/internal/integration/test_http_requests/oas_handlers_gen.go index 19f94e398..0a8e4f59a 100644 --- a/internal/integration/test_http_requests/oas_handlers_gen.go +++ b/internal/integration/test_http_requests/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAllRequestBodiesRequest handles allRequestBodies operation. // // POST /allRequestBodies func (s *Server) handleAllRequestBodiesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("allRequestBodies"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45,7 +57,16 @@ func (s *Server) handleAllRequestBodiesRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleAllRequestBodiesRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -134,6 +174,8 @@ func (s *Server) handleAllRequestBodiesRequest(args [0]string, argsEscaped bool, // // POST /allRequestBodiesOptional func (s *Server) handleAllRequestBodiesOptionalRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("allRequestBodiesOptional"), semconv.HTTPRequestMethodKey.String("POST"), @@ -155,7 +197,16 @@ func (s *Server) handleAllRequestBodiesOptionalRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -167,8 +218,27 @@ func (s *Server) handleAllRequestBodiesOptionalRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -244,6 +314,8 @@ func (s *Server) handleAllRequestBodiesOptionalRequest(args [0]string, argsEscap // // POST /base64Request func (s *Server) handleBase64RequestRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("base64Request"), semconv.HTTPRequestMethodKey.String("POST"), @@ -265,7 +337,16 @@ func (s *Server) handleBase64RequestRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -277,8 +358,27 @@ func (s *Server) handleBase64RequestRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -354,6 +454,8 @@ func (s *Server) handleBase64RequestRequest(args [0]string, argsEscaped bool, w // // POST /maskContentType func (s *Server) handleMaskContentTypeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("maskContentType"), semconv.HTTPRequestMethodKey.String("POST"), @@ -375,7 +477,16 @@ func (s *Server) handleMaskContentTypeRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -387,8 +498,27 @@ func (s *Server) handleMaskContentTypeRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -464,6 +594,8 @@ func (s *Server) handleMaskContentTypeRequest(args [0]string, argsEscaped bool, // // POST /maskContentTypeOptional func (s *Server) handleMaskContentTypeOptionalRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("maskContentTypeOptional"), semconv.HTTPRequestMethodKey.String("POST"), @@ -485,7 +617,16 @@ func (s *Server) handleMaskContentTypeOptionalRequest(args [0]string, argsEscape startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -497,8 +638,27 @@ func (s *Server) handleMaskContentTypeOptionalRequest(args [0]string, argsEscape var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -574,6 +734,8 @@ func (s *Server) handleMaskContentTypeOptionalRequest(args [0]string, argsEscape // // POST /streamJSON func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("streamJSON"), semconv.HTTPRequestMethodKey.String("POST"), @@ -595,7 +757,16 @@ func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -607,8 +778,27 @@ func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_http_responses/oas_handlers_gen.go b/internal/integration/test_http_responses/oas_handlers_gen.go index 71bf32ef9..9ef17b045 100644 --- a/internal/integration/test_http_responses/oas_handlers_gen.go +++ b/internal/integration/test_http_responses/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleAnyContentTypeBinaryStringSchemaRequest handles anyContentTypeBinaryStringSchema operation. // // GET /anyContentTypeBinaryStringSchema func (s *Server) handleAnyContentTypeBinaryStringSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("anyContentTypeBinaryStringSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45,7 +57,16 @@ func (s *Server) handleAnyContentTypeBinaryStringSchemaRequest(args [0]string, a startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleAnyContentTypeBinaryStringSchemaRequest(args [0]string, a var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -115,6 +155,8 @@ func (s *Server) handleAnyContentTypeBinaryStringSchemaRequest(args [0]string, a // // GET /anyContentTypeBinaryStringSchemaDefault func (s *Server) handleAnyContentTypeBinaryStringSchemaDefaultRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("anyContentTypeBinaryStringSchemaDefault"), semconv.HTTPRequestMethodKey.String("GET"), @@ -136,7 +178,16 @@ func (s *Server) handleAnyContentTypeBinaryStringSchemaDefaultRequest(args [0]st startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -148,8 +199,27 @@ func (s *Server) handleAnyContentTypeBinaryStringSchemaDefaultRequest(args [0]st var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -206,6 +276,8 @@ func (s *Server) handleAnyContentTypeBinaryStringSchemaDefaultRequest(args [0]st // // GET /combined func (s *Server) handleCombinedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("combined"), semconv.HTTPRequestMethodKey.String("GET"), @@ -227,7 +299,16 @@ func (s *Server) handleCombinedRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -239,8 +320,27 @@ func (s *Server) handleCombinedRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -316,6 +416,8 @@ func (s *Server) handleCombinedRequest(args [0]string, argsEscaped bool, w http. // // GET /headers200 func (s *Server) handleHeaders200Request(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("headers200"), semconv.HTTPRequestMethodKey.String("GET"), @@ -337,7 +439,16 @@ func (s *Server) handleHeaders200Request(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -349,8 +460,27 @@ func (s *Server) handleHeaders200Request(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -407,6 +537,8 @@ func (s *Server) handleHeaders200Request(args [0]string, argsEscaped bool, w htt // // GET /headersCombined func (s *Server) handleHeadersCombinedRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("headersCombined"), semconv.HTTPRequestMethodKey.String("GET"), @@ -428,7 +560,16 @@ func (s *Server) handleHeadersCombinedRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -440,8 +581,27 @@ func (s *Server) handleHeadersCombinedRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -517,6 +677,8 @@ func (s *Server) handleHeadersCombinedRequest(args [0]string, argsEscaped bool, // // GET /headersDefault func (s *Server) handleHeadersDefaultRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("headersDefault"), semconv.HTTPRequestMethodKey.String("GET"), @@ -538,7 +700,16 @@ func (s *Server) handleHeadersDefaultRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -550,8 +721,27 @@ func (s *Server) handleHeadersDefaultRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -608,6 +798,8 @@ func (s *Server) handleHeadersDefaultRequest(args [0]string, argsEscaped bool, w // // GET /headersJSON func (s *Server) handleHeadersJSONRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("headersJSON"), semconv.HTTPRequestMethodKey.String("GET"), @@ -629,7 +821,16 @@ func (s *Server) handleHeadersJSONRequest(args [0]string, argsEscaped bool, w ht startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -641,8 +842,27 @@ func (s *Server) handleHeadersJSONRequest(args [0]string, argsEscaped bool, w ht var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -699,6 +919,8 @@ func (s *Server) handleHeadersJSONRequest(args [0]string, argsEscaped bool, w ht // // GET /headersPattern func (s *Server) handleHeadersPatternRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("headersPattern"), semconv.HTTPRequestMethodKey.String("GET"), @@ -720,7 +942,16 @@ func (s *Server) handleHeadersPatternRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -732,8 +963,27 @@ func (s *Server) handleHeadersPatternRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -793,6 +1043,8 @@ func (s *Server) handleHeadersPatternRequest(args [0]string, argsEscaped bool, w // // GET /intersectPatternCode func (s *Server) handleIntersectPatternCodeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("intersectPatternCode"), semconv.HTTPRequestMethodKey.String("GET"), @@ -814,7 +1066,16 @@ func (s *Server) handleIntersectPatternCodeRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -826,8 +1087,27 @@ func (s *Server) handleIntersectPatternCodeRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -903,6 +1183,8 @@ func (s *Server) handleIntersectPatternCodeRequest(args [0]string, argsEscaped b // // GET /multipleGenericResponses func (s *Server) handleMultipleGenericResponsesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("multipleGenericResponses"), semconv.HTTPRequestMethodKey.String("GET"), @@ -924,7 +1206,16 @@ func (s *Server) handleMultipleGenericResponsesRequest(args [0]string, argsEscap startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -936,8 +1227,27 @@ func (s *Server) handleMultipleGenericResponsesRequest(args [0]string, argsEscap var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -994,6 +1304,8 @@ func (s *Server) handleMultipleGenericResponsesRequest(args [0]string, argsEscap // // GET /octetStreamBinaryStringSchema func (s *Server) handleOctetStreamBinaryStringSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("octetStreamBinaryStringSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1015,7 +1327,16 @@ func (s *Server) handleOctetStreamBinaryStringSchemaRequest(args [0]string, args startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1027,8 +1348,27 @@ func (s *Server) handleOctetStreamBinaryStringSchemaRequest(args [0]string, args var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1085,6 +1425,8 @@ func (s *Server) handleOctetStreamBinaryStringSchemaRequest(args [0]string, args // // GET /octetStreamEmptySchema func (s *Server) handleOctetStreamEmptySchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("octetStreamEmptySchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1106,7 +1448,16 @@ func (s *Server) handleOctetStreamEmptySchemaRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1118,8 +1469,27 @@ func (s *Server) handleOctetStreamEmptySchemaRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1178,6 +1548,8 @@ func (s *Server) handleOctetStreamEmptySchemaRequest(args [0]string, argsEscaped // // GET /optionalHeaders func (s *Server) handleOptionalHeadersRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("optionalHeaders"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1199,7 +1571,16 @@ func (s *Server) handleOptionalHeadersRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1211,8 +1592,27 @@ func (s *Server) handleOptionalHeadersRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -1269,6 +1669,8 @@ func (s *Server) handleOptionalHeadersRequest(args [0]string, argsEscaped bool, // // POST /streamJSON func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("streamJSON"), semconv.HTTPRequestMethodKey.String("POST"), @@ -1290,7 +1692,16 @@ func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1302,8 +1713,27 @@ func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1379,6 +1809,8 @@ func (s *Server) handleStreamJSONRequest(args [0]string, argsEscaped bool, w htt // // GET /textPlainBinaryStringSchema func (s *Server) handleTextPlainBinaryStringSchemaRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("textPlainBinaryStringSchema"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1400,7 +1832,16 @@ func (s *Server) handleTextPlainBinaryStringSchemaRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1412,8 +1853,27 @@ func (s *Server) handleTextPlainBinaryStringSchemaRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/test_issue1161/oas_handlers_gen.go b/internal/integration/test_issue1161/oas_handlers_gen.go index 81143a9c3..e0724239e 100644 --- a/internal/integration/test_issue1161/oas_handlers_gen.go +++ b/internal/integration/test_issue1161/oas_handlers_gen.go @@ -19,10 +19,22 @@ import ( "github.com/ogen-go/ogen/ogenerrors" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleFooBarBazGetRequest handles GET /foo/bar/baz operation. // // GET /foo/bar/baz func (s *Server) handleFooBarBazGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/foo/bar/baz"), @@ -43,7 +55,16 @@ func (s *Server) handleFooBarBazGetRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -55,8 +76,27 @@ func (s *Server) handleFooBarBazGetRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -113,6 +153,8 @@ func (s *Server) handleFooBarBazGetRequest(args [0]string, argsEscaped bool, w h // // GET /foo/bar/qux func (s *Server) handleFooBarQuxGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/foo/bar/qux"), @@ -133,7 +175,16 @@ func (s *Server) handleFooBarQuxGetRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -145,8 +196,27 @@ func (s *Server) handleFooBarQuxGetRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -203,6 +273,8 @@ func (s *Server) handleFooBarQuxGetRequest(args [0]string, argsEscaped bool, w h // // GET /foo/{param}/xyz func (s *Server) handleFooParamXyzGetRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/foo/{param}/xyz"), @@ -223,7 +295,16 @@ func (s *Server) handleFooParamXyzGetRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -235,8 +316,27 @@ func (s *Server) handleFooParamXyzGetRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_naming_extensions/oas_handlers_gen.go b/internal/integration/test_naming_extensions/oas_handlers_gen.go index 7902fe698..ada01576f 100644 --- a/internal/integration/test_naming_extensions/oas_handlers_gen.go +++ b/internal/integration/test_naming_extensions/oas_handlers_gen.go @@ -18,10 +18,22 @@ import ( "github.com/ogen-go/ogen/middleware" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleHealthzGetRequest handles GET /healthz operation. // // GET /healthz func (s *Server) handleHealthzGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/healthz"), @@ -42,7 +54,16 @@ func (s *Server) handleHealthzGetRequest(args [0]string, argsEscaped bool, w htt startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -54,8 +75,27 @@ func (s *Server) handleHealthzGetRequest(args [0]string, argsEscaped bool, w htt var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/test_parameters/oas_handlers_gen.go b/internal/integration/test_parameters/oas_handlers_gen.go index bb960c0ba..4ef00961f 100644 --- a/internal/integration/test_parameters/oas_handlers_gen.go +++ b/internal/integration/test_parameters/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleComplicatedParameterNameGetRequest handles GET /complicatedParameterName operation. // // GET /complicatedParameterName func (s *Server) handleComplicatedParameterNameGetRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String("GET"), semconv.HTTPRouteKey.String("/complicatedParameterName"), @@ -44,7 +56,16 @@ func (s *Server) handleComplicatedParameterNameGetRequest(args [0]string, argsEs startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -56,8 +77,27 @@ func (s *Server) handleComplicatedParameterNameGetRequest(args [0]string, argsEs var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -149,6 +189,8 @@ func (s *Server) handleComplicatedParameterNameGetRequest(args [0]string, argsEs // // GET /contentParameters/{path} func (s *Server) handleContentParametersRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("contentParameters"), semconv.HTTPRequestMethodKey.String("GET"), @@ -170,7 +212,16 @@ func (s *Server) handleContentParametersRequest(args [1]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -182,8 +233,27 @@ func (s *Server) handleContentParametersRequest(args [1]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -273,6 +343,8 @@ func (s *Server) handleContentParametersRequest(args [1]string, argsEscaped bool // // GET /cookieParameter func (s *Server) handleCookieParameterRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("cookieParameter"), semconv.HTTPRequestMethodKey.String("GET"), @@ -294,7 +366,16 @@ func (s *Server) handleCookieParameterRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -306,8 +387,27 @@ func (s *Server) handleCookieParameterRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -385,6 +485,8 @@ func (s *Server) handleCookieParameterRequest(args [0]string, argsEscaped bool, // // GET /headerParameter func (s *Server) handleHeaderParameterRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("headerParameter"), semconv.HTTPRequestMethodKey.String("GET"), @@ -406,7 +508,16 @@ func (s *Server) handleHeaderParameterRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -418,8 +529,27 @@ func (s *Server) handleHeaderParameterRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -495,6 +625,8 @@ func (s *Server) handleHeaderParameterRequest(args [0]string, argsEscaped bool, // // GET /objectCookieParameter func (s *Server) handleObjectCookieParameterRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("objectCookieParameter"), semconv.HTTPRequestMethodKey.String("GET"), @@ -516,7 +648,16 @@ func (s *Server) handleObjectCookieParameterRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -528,8 +669,27 @@ func (s *Server) handleObjectCookieParameterRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -605,6 +765,8 @@ func (s *Server) handleObjectCookieParameterRequest(args [0]string, argsEscaped // // GET /objectQueryParameter func (s *Server) handleObjectQueryParameterRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("objectQueryParameter"), semconv.HTTPRequestMethodKey.String("GET"), @@ -626,7 +788,16 @@ func (s *Server) handleObjectQueryParameterRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -638,8 +809,27 @@ func (s *Server) handleObjectQueryParameterRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -719,6 +909,8 @@ func (s *Server) handleObjectQueryParameterRequest(args [0]string, argsEscaped b // // GET /optionalArrayParameter func (s *Server) handleOptionalArrayParameterRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("optionalArrayParameter"), semconv.HTTPRequestMethodKey.String("GET"), @@ -740,7 +932,16 @@ func (s *Server) handleOptionalArrayParameterRequest(args [0]string, argsEscaped startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -752,8 +953,27 @@ func (s *Server) handleOptionalArrayParameterRequest(args [0]string, argsEscaped var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -835,6 +1055,8 @@ func (s *Server) handleOptionalArrayParameterRequest(args [0]string, argsEscaped // // GET /pathParameter/{value} func (s *Server) handlePathParameterRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("pathParameter"), semconv.HTTPRequestMethodKey.String("GET"), @@ -856,7 +1078,16 @@ func (s *Server) handlePathParameterRequest(args [1]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -868,8 +1099,27 @@ func (s *Server) handlePathParameterRequest(args [1]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -947,6 +1197,8 @@ func (s *Server) handlePathParameterRequest(args [1]string, argsEscaped bool, w // // GET /same_name/{param} func (s *Server) handleSameNameRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("sameName"), semconv.HTTPRequestMethodKey.String("GET"), @@ -968,7 +1220,16 @@ func (s *Server) handleSameNameRequest(args [1]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -980,8 +1241,27 @@ func (s *Server) handleSameNameRequest(args [1]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -1063,6 +1343,8 @@ func (s *Server) handleSameNameRequest(args [1]string, argsEscaped bool, w http. // // GET /similarNames func (s *Server) handleSimilarNamesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("similarNames"), semconv.HTTPRequestMethodKey.String("GET"), @@ -1084,7 +1366,16 @@ func (s *Server) handleSimilarNamesRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -1096,8 +1387,27 @@ func (s *Server) handleSimilarNamesRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_security/oas_handlers_gen.go b/internal/integration/test_security/oas_handlers_gen.go index 343cb55e0..6931e4777 100644 --- a/internal/integration/test_security/oas_handlers_gen.go +++ b/internal/integration/test_security/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleCustomSecurityRequest handles customSecurity operation. // // GET /customSecurity func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("customSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45,7 +57,16 @@ func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -163,6 +203,8 @@ func (s *Server) handleCustomSecurityRequest(args [0]string, argsEscaped bool, w // // GET /disjointSecurity func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("disjointSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -184,7 +226,16 @@ func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -196,8 +247,27 @@ func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -354,6 +424,8 @@ func (s *Server) handleDisjointSecurityRequest(args [0]string, argsEscaped bool, // // GET /intersectSecurity func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("intersectSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -375,7 +447,16 @@ func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -387,8 +468,27 @@ func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -528,6 +628,8 @@ func (s *Server) handleIntersectSecurityRequest(args [0]string, argsEscaped bool // // GET /optionalSecurity func (s *Server) handleOptionalSecurityRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("optionalSecurity"), semconv.HTTPRequestMethodKey.String("GET"), @@ -549,7 +651,16 @@ func (s *Server) handleOptionalSecurityRequest(args [0]string, argsEscaped bool, startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -561,8 +672,27 @@ func (s *Server) handleOptionalSecurityRequest(args [0]string, argsEscaped bool, var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_servers/oas_handlers_gen.go b/internal/integration/test_servers/oas_handlers_gen.go index 9450a0207..cc0e88b32 100644 --- a/internal/integration/test_servers/oas_handlers_gen.go +++ b/internal/integration/test_servers/oas_handlers_gen.go @@ -19,12 +19,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleProbeLivenessRequest handles probeLiveness operation. // // Liveness probe for kubernetes. // // GET /healthz func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("probeLiveness"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46,7 +58,16 @@ func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58,8 +79,27 @@ func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/test_single_endpoint/oas_handlers_gen.go b/internal/integration/test_single_endpoint/oas_handlers_gen.go index 9450a0207..cc0e88b32 100644 --- a/internal/integration/test_single_endpoint/oas_handlers_gen.go +++ b/internal/integration/test_single_endpoint/oas_handlers_gen.go @@ -19,12 +19,24 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleProbeLivenessRequest handles probeLiveness operation. // // Liveness probe for kubernetes. // // GET /healthz func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("probeLiveness"), semconv.HTTPRequestMethodKey.String("GET"), @@ -46,7 +58,16 @@ func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -58,8 +79,27 @@ func (s *Server) handleProbeLivenessRequest(args [0]string, argsEscaped bool, w var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) diff --git a/internal/integration/test_time_extension/oas_handlers_gen.go b/internal/integration/test_time_extension/oas_handlers_gen.go index e7235ae77..b7d1e552a 100644 --- a/internal/integration/test_time_extension/oas_handlers_gen.go +++ b/internal/integration/test_time_extension/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handleDefaultRequest handles default operation. // // GET /optional func (s *Server) handleDefaultRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("default"), semconv.HTTPRequestMethodKey.String("GET"), @@ -45,7 +57,16 @@ func (s *Server) handleDefaultRequest(args [0]string, argsEscaped bool, w http.R startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handleDefaultRequest(args [0]string, argsEscaped bool, w http.R var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -142,6 +182,8 @@ func (s *Server) handleDefaultRequest(args [0]string, argsEscaped bool, w http.R // // GET /required func (s *Server) handleRequiredRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("required"), semconv.HTTPRequestMethodKey.String("GET"), @@ -163,7 +205,16 @@ func (s *Server) handleRequiredRequest(args [0]string, argsEscaped bool, w http. startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -175,8 +226,27 @@ func (s *Server) handleRequiredRequest(args [0]string, argsEscaped bool, w http. var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ diff --git a/internal/integration/test_webhooks/oas_handlers_gen.go b/internal/integration/test_webhooks/oas_handlers_gen.go index b063c76de..dd6a712ce 100644 --- a/internal/integration/test_webhooks/oas_handlers_gen.go +++ b/internal/integration/test_webhooks/oas_handlers_gen.go @@ -20,10 +20,22 @@ import ( "github.com/ogen-go/ogen/otelogen" ) +type codeRecorder struct { + http.ResponseWriter + status int +} + +func (c *codeRecorder) WriteHeader(status int) { + c.status = status + c.ResponseWriter.WriteHeader(status) +} + // handlePublishEventRequest handles publishEvent operation. // // POST /event func (s *Server) handlePublishEventRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("publishEvent"), semconv.HTTPRequestMethodKey.String("POST"), @@ -45,7 +57,16 @@ func (s *Server) handlePublishEventRequest(args [0]string, argsEscaped bool, w h startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -57,8 +78,27 @@ func (s *Server) handlePublishEventRequest(args [0]string, argsEscaped bool, w h var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{ @@ -143,6 +183,8 @@ func (s *Server) handlePublishEventRequest(args [0]string, argsEscaped bool, w h // handleStatusWebhookRequest handles statusWebhook operation. func (s *WebhookServer) handleStatusWebhookRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("statusWebhook"), otelogen.WebhookName("status"), @@ -163,7 +205,16 @@ func (s *WebhookServer) handleStatusWebhookRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -175,8 +226,27 @@ func (s *WebhookServer) handleStatusWebhookRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -231,6 +301,8 @@ func (s *WebhookServer) handleStatusWebhookRequest(args [0]string, argsEscaped b // handleUpdateDeleteRequest handles DELETE update operation. func (s *WebhookServer) handleUpdateDeleteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.WebhookName("update"), } @@ -250,7 +322,16 @@ func (s *WebhookServer) handleUpdateDeleteRequest(args [0]string, argsEscaped bo startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -262,8 +343,27 @@ func (s *WebhookServer) handleUpdateDeleteRequest(args [0]string, argsEscaped bo var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error ) @@ -318,6 +418,8 @@ func (s *WebhookServer) handleUpdateDeleteRequest(args [0]string, argsEscaped bo // handleUpdateWebhookRequest handles updateWebhook operation. func (s *WebhookServer) handleUpdateWebhookRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + statusWriter := &codeRecorder{ResponseWriter: w} + w = statusWriter otelAttrs := []attribute.KeyValue{ otelogen.OperationID("updateWebhook"), otelogen.WebhookName("update"), @@ -338,7 +440,16 @@ func (s *WebhookServer) handleUpdateWebhookRequest(args [0]string, argsEscaped b startTime := time.Now() defer func() { elapsedDuration := time.Since(startTime) - attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + code := statusWriter.status + if code != 0 { + codeAttr := semconv.HTTPResponseStatusCode(code) + attrs = append(attrs, codeAttr) + span.SetAttributes(codeAttr) + } + attrOpt := metric.WithAttributes(attrs...) // Increment request counter. s.requests.Add(ctx, 1, attrOpt) @@ -350,8 +461,27 @@ func (s *WebhookServer) handleUpdateWebhookRequest(args [0]string, argsEscaped b var ( recordError = func(stage string, err error) { span.RecordError(err) - span.SetStatus(codes.Error, stage) - s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + + // https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status + // Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, + // unless there was another error (e.g., network error receiving the response body; or 3xx codes with + // max redirects exceeded), in which case status MUST be set to Error. + setStatus := true + code := statusWriter.status + if code >= 100 && code < 400 { + setStatus = false + } + if setStatus { + span.SetStatus(codes.Error, stage) + } + + attrSet := labeler.AttributeSet() + attrs := attrSet.ToSlice() + if code != 0 { + attrs = append(attrs, semconv.HTTPResponseStatusCode(code)) + } + + s.errors.Add(ctx, 1, metric.WithAttributes(attrs...)) } err error opErrContext = ogenerrors.OperationContext{