Skip to content

Commit e4e0514

Browse files
authored
[baseserver] Initialize tracer with server (#16586)
* [baseserver] Initialize tracer with server * fix * Fix * fix
1 parent a0693f3 commit e4e0514

File tree

90 files changed

+1097
-3266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1097
-3266
lines changed

components/blobserve/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ require (
113113
go.uber.org/multierr v1.9.0 // indirect
114114
go.uber.org/zap v1.24.0 // indirect
115115
golang.org/x/crypto v0.3.0 // indirect
116-
golang.org/x/net v0.3.0 // indirect
116+
golang.org/x/net v0.4.0 // indirect
117117
golang.org/x/sys v0.4.0 // indirect
118118
golang.org/x/text v0.5.0 // indirect
119119
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
120-
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
121-
google.golang.org/grpc v1.49.0 // indirect
120+
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
121+
google.golang.org/grpc v1.52.3 // indirect
122122
google.golang.org/protobuf v1.28.1 // indirect
123123
gopkg.in/inf.v0 v0.9.1 // indirect
124124
gopkg.in/yaml.v2 v2.4.0 // indirect

components/blobserve/go.sum

Lines changed: 7 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/common-go/baseserver/server.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package baseserver
77
import (
88
"context"
99
"fmt"
10+
"io"
1011
"net"
1112
"net/http"
1213
"os"
@@ -16,8 +17,10 @@ import (
1617

1718
common_grpc "github.com/gitpod-io/gitpod/common-go/grpc"
1819
"github.com/gitpod-io/gitpod/common-go/pprof"
20+
"github.com/gitpod-io/gitpod/common-go/tracing"
1921
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
2022
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
23+
"github.com/opentracing/opentracing-go"
2124
"github.com/prometheus/client_golang/prometheus"
2225
"github.com/prometheus/client_golang/prometheus/collectors"
2326
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -43,6 +46,7 @@ func New(name string, opts ...Option) (*Server, error) {
4346
options: options,
4447
}
4548
server.builtinServices = newBuiltinServices(server)
49+
server.tracingCloser = tracing.Init(name)
4650

4751
server.httpMux = http.NewServeMux()
4852
server.http = &http.Server{Handler: std.Handler("", middleware.New(middleware.Config{
@@ -98,6 +102,8 @@ type Server struct {
98102
grpc *grpc.Server
99103
grpcListener net.Listener
100104

105+
tracingCloser io.Closer
106+
101107
// listening indicates the server is serving. When closed, the server is in the process of graceful termination.
102108
listening chan struct{}
103109
closeOnce sync.Once
@@ -198,6 +204,10 @@ func (s *Server) MetricsRegistry() *prometheus.Registry {
198204
return s.options.metricsRegistry
199205
}
200206

207+
func (s *Server) Tracer() opentracing.Tracer {
208+
return opentracing.GlobalTracer()
209+
}
210+
201211
func (s *Server) close(ctx context.Context) error {
202212
if s.listening == nil {
203213
return fmt.Errorf("server is not running, invalid close operation")
@@ -235,6 +245,11 @@ func (s *Server) close(ctx context.Context) error {
235245
}
236246
s.Logger().Info("Debug server terminated.")
237247

248+
err = s.tracingCloser.Close()
249+
if err != nil {
250+
return fmt.Errorf("failed to close tracing: %w", err)
251+
}
252+
238253
return nil
239254
}
240255

components/common-go/go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/containerd/cgroups v1.0.4
1010
github.com/fsnotify/fsnotify v1.4.9
1111
github.com/go-test/deep v1.0.5
12-
github.com/google/go-cmp v0.5.8
12+
github.com/google/go-cmp v0.5.9
1313
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
1414
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
1515
github.com/hashicorp/golang-lru v0.5.1
@@ -19,15 +19,15 @@ require (
1919
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect
2020
github.com/sirupsen/logrus v1.8.1
2121
github.com/slok/go-http-metrics v0.10.0
22-
github.com/stretchr/testify v1.7.0
22+
github.com/stretchr/testify v1.8.1
2323
github.com/uber/jaeger-client-go v2.29.1+incompatible
2424
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
2525
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
2626
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
27-
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
27+
golang.org/x/sys v0.3.0
2828
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af
2929
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
30-
google.golang.org/grpc v1.49.0
30+
google.golang.org/grpc v1.52.3
3131
google.golang.org/protobuf v1.28.1
3232
gopkg.in/segmentio/analytics-go.v3 v3.1.0
3333
k8s.io/api v0.24.4
@@ -42,7 +42,7 @@ require (
4242
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
4343
github.com/davecgh/go-spew v1.1.1 // indirect
4444
github.com/docker/go-units v0.4.0 // indirect
45-
github.com/go-logr/logr v1.2.0 // indirect
45+
github.com/go-logr/logr v1.2.3 // indirect
4646
github.com/godbus/dbus/v5 v5.0.4 // indirect
4747
github.com/gogo/protobuf v1.3.2 // indirect
4848
github.com/golang/protobuf v1.5.2 // indirect
@@ -58,13 +58,13 @@ require (
5858
github.com/prometheus/common v0.37.0 // indirect
5959
github.com/prometheus/procfs v0.8.0 // indirect
6060
go.uber.org/atomic v1.4.0 // indirect
61-
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
62-
golang.org/x/text v0.3.7 // indirect
63-
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 // indirect
61+
golang.org/x/net v0.4.0 // indirect
62+
golang.org/x/text v0.5.0 // indirect
63+
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
6464
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect
6565
gopkg.in/inf.v0 v0.9.1 // indirect
6666
gopkg.in/yaml.v2 v2.4.0 // indirect
67-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
67+
gopkg.in/yaml.v3 v3.0.1 // indirect
6868
k8s.io/klog/v2 v2.60.1 // indirect
6969
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
7070
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect

0 commit comments

Comments
 (0)