Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Add Tracing #308

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion cmd/wksctl/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package main

import (
"context"
"os"

ot "github.com/opentracing/opentracing-go"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/weaveworks/go-checkpoint"
"sigs.k8s.io/controller-runtime/pkg/tracing"

"github.com/weaveworks/wksctl/cmd/wksctl/addon"
"github.com/weaveworks/wksctl/cmd/wksctl/apply"
Expand Down Expand Up @@ -42,6 +45,16 @@ func configureLogger(cmd *cobra.Command, args []string) {
}

func main() {
tracingCloser, err := tracing.SetupJaeger("wksctl")
if err != nil {
log.Fatalf("failed to set up Jaeger: %v", err)
}
defer tracingCloser.Close()

sp := ot.StartSpan("wksctl")
defer sp.Finish()
ctx := ot.ContextWithSpan(context.Background(), sp)

rootCmd.PersistentFlags().BoolVarP(&options.verbose, "verbose", "v", false, "Enable verbose output")

rootCmd.AddCommand(addon.Cmd)
Expand All @@ -65,7 +78,8 @@ func main() {
checkResponse.CurrentVersion, checkResponse.CurrentDownloadURL)
}

if err := rootCmd.Execute(); err != nil {
if err := rootCmd.ExecuteContext(ctx); err != nil {
sp.Finish()
os.Exit(1)
}

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/go-jsonnet v0.16.0
github.com/googleapis/gnostic v0.4.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/opentracing/opentracing-go v1.2.0
github.com/pelletier/go-toml v1.8.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1 // indirect
Expand All @@ -22,15 +22,14 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
github.com/thanhpk/randstr v1.0.4
github.com/weaveworks/cluster-api-provider-existinginfra v0.0.4-0.20201019151825-abde7d1650ca
github.com/weaveworks/cluster-api-provider-existinginfra v0.0.4-0.20201022134757-9265a295f8a1
github.com/weaveworks/footloose v0.0.0-20200609124411-8f3df89ea188
github.com/weaveworks/go-checkpoint v0.0.0-20170503165305-ebbb8b0518ab
github.com/weaveworks/launcher v0.0.0-20180824102238-59a4fcc32c9c
github.com/weaveworks/libgitops v0.0.2
github.com/whilp/git-urls v0.0.0-20191001220047-6db9661140c0
golang.org/x/crypto v0.0.0-20200707235045-ab33eee955e0
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
golang.org/x/tools v0.0.0-20200708003708-134513de8882 // indirect
gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1
Expand All @@ -42,7 +41,7 @@ require (
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19
sigs.k8s.io/cluster-api v0.3.6
sigs.k8s.io/controller-runtime v0.6.0
sigs.k8s.io/kustomize/kyaml v0.6.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.6.0
sigs.k8s.io/yaml v1.2.0
)

Expand Down Expand Up @@ -75,4 +74,5 @@ replace (
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.5
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.18.5
k8s.io/sample-controller => k8s.io/sample-controller v0.18.5
sigs.k8s.io/controller-runtime => github.com/bboreham/controller-runtime v0.6.4-0.20201021142033-b7613e6bd7ff
)
Loading