Skip to content

[baseserver] Initialize tracer with server #16586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/blobserve/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ require (
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.3.0 // indirect
golang.org/x/net v0.3.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
google.golang.org/grpc v1.52.3 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
33 changes: 7 additions & 26 deletions components/blobserve/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions components/common-go/baseserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package baseserver
import (
"context"
"fmt"
"io"
"net"
"net/http"
"os"
Expand All @@ -16,8 +17,10 @@ import (

common_grpc "github.com/gitpod-io/gitpod/common-go/grpc"
"github.com/gitpod-io/gitpod/common-go/pprof"
"github.com/gitpod-io/gitpod/common-go/tracing"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand All @@ -43,6 +46,7 @@ func New(name string, opts ...Option) (*Server, error) {
options: options,
}
server.builtinServices = newBuiltinServices(server)
server.tracingCloser = tracing.Init(name)

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

tracingCloser io.Closer

// listening indicates the server is serving. When closed, the server is in the process of graceful termination.
listening chan struct{}
closeOnce sync.Once
Expand Down Expand Up @@ -198,6 +204,10 @@ func (s *Server) MetricsRegistry() *prometheus.Registry {
return s.options.metricsRegistry
}

func (s *Server) Tracer() opentracing.Tracer {
return opentracing.GlobalTracer()
}

func (s *Server) close(ctx context.Context) error {
if s.listening == nil {
return fmt.Errorf("server is not running, invalid close operation")
Expand Down Expand Up @@ -235,6 +245,11 @@ func (s *Server) close(ctx context.Context) error {
}
s.Logger().Info("Debug server terminated.")

err = s.tracingCloser.Close()
if err != nil {
return fmt.Errorf("failed to close tracing: %w", err)
}

return nil
}

Expand Down
18 changes: 9 additions & 9 deletions components/common-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/containerd/cgroups v1.0.4
github.com/fsnotify/fsnotify v1.4.9
github.com/go-test/deep v1.0.5
github.com/google/go-cmp v0.5.8
github.com/google/go-cmp v0.5.9
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/hashicorp/golang-lru v0.5.1
Expand All @@ -19,15 +19,15 @@ require (
github.com/segmentio/backo-go v0.0.0-20200129164019-23eae7c10bd3 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/slok/go-http-metrics v0.10.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
github.com/uber/jaeger-client-go v2.29.1+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
golang.org/x/sys v0.3.0
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/grpc v1.49.0
google.golang.org/grpc v1.52.3
google.golang.org/protobuf v1.28.1
gopkg.in/segmentio/analytics-go.v3 v3.1.0
k8s.io/api v0.24.4
Expand All @@ -42,7 +42,7 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand All @@ -58,13 +58,13 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
go.uber.org/atomic v1.4.0 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
Expand Down
Loading