diff --git a/go.mod b/go.mod index 110137e..082baa2 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/fatih/color v1.15.0 github.com/go-faster/errors v0.6.1 github.com/go-faster/jx v1.1.0 - github.com/ogen-go/ogen v0.73.0 + github.com/ogen-go/ogen v0.74.0 github.com/povilasv/prommod v0.0.12 github.com/prometheus/client_golang v1.16.0 go.opentelemetry.io/otel v1.18.0 diff --git a/go.sum b/go.sum index 2526ecb..d648725 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfr github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/ogen-go/ogen v0.73.0 h1:h9HFV2V/h7UTKewlJpvOjx0gHIjjn4O9mjKe3eLNWkY= -github.com/ogen-go/ogen v0.73.0/go.mod h1:CS1RfTfLLcxw968GF2pEw8r6P6YTlU+mCOTGJvl7P2c= +github.com/ogen-go/ogen v0.74.0 h1:EFzCDm9h7RupLMn4RAEC1kIjXa9KUJTLGkMyejVmB34= +github.com/ogen-go/ogen v0.74.0/go.mod h1:Jr2HmdCICrlXw+29Vcx1EAgx4dIQpXEwCpwuIDqrj6Y= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/internal/oas/oas_client_gen.go b/internal/oas/oas_client_gen.go index 6976245..4c942b7 100644 --- a/internal/oas/oas_client_gen.go +++ b/internal/oas/oas_client_gen.go @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/metric" + semconv "go.opentelemetry.io/otel/semconv/v1.19.0" "go.opentelemetry.io/otel/trace" "github.com/ogen-go/ogen/conv" @@ -82,6 +83,8 @@ func (c *Client) AddPet(ctx context.Context, request *Pet) (*Pet, error) { func (c *Client) sendAddPet(ctx context.Context, request *Pet) (res *Pet, err error) { otelAttrs := []attribute.KeyValue{ otelogen.OperationID("addPet"), + semconv.HTTPMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/pet"), } // Validate request before sending. if err := func() error { @@ -165,6 +168,8 @@ func (c *Client) DeletePet(ctx context.Context, params DeletePetParams) error { func (c *Client) sendDeletePet(ctx context.Context, params DeletePetParams) (res *DeletePetOK, err error) { otelAttrs := []attribute.KeyValue{ otelogen.OperationID("deletePet"), + semconv.HTTPMethodKey.String("DELETE"), + semconv.HTTPRouteKey.String("/pet/{petId}"), } // Run stopwatch. @@ -254,6 +259,8 @@ func (c *Client) GetPetById(ctx context.Context, params GetPetByIdParams) (GetPe func (c *Client) sendGetPetById(ctx context.Context, params GetPetByIdParams) (res GetPetByIdRes, err error) { otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getPetById"), + semconv.HTTPMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/pet/{petId}"), } // Run stopwatch. @@ -343,6 +350,8 @@ func (c *Client) UpdatePet(ctx context.Context, params UpdatePetParams) error { func (c *Client) sendUpdatePet(ctx context.Context, params UpdatePetParams) (res *UpdatePetOK, err error) { otelAttrs := []attribute.KeyValue{ otelogen.OperationID("updatePet"), + semconv.HTTPMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/pet/{petId}"), } // Run stopwatch. diff --git a/internal/oas/oas_handlers_gen.go b/internal/oas/oas_handlers_gen.go index 813b3ad..3b78dab 100644 --- a/internal/oas/oas_handlers_gen.go +++ b/internal/oas/oas_handlers_gen.go @@ -7,12 +7,14 @@ import ( "net/http" "time" + "github.com/go-faster/errors" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/metric" semconv "go.opentelemetry.io/otel/semconv/v1.19.0" "go.opentelemetry.io/otel/trace" + ht "github.com/ogen-go/ogen/http" "github.com/ogen-go/ogen/middleware" "github.com/ogen-go/ogen/ogenerrors" "github.com/ogen-go/ogen/otelogen" @@ -116,7 +118,9 @@ func (s *Server) handleAddPetRequest(args [0]string, argsEscaped bool, w http.Re if err := encodeAddPetResponse(response, w, span); err != nil { recordError("EncodeResponse", err) - s.cfg.ErrorHandler(ctx, w, r, err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } return } } @@ -219,7 +223,9 @@ func (s *Server) handleDeletePetRequest(args [1]string, argsEscaped bool, w http if err := encodeDeletePetResponse(response, w, span); err != nil { recordError("EncodeResponse", err) - s.cfg.ErrorHandler(ctx, w, r, err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } return } } @@ -322,7 +328,9 @@ func (s *Server) handleGetPetByIdRequest(args [1]string, argsEscaped bool, w htt if err := encodeGetPetByIdResponse(response, w, span); err != nil { recordError("EncodeResponse", err) - s.cfg.ErrorHandler(ctx, w, r, err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } return } } @@ -433,7 +441,9 @@ func (s *Server) handleUpdatePetRequest(args [1]string, argsEscaped bool, w http if err := encodeUpdatePetResponse(response, w, span); err != nil { recordError("EncodeResponse", err) - s.cfg.ErrorHandler(ctx, w, r, err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } return } } diff --git a/internal/oas/oas_response_encoders_gen.go b/internal/oas/oas_response_encoders_gen.go index df03f4f..ec4d344 100644 --- a/internal/oas/oas_response_encoders_gen.go +++ b/internal/oas/oas_response_encoders_gen.go @@ -21,6 +21,7 @@ func encodeAddPetResponse(response *Pet, w http.ResponseWriter, span trace.Span) if _, err := e.WriteTo(w); err != nil { return errors.Wrap(err, "write") } + return nil } @@ -43,6 +44,7 @@ func encodeGetPetByIdResponse(response GetPetByIdRes, w http.ResponseWriter, spa if _, err := e.WriteTo(w); err != nil { return errors.Wrap(err, "write") } + return nil case *GetPetByIdNotFound: diff --git a/internal/oas/oas_schemas_gen.go b/internal/oas/oas_schemas_gen.go index 5d328e5..ed9c857 100644 --- a/internal/oas/oas_schemas_gen.go +++ b/internal/oas/oas_schemas_gen.go @@ -212,6 +212,15 @@ const ( PetStatusSold PetStatus = "sold" ) +// AllValues returns all PetStatus values. +func (PetStatus) AllValues() []PetStatus { + return []PetStatus{ + PetStatusAvailable, + PetStatusPending, + PetStatusSold, + } +} + // MarshalText implements encoding.TextMarshaler. func (s PetStatus) MarshalText() ([]byte, error) { switch s {