• 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/simplemath/main.go
1
package main
2

3
import (
4
        "context"
5
        "fmt"
6

7
        "github.com/getsentry/sentry-go"
8
        "github.com/pace/bricks/grpc"
9
        "github.com/pace/bricks/http/security"
10
        "github.com/pace/bricks/locale"
11
        "github.com/pace/bricks/maintenance/log"
12
        "github.com/pace/bricks/tools/testserver/math"
13
)
14

15
type GrpcAuthBackend struct{}
16

17
func (*GrpcAuthBackend) AuthorizeStream(ctx context.Context) (context.Context, error) {
×
18
        return ctx, nil
×
19
}
×
20

21
func (*GrpcAuthBackend) AuthorizeUnary(ctx context.Context) (context.Context, error) {
×
22
        token, ok := security.GetTokenFromContext(ctx)
×
23
        if ok {
×
24
                log.Ctx(ctx).Debug().Msgf("Token: %v", token.GetValue())
×
25
        } else {
×
26
                return nil, fmt.Errorf("unauthenticated")
×
27
        }
×
28
        return ctx, nil
×
29
}
30

31
type SimpleMathServer struct {
32
        math.UnimplementedMathServiceServer
33
}
34

35
func (*SimpleMathServer) Add(ctx context.Context, i *math.Input) (*math.Output, error) {
×
36
        if loc, ok := locale.FromCtx(ctx); ok {
×
37
                log.Ctx(ctx).Debug().Msgf("Locale: %q", loc.Serialize())
×
38
        }
×
NEW
39
        span := sentry.SpanFromContext(ctx)
×
NEW
40
        if span != nil {
×
NEW
41
                log.Ctx(ctx).Debug().Msgf("Span: %q", span.Name)
×
42
        }
×
43

44
        var o math.Output
×
45
        o.C = i.A + i.B
×
46
        log.Ctx(ctx).Debug().Msgf("A: %d + B: %d = C: %d", i.A, i.B, o.C)
×
47
        return &o, nil
×
48
}
49

50
func (*SimpleMathServer) Substract(ctx context.Context, i *math.Input) (*math.Output, error) {
×
51
        panic("not implemented")
×
52
}
53

54
func main() {
×
55
        ms := &SimpleMathServer{}
×
56
        gs := grpc.Server(&GrpcAuthBackend{})
×
57
        math.RegisterMathServiceServer(gs, ms)
×
58

×
59
        err := grpc.ListenAndServe(gs)
×
60
        if err != nil {
×
61
                log.Fatal(err)
×
62
        }
×
63
}
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