mirror of https://github.com/kubernetes/kops.git
Merge pull request #16220 from rifelpet/jaeger
Jaeger tracing visualizer improvements
This commit is contained in:
commit
63c0636ae4
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
|
|
@ -12,12 +12,47 @@ To try this out:
|
||||||
|
|
||||||
You should now see that the /tmp/trace file is created.
|
You should now see that the /tmp/trace file is created.
|
||||||
|
|
||||||
Then we have an experimental tool to serve the trace file to jaeger:
|
Then we have an experimental tool to serve the trace file to jaeger. First ensure `jaeger-query` is in your PATH, available [here](https://www.jaegertracing.io/download/#binaries)
|
||||||
|
|
||||||
```
|
```
|
||||||
cd tools/otel/traceserver
|
cd tools/otel/traceserver
|
||||||
go run . --src /tmp/trace --run jaeger
|
go run . --src /tmp/trace --run jaeger
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively you can use the jaeger docker image with:
|
||||||
|
|
||||||
|
```
|
||||||
|
go run . --src /tmp/trace --run docker-jaeger
|
||||||
|
```
|
||||||
|
|
||||||
|
This will open your local jaeger-query's frontend in a web browser:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Not everything is instrumented yet, and not all the traces are fully joined up (we need to thread more contexts through more methods),
|
Not everything is instrumented yet, and not all the traces are fully joined up (we need to thread more contexts through more methods),
|
||||||
but you should be able to start to explore the operations that we run and their performance.
|
but you should be able to start to explore the operations that we run and their performance.
|
||||||
|
|
||||||
|
## Prow Jobs
|
||||||
|
|
||||||
|
Tracing is enabled in the kops prow jobs. `.otel` files are created during job execution and included as job artifacts in the `otlp` subdirectory.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://gcsweb.k8s.io/gcs/kubernetes-jenkins/pr-logs/pull/kops/16204/presubmit-kops-aws-scale-amazonvpc-using-cl2/1742962895290896384/artifacts/otlp/
|
||||||
|
```
|
||||||
|
|
||||||
|
Download these files to a local directory, either with `gsutil` or through a web browser
|
||||||
|
|
||||||
|
```
|
||||||
|
mkdir /tmp/job-traces
|
||||||
|
|
||||||
|
gsutil cp -r gs://kubernetes-jenkins/pr-logs/pull/kops/16204/presubmit-kops-aws-scale-amazonvpc-using-cl2/1742962895290896384/artifacts/otlp/ /tmp/job-traces
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run the trace server as normal:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd tools/otel/traceserver
|
||||||
|
go run . --src /tmp/traces --run jaeger
|
||||||
|
```
|
||||||
|
|
@ -58,7 +58,7 @@ func run(ctx context.Context) error {
|
||||||
src := ""
|
src := ""
|
||||||
flag.StringVar(&src, "src", src, "tracefile to load")
|
flag.StringVar(&src, "src", src, "tracefile to load")
|
||||||
flag.StringVar(&listen, "listen", listen, "endpoint on which to serve grpc")
|
flag.StringVar(&listen, "listen", listen, "endpoint on which to serve grpc")
|
||||||
flag.StringVar(&run, "run", run, "visualization program to run [jaeger]")
|
flag.StringVar(&run, "run", run, "visualization program to run [jaeger, docker-jaeger]")
|
||||||
klog.InitFlags(nil)
|
klog.InitFlags(nil)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -68,10 +68,11 @@ func run(ctx context.Context) error {
|
||||||
|
|
||||||
if run != "" {
|
if run != "" {
|
||||||
switch run {
|
switch run {
|
||||||
case "jaeger":
|
case "jaeger", "docker-jaeger":
|
||||||
go func() {
|
go func() {
|
||||||
opt := RunJaegerOptions{
|
opt := RunJaegerOptions{
|
||||||
StorageServer: listen,
|
StorageServer: listen,
|
||||||
|
UseDocker: run == "docker-jaeger",
|
||||||
}
|
}
|
||||||
err := runJaeger(ctx, opt)
|
err := runJaeger(ctx, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -79,7 +80,7 @@ func run(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("run=%q not known (valid values: jaeger)", run)
|
return fmt.Errorf("run=%q not known (valid values: jaeger, docker-jaeger)", run)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -485,6 +486,7 @@ func attributeValueAsString(v *v11.AnyValue) (string, error) {
|
||||||
// RunJaegerOptions are the options for runJaeger
|
// RunJaegerOptions are the options for runJaeger
|
||||||
type RunJaegerOptions struct {
|
type RunJaegerOptions struct {
|
||||||
StorageServer string
|
StorageServer string
|
||||||
|
UseDocker bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// runJaeger starts the jaeger query & visualizer, binding to our storage server
|
// runJaeger starts the jaeger query & visualizer, binding to our storage server
|
||||||
|
|
@ -494,25 +496,45 @@ func runJaeger(ctx context.Context, opt RunJaegerOptions) error {
|
||||||
var jaeger *exec.Cmd
|
var jaeger *exec.Cmd
|
||||||
{
|
{
|
||||||
klog.Infof("starting jaeger")
|
klog.Infof("starting jaeger")
|
||||||
args := []string{
|
|
||||||
"docker", "run", "--rm", "--network=host", "--name=jaeger",
|
var c *exec.Cmd
|
||||||
"-e=SPAN_STORAGE_TYPE=grpc-plugin",
|
if opt.UseDocker {
|
||||||
"jaegertracing/jaeger-query",
|
args := []string{
|
||||||
"--grpc-storage.server=" + opt.StorageServer,
|
"docker", "run", "--rm", "--network=host", "--name=jaeger",
|
||||||
|
"-e=SPAN_STORAGE_TYPE=grpc-plugin",
|
||||||
|
"jaegertracing/jaeger-query",
|
||||||
|
"--grpc-storage.server=" + opt.StorageServer,
|
||||||
|
}
|
||||||
|
c = exec.CommandContext(ctx, args[0], args[1:]...)
|
||||||
|
} else {
|
||||||
|
args := []string{
|
||||||
|
"jaeger-query",
|
||||||
|
"--grpc-storage.server=" + opt.StorageServer,
|
||||||
|
}
|
||||||
|
c = exec.CommandContext(ctx, args[0], args[1:]...)
|
||||||
|
c.Env = append(os.Environ(), "SPAN_STORAGE_TYPE=grpc-plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
c := exec.CommandContext(ctx, args[0], args[1:]...)
|
|
||||||
c.Stdout = os.Stdout
|
c.Stdout = os.Stdout
|
||||||
c.Stderr = os.Stderr
|
c.Stderr = os.Stderr
|
||||||
if err := c.Start(); err != nil {
|
if err := c.Start(); err != nil {
|
||||||
return fmt.Errorf("starting jaeger in docker (%s): %w", strings.Join(args, " "), err)
|
return fmt.Errorf("starting jaeger (%s): %w", strings.Join(c.Args, " "), err)
|
||||||
}
|
}
|
||||||
jaeger = c
|
jaeger = c
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
fmt.Fprintf(os.Stdout, "open browser to %s\n", jaegerURL)
|
fmt.Fprintf(os.Stdout, "open browser to %s\n", jaegerURL)
|
||||||
args := []string{"xdg-open", jaegerURL}
|
|
||||||
|
args := make([]string, 0)
|
||||||
|
for _, o := range []string{"xdg-open", "open"} {
|
||||||
|
if _, err := exec.LookPath(o); err == nil {
|
||||||
|
args = append(args, o)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
args = append(args, jaegerURL)
|
||||||
|
|
||||||
c := exec.CommandContext(ctx, args[0], args[1:]...)
|
c := exec.CommandContext(ctx, args[0], args[1:]...)
|
||||||
c.Stdout = os.Stdout
|
c.Stdout = os.Stdout
|
||||||
c.Stderr = os.Stderr
|
c.Stderr = os.Stderr
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue