Skip to content

Commit

Permalink
move gcp profiling start outside of init()
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Callaway <bcallaway@google.com>
  • Loading branch information
bobcallaway committed Oct 9, 2023
1 parent 243e383 commit 229a8b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 0 additions & 14 deletions cmd/rekor-server/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"os"
"time"

"cloud.google.com/go/profiler"

homedir "github.com/mitchellh/go-homedir"
"github.com/sigstore/rekor/pkg/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -153,18 +151,6 @@ Memory and file-based signers should only be used for testing.`)
}()
}

if viper.GetBool("gcp_cloud_profiling.enabled") {
cfg := profiler.Config{
Service: viper.GetString("gcp_cloud_profiling.service"),
ServiceVersion: viper.GetString("gcp_cloud_profiling.service_version"),
ProjectID: viper.GetString("gcp_cloud_profiling.project_id"),
EnableOCTelemetry: viper.GetBool("gcp_cloud_profiling.enable_oc_telemetry"),
}

if err := profiler.Start(cfg); err != nil {
log.Logger.Warnf("Error configuring GCP Cloud Profiling: %v", err)
}
}
}

// initConfig reads in config file and ENV variables if set.
Expand Down
14 changes: 14 additions & 0 deletions cmd/rekor-server/app/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/http"
"time"

"cloud.google.com/go/profiler"
"github.com/go-openapi/loads"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -75,6 +76,19 @@ var serveCmd = &cobra.Command{
}
log.Logger.Infof("starting rekor-server @ %v", viStr)

if viper.GetBool("gcp_cloud_profiling.enabled") {
cfg := profiler.Config{
Service: viper.GetString("gcp_cloud_profiling.service"),
ServiceVersion: viper.GetString("gcp_cloud_profiling.service_version"),
ProjectID: viper.GetString("gcp_cloud_profiling.project_id"),
EnableOCTelemetry: viper.GetBool("gcp_cloud_profiling.enable_oc_telemetry"),
}

if err := profiler.Start(cfg); err != nil {
log.Logger.Warnf("Error configuring GCP Cloud Profiling: %v", err)
}
}

doc, _ := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
server := restapi.NewServer(operations.NewRekorServerAPI(doc))
defer func() {
Expand Down

0 comments on commit 229a8b3

Please sign in to comment.