Skip to content

Commit baea2db

Browse files
authored
chore: instrument controlplane and cas with OpenTelemetry tracing (#3081)
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
1 parent 623d06f commit baea2db

99 files changed

Lines changed: 2130 additions & 269 deletions

File tree

Some content is hidden

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

‎app/artifact-cas/cmd/main.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/go-kratos/kratos/v2/log"
3838
"github.com/go-kratos/kratos/v2/transport/grpc"
3939
"github.com/go-kratos/kratos/v2/transport/http"
40+
"go.opentelemetry.io/otel/trace"
4041

4142
_ "go.uber.org/automaxprocs"
4243
)
@@ -63,7 +64,7 @@ type app struct {
6364
backend.Providers
6465
}
6566

66-
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server, ms *server.HTTPMetricsServer, providers backend.Providers) *app {
67+
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server, ms *server.HTTPMetricsServer, providers backend.Providers, _ trace.TracerProvider) *app {
6768
return &app{
6869
kratos.New(
6970
kratos.ID(id),
@@ -131,7 +132,7 @@ func main() {
131132
panic(err)
132133
}
133134

134-
app, cleanup, err := wireApp(bc.Server, bc.Auth, credentialsReader, logger)
135+
app, cleanup, err := wireApp(&bc, bc.Server, bc.Auth, credentialsReader, logger)
135136
if err != nil {
136137
panic(err)
137138
}

‎app/artifact-cas/cmd/wire.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2023-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import (
3131
)
3232

3333
// wireApp init kratos application.
34-
func wireApp(*conf.Server, *conf.Auth, credentials.Reader, log.Logger) (*app, func(), error) {
34+
func wireApp(*conf.Bootstrap, *conf.Server, *conf.Auth, credentials.Reader, log.Logger) (*app, func(), error) {
3535
panic(
3636
wire.Build(
3737
server.ProviderSet,

‎app/artifact-cas/cmd/wire_gen.go‎

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

‎app/artifact-cas/configs/config.devel.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,12 @@ credentials_service:
3030
address: ${VAULT_ADDRESS:http://0.0.0.0:8200}
3131
token: ${VAULT_TOKEN:notasecret}
3232

33+
observability:
34+
tracing:
35+
enabled: false
36+
endpoint: "localhost:4317"
37+
insecure: true
38+
sampling_ratio: 1.0
39+
3340
auth:
3441
public_key_path: ${PUBLIC_KEY_PATH:../../devel/devkeys/cas.pub}

‎app/artifact-cas/internal/conf/conf.pb.go‎

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

‎app/artifact-cas/internal/conf/conf.proto‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,24 @@ message Bootstrap {
2828

2929
message Observability {
3030
Sentry sentry = 1;
31+
Tracing tracing = 2;
3132

3233
// Sentry notification support
3334
message Sentry {
3435
string dsn = 1;
3536
string environment = 2;
3637
}
38+
// OpenTelemetry tracing configuration
39+
message Tracing {
40+
// Whether tracing is enabled. Disabled by default for backward compatibility.
41+
bool enabled = 1;
42+
// OTLP gRPC exporter endpoint (e.g. "localhost:4317")
43+
string endpoint = 2;
44+
// Whether to use insecure connection (no TLS). Useful for local development.
45+
bool insecure = 3;
46+
// Sampling ratio between 0.0 and 1.0. Defaults to 1.0 (sample everything) when unset.
47+
optional double sampling_ratio = 4;
48+
}
3749
}
3850
}
3951

0 commit comments

Comments
 (0)