Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 931839d

Browse files
authored
feat(tracing): configure otel tracing (#258)
* feat(tracing): configure otel tracing by moving pkg from golang-commons On-behalf-of: @SAP angel.kafazov@sap.com Signed-off-by: Angel Kafazov <akafazov@cst-bg.net> * use golang-commons On-behalf-of: @SAP angel.kafazov@sap.com Signed-off-by: Angel Kafazov <akafazov@cst-bg.net> * remove toolchain from go.mod On-behalf-of: @SAP angel.kafazov@sap.com Signed-off-by: Angel Kafazov <akafazov@cst-bg.net> --------- Signed-off-by: Angel Kafazov <akafazov@cst-bg.net>
1 parent 067c2e8 commit 931839d

File tree

3 files changed

+111
-86
lines changed

3 files changed

+111
-86
lines changed

cmd/gateway.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
openmfpcontext "github.com/openmfp/golang-commons/context"
1111
"github.com/openmfp/golang-commons/sentry"
12+
"github.com/openmfp/golang-commons/traces"
1213
"github.com/spf13/cobra"
1314
ctrl "sigs.k8s.io/controller-runtime"
1415
restCfg "sigs.k8s.io/controller-runtime/pkg/client/config"
@@ -54,6 +55,26 @@ var gatewayCmd = &cobra.Command{
5455
log.Fatal().Err(err).Msg("Error getting Kubernetes restCfg, exiting")
5556
}
5657

58+
// Initialize tracing provider
59+
var providerShutdown func(ctx context.Context) error
60+
if defaultCfg.Tracing.Enabled {
61+
providerShutdown, err = traces.InitProvider(ctx, defaultCfg.Tracing.Collector)
62+
if err != nil {
63+
log.Fatal().Err(err).Msg("unable to start gRPC-Sidecar TracerProvider")
64+
}
65+
} else {
66+
providerShutdown, err = traces.InitLocalProvider(ctx, defaultCfg.Tracing.Collector, false)
67+
if err != nil {
68+
log.Fatal().Err(err).Msg("unable to start local TracerProvider")
69+
}
70+
}
71+
72+
defer func() {
73+
if err := providerShutdown(ctx); err != nil {
74+
log.Fatal().Err(err).Msg("failed to shutdown TracerProvider")
75+
}
76+
}()
77+
5778
// Initialize Manager
5879
managerInstance, err := manager.NewManager(log, restCfg, appCfg)
5980
if err != nil {

go.mod

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
module github.com/openmfp/kubernetes-graphql-gateway
22

3-
go 1.23.2
3+
go 1.24.3
44

5-
replace sigs.k8s.io/controller-runtime => github.com/kcp-dev/controller-runtime v0.19.0-kcp.1.0.20250129100209-5eaf4c7b6056
6-
7-
// this PR introduces newer version of graphiQL that supports headers
8-
// https://github.com/graphql-go/handler/pull/93
9-
replace github.com/graphql-go/handler => github.com/vertex451/handler v0.0.0-20250124125145-ed328e3cf42a
5+
replace (
6+
github.com/google/cel-go => github.com/google/cel-go v0.22.1
7+
// this PR introduces newer version of graphiQL that supports headers
8+
// https://github.com/graphql-go/handler/pull/93
9+
github.com/graphql-go/handler => github.com/vertex451/handler v0.0.0-20250124125145-ed328e3cf42a
10+
k8s.io/api => k8s.io/api v0.32.4
11+
k8s.io/apimachinery => k8s.io/apimachinery v0.32.4
12+
k8s.io/client-go => k8s.io/client-go v0.32.4
13+
sigs.k8s.io/controller-runtime => github.com/kcp-dev/controller-runtime v0.19.0-kcp.1.0.20250129100209-5eaf4c7b6056
14+
)
1015

1116
require (
1217
github.com/fsnotify/fsnotify v1.9.0
@@ -20,7 +25,7 @@ require (
2025
github.com/kcp-dev/kcp/sdk v0.27.1
2126
github.com/kcp-dev/logicalcluster/v3 v3.0.5
2227
github.com/openmfp/account-operator v0.169.13
23-
github.com/openmfp/golang-commons v0.147.8
28+
github.com/openmfp/golang-commons v0.150.7
2429
github.com/pkg/errors v0.9.1
2530
github.com/rs/zerolog v1.34.0
2631
github.com/spf13/cobra v1.9.1
@@ -29,30 +34,30 @@ require (
2934
go.opentelemetry.io/otel v1.37.0
3035
go.opentelemetry.io/otel/trace v1.37.0
3136
gopkg.in/yaml.v3 v3.0.1
32-
k8s.io/api v0.32.4
37+
k8s.io/api v0.33.2
3338
k8s.io/apiextensions-apiserver v0.32.4
34-
k8s.io/apimachinery v0.32.4
35-
k8s.io/client-go v0.32.4
39+
k8s.io/apimachinery v0.33.2
40+
k8s.io/client-go v0.33.2
3641
k8s.io/kube-openapi v0.0.0-20250626183228-af0a60a813f8
3742
sigs.k8s.io/controller-runtime v0.21.0
3843
)
3944

4045
require (
41-
cel.dev/expr v0.23.0 // indirect
42-
github.com/99designs/gqlgen v0.17.73 // indirect
46+
cel.dev/expr v0.23.1 // indirect
47+
github.com/99designs/gqlgen v0.17.75 // indirect
4348
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
4449
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
4550
github.com/beorn7/perks v1.0.1 // indirect
4651
github.com/blang/semver/v4 v4.0.0 // indirect
47-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
52+
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
4853
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4954
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5055
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
5156
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
5257
github.com/felixge/httpsnoop v1.0.4 // indirect
5358
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
54-
github.com/getsentry/sentry-go v0.33.0 // indirect
55-
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
59+
github.com/getsentry/sentry-go v0.34.0 // indirect
60+
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
5661
github.com/go-logr/logr v1.4.3 // indirect
5762
github.com/go-logr/stdr v1.2.2 // indirect
5863
github.com/go-logr/zapr v1.3.0 // indirect
@@ -63,18 +68,17 @@ require (
6368
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
6469
github.com/gogo/protobuf v1.3.2 // indirect
6570
github.com/golang/protobuf v1.5.4 // indirect
66-
github.com/google/cel-go v0.22.1 // indirect
71+
github.com/google/cel-go v0.25.0 // indirect
6772
github.com/google/go-cmp v0.7.0 // indirect
6873
github.com/google/gofuzz v1.2.0 // indirect
6974
github.com/google/uuid v1.6.0 // indirect
70-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.0 // indirect
75+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
7176
github.com/hashicorp/errwrap v1.1.0 // indirect
7277
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
7378
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7479
github.com/josharian/intern v1.0.0 // indirect
7580
github.com/json-iterator/go v1.1.12 // indirect
7681
github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250223115924-431177b024f3 // indirect
77-
github.com/klauspost/compress v1.17.11 // indirect
7882
github.com/mailru/easyjson v0.9.0 // indirect
7983
github.com/mattn/go-colorable v0.1.14 // indirect
8084
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -84,10 +88,10 @@ require (
8488
github.com/onsi/gomega v1.35.1 // indirect
8589
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
8690
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
87-
github.com/prometheus/client_golang v1.20.5 // indirect
91+
github.com/prometheus/client_golang v1.22.0 // indirect
8892
github.com/prometheus/client_model v0.6.1 // indirect
8993
github.com/prometheus/common v0.62.0 // indirect
90-
github.com/prometheus/procfs v0.15.1 // indirect
94+
github.com/prometheus/procfs v0.16.1 // indirect
9195
github.com/sagikazarmark/locafero v0.7.0 // indirect
9296
github.com/sosodev/duration v1.3.1 // indirect
9397
github.com/sourcegraph/conc v0.3.0 // indirect
@@ -97,30 +101,30 @@ require (
97101
github.com/stoewer/go-strcase v1.3.0 // indirect
98102
github.com/stretchr/objx v0.5.2 // indirect
99103
github.com/subosito/gotenv v1.6.0 // indirect
100-
github.com/vektah/gqlparser/v2 v2.5.27 // indirect
104+
github.com/vektah/gqlparser/v2 v2.5.28 // indirect
101105
github.com/x448/float16 v0.8.4 // indirect
102106
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
103-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
104-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
105-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 // indirect
107+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
108+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 // indirect
109+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0 // indirect
110+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.37.0 // indirect
106111
go.opentelemetry.io/otel/metric v1.37.0 // indirect
107-
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
108-
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
112+
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
113+
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
109114
go.uber.org/multierr v1.11.0 // indirect
110115
go.uber.org/zap v1.27.0 // indirect
111116
go.yaml.in/yaml/v2 v2.4.2 // indirect
112-
golang.org/x/crypto v0.38.0 // indirect
113-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
114-
golang.org/x/net v0.40.0 // indirect
115-
golang.org/x/oauth2 v0.28.0 // indirect
116-
golang.org/x/sync v0.14.0 // indirect
117+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
118+
golang.org/x/net v0.41.0 // indirect
119+
golang.org/x/oauth2 v0.30.0 // indirect
120+
golang.org/x/sync v0.15.0 // indirect
117121
golang.org/x/sys v0.33.0 // indirect
118122
golang.org/x/term v0.32.0 // indirect
119-
golang.org/x/text v0.25.0 // indirect
123+
golang.org/x/text v0.26.0 // indirect
120124
golang.org/x/time v0.9.0 // indirect
121125
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
122-
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect
123-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
126+
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect
127+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
124128
google.golang.org/grpc v1.73.0 // indirect
125129
google.golang.org/protobuf v1.36.6 // indirect
126130
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect

0 commit comments

Comments
 (0)