Skip to content

Repository files navigation


License: MITPkgGoDevGo Report Card

Unofficial, simple yet effective Google Cloud Trace CLI tool.



Installation

Homebrew (Linux/macOS)

brew install moshebe/pkg/gtrace

Go (Linux/Windows/macOS/any other platform supported by Go)

If you have Go 1.16+, you can install latest released version of gtrace directly from source by running:

go install github.com/moshebe/gtrace@latest

Usage

› gtrace help
NAME:
gtrace - Google Cloud Trace CLI tool
USAGE:
Simple command-line tool to query and fetch tracing information from Cloud Trace API.
Find more information at: https://cloud.google.com/trace/docs
VERSION:
v1.0.0
COMMANDS:
get Get a specific trace by id from one or more projects
list Query traces from a project according to the given conditions
url Generate a browsable URL for a given trace
format Format trace spans according to a given template duration Filter trace spans by total duration
subtree Extract span and all its children for a given trace
help, h Shows a list of commands or helpfor one command
GLOBAL OPTIONS:
--help, -h show help (default: false)
--version, -v print the version (default: false)

Authentication

Google Cloud APIs has a few methods to authenticate:

  1. On your machine maka sure you have gcloud and that you are logged-in and then run gcloud auth application-default login
  2. If you are running on GKE you can use Workload Identity
  3. Service accounts with JSON keys
  4. Pointing to your service account via env GOOGLE_APPLICATION_CREDENTIALS

You can read about it more on: https://cloud.google.com/docs/authentication/getting-started

Examples

Fetch a specific trace from multiple projects:

gtrace get --project production-a,production-b 5e26a889fa12da351beee9ea16ce0a65

Format trace spans by a specific template:

gtrace format -f /tmp/trace.json --template "{{ .Name }}, {{ .Duration }}"

Query traces by multiple filters from the last 3 hours:

gtrace list --project dev --limit 10 --since 3h --filter service:api --filter user-id:1234

About

Unofficial, simple yet effective Google Cloud Trace CLI tool.

Resources

Stars

83 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages