aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/main.go
diff options
context:
space:
mode:
authorSebastian Jug <sejug@redhat.com>2018-10-16 16:30:53 -0400
committerSebastian Jug <seb@stianj.ug>2019-02-18 09:57:08 -0500
commit7141f972700ed454438d8539dd0bec79c0b61cf4 (patch)
treebfa2e524b71757a514a02ef68661b46dca9a3dfe /cmd/podman/main.go
parente738ef16225395f5f5e4b93ba1a43ae9449ae11b (diff)
downloadpodman-7141f972700ed454438d8539dd0bec79c0b61cf4.tar.gz
podman-7141f972700ed454438d8539dd0bec79c0b61cf4.tar.bz2
podman-7141f972700ed454438d8539dd0bec79c0b61cf4.zip
OpenTracing support added to start, stop, run, create, pull, and ps
Drop context.Context field from cli.Context Signed-off-by: Sebastian Jug <sejug@redhat.com>
Diffstat (limited to 'cmd/podman/main.go')
-rw-r--r--cmd/podman/main.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index f9820c075..ecb72f58b 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -1,7 +1,9 @@
package main
import (
+ "context"
"fmt"
+ "io"
"log/syslog"
"os"
"os/exec"
@@ -13,8 +15,10 @@ import (
"github.com/containers/libpod/libpod"
_ "github.com/containers/libpod/pkg/hooks/0.1.0"
"github.com/containers/libpod/pkg/rootless"
+ "github.com/containers/libpod/pkg/tracing"
"github.com/containers/libpod/version"
"github.com/containers/storage/pkg/reexec"
+ opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
lsyslog "github.com/sirupsen/logrus/hooks/syslog"
@@ -25,6 +29,9 @@ import (
// in the repository
var (
exitCode = 125
+ Ctx context.Context
+ span opentracing.Span
+ closer io.Closer
)
// Commands that the remote and local client have
@@ -112,6 +119,7 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&MainGlobalOpts.Syslog, "syslog", false, "Output logging information to syslog as well as the console")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.TmpDir, "tmpdir", "", "Path to the tmp directory")
+ rootCmd.PersistentFlags().BoolVar(&MainGlobalOpts.Trace, "trace", false, "enable opentracing output")
rootCmd.AddCommand(mainCommands...)
rootCmd.AddCommand(getMainCommands()...)
@@ -181,6 +189,15 @@ func before(cmd *cobra.Command, args []string) error {
}
pprof.StartCPUProfile(f)
}
+ if cmd.Flag("trace").Changed {
+ var tracer opentracing.Tracer
+ tracer, closer = tracing.Init("podman")
+ opentracing.SetGlobalTracer(tracer)
+
+ span = tracer.StartSpan("before-context")
+
+ Ctx = opentracing.ContextWithSpan(context.Background(), span)
+ }
return nil
}
@@ -188,6 +205,10 @@ func after(cmd *cobra.Command, args []string) error {
if cmd.Flag("cpu-profile").Changed {
pprof.StopCPUProfile()
}
+ if cmd.Flag("trace").Changed {
+ span.Finish()
+ closer.Close()
+ }
return nil
}