• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pace / bricks / 11250208184

09 Oct 2024 07:25AM UTC coverage: 57.466% (-13.7%) from 71.177%
11250208184

push

github

web-flow
Merge pull request #380 from pace/sentry-tracing-poc

tracing: replace Jaeger with Sentry

140 of 206 new or added lines in 19 files covered. (67.96%)

3 existing lines in 3 files now uncovered.

5515 of 9597 relevant lines covered (57.47%)

21.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/tools/testserver/simple/open-api.go
1
// Code generated by github.com/pace/bricks DO NOT EDIT.
2
package simple
3

4
import (
5
        "context"
6
        errors1 "errors"
7
        sentry "github.com/getsentry/sentry-go"
8
        mux "github.com/gorilla/mux"
9
        errors "github.com/pace/bricks/maintenance/errors"
10
        metrics "github.com/pace/bricks/maintenance/metric/jsonapi"
11
        "net/http"
12
)
13

14
/*
15
GetTestHandler handles request/response marshaling and validation for
16

17
        Get /beta/test
18
*/
19
func GetTestHandler(service GetTestHandlerService) http.Handler {
×
20
        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
×
21
                defer errors.HandleRequest("GetTestHandler", w, r)
×
22

×
23
                // Trace the service function handler execution
×
NEW
24
                span := sentry.StartSpan(r.Context(), "http.server", sentry.WithDescription("GetTestHandler"))
×
NEW
25
                defer span.Finish()
×
NEW
26

×
NEW
27
                ctx := span.Context()
×
NEW
28
                r = r.WithContext(ctx)
×
29

×
30
                // Setup context, response writer and request type
×
31
                writer := getTestResponseWriter{
×
32
                        ResponseWriter: metrics.NewMetric("simple", "/beta/test", w, r),
×
33
                }
×
34
                request := GetTestRequest{
×
35
                        Request: r.WithContext(ctx),
×
36
                }
×
37

×
38
                // Scan and validate incoming request parameters
×
39

×
40
                // Invoke service that implements the business logic
×
41
                err := service.GetTest(ctx, &writer, &request)
×
42
                select {
×
43
                case <-ctx.Done():
×
44
                        if ctx.Err() != nil {
×
45
                                // Context cancellation should not be reported if it's the request context
×
46
                                w.WriteHeader(499)
×
47
                                if err != nil && !(errors1.Is(err, context.Canceled) || errors1.Is(err, context.DeadlineExceeded)) {
×
48
                                        // Report unclean error handling (err != context err) to sentry
×
49
                                        errors.Handle(ctx, err)
×
50
                                }
×
51
                        }
52
                default:
×
53
                        if err != nil {
×
54
                                errors.HandleError(err, "GetTestHandler", w, r)
×
55
                        }
×
56
                }
57
        })
58
}
59

60
/*
61
GetTestResponseWriter is a standard http.ResponseWriter extended with methods
62
to generate the respective responses easily
63
*/
64
type GetTestResponseWriter interface {
65
        http.ResponseWriter
66
        OK()
67
}
68
type getTestResponseWriter struct {
69
        http.ResponseWriter
70
}
71

72
// OK responds with empty response (HTTP code 200)
73
func (w *getTestResponseWriter) OK() {
×
74
        w.Header().Set("Content-Type", "application/vnd.api+json")
×
75
        w.WriteHeader(200)
×
76
}
×
77

78
/*
79
GetTestRequest is a standard http.Request extended with the
80
un-marshaled content object
81
*/
82
type GetTestRequest struct {
83
        Request *http.Request `valid:"-"`
84
}
85

86
// Service interface for GetTestHandler handler
87
type GetTestHandlerService interface {
88
        // GetTest Test
89
        GetTest(context.Context, GetTestResponseWriter, *GetTestRequest) error
90
}
91

92
// Legacy Interface.
93
// Use this if you want to fully implement a service.
94
type Service interface {
95
        GetTestHandlerService
96
}
97

98
// GetTestHandlerWithFallbackHelper helper that checks if the given service fulfills the interface. Returns fallback handler if not, otherwise returns matching handler.
99
func GetTestHandlerWithFallbackHelper(service interface{}, fallback http.Handler) http.Handler {
×
100
        if service, ok := service.(GetTestHandlerService); ok {
×
101
                return GetTestHandler(service)
×
102
        } else {
×
103
                return fallback
×
104
        }
×
105
}
106

107
/*
108
Router implements: PACE Payment API
109

110
Welcome to the PACE Payment API documentation.
111
This API is responsible for managing payment methods for users as well as authorizing payments on behalf of PACE services.
112
*/
113
func Router(service interface{}) *mux.Router {
×
114
        router := mux.NewRouter()
×
115
        // Subrouter s1 - Path: /pay
×
116
        s1 := router.PathPrefix("/pay").Subrouter()
×
117
        s1.Methods("GET").Path("/beta/test").Name("GetTest").Handler(GetTestHandlerWithFallbackHelper(service, router.NotFoundHandler))
×
118
        return router
×
119
}
×
120

121
/*
122
Router implements: PACE Payment API
123

124
Welcome to the PACE Payment API documentation.
125
This API is responsible for managing payment methods for users as well as authorizing payments on behalf of PACE services.
126
*/
127
func RouterWithFallback(service interface{}, fallback http.Handler) *mux.Router {
×
128
        router := mux.NewRouter()
×
129
        // Subrouter s1 - Path: /pay
×
130
        s1 := router.PathPrefix("/pay").Subrouter()
×
131
        s1.Methods("GET").Path("/beta/test").Name("GetTest").Handler(GetTestHandlerWithFallbackHelper(service, fallback))
×
132
        return router
×
133
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc