cloudtrace

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetListTracesFilter

func GetListTracesFilter(queryText string) (string, error)

GetListTracesFilter takes the raw query text from a user and converts it to a filter string as expected by the Cloud Trace API

func GetServiceName

func GetServiceName(span *tracepb.TraceSpan) string

GetServiceName returns the service name for the span

func GetSpanOperationName

func GetSpanOperationName(span *tracepb.TraceSpan) string

GetSpanOperationName gets the name and method label value for the span and combines them to create a descriptive name

func GetTags

func GetTags(span *tracepb.TraceSpan) (serviceTags json.RawMessage, spanTags json.RawMessage, err error)

GetTags converts Google Trace labels to Grafana service and span tags

func GetTraceName

func GetTraceName(span *tracepb.TraceSpan) string

GetTraceName gets the name, service label value, and method label value for the span and combines them to create a descriptive name

Types

type API

type API interface {
	// ListTraces retrieves all traces matching some query filter up to the given limit
	ListTraces(context.Context, *TracesQuery) ([]*cloudtracepb.Trace, error)
	// GetTrace retrieves a trace matching a trace ID
	GetTrace(context.Context, *TraceQuery) (*cloudtracepb.Trace, error)
	// TestConnection queries for any trace from the given project
	TestConnection(ctx context.Context, projectID string) error
	// ListProjects returns the project IDs of all visible projects
	ListProjects(context.Context) ([]string, error)
	// Close closes the underlying connection to the GCP API
	Close() error
}

API implements the methods we need to query traces and list projects from GCP

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps a GCP trace client to fetch traces and spance, and a resourcemanager client to list projects

func NewClient

func NewClient(ctx context.Context, jsonCreds []byte) (*Client, error)

NewClient creates a new Client using jsonCreds for authentication

func NewClientWithGCE

func NewClientWithGCE(ctx context.Context) (*Client, error)

NewClient creates a new Client using GCE metadata for authentication

func NewClientWithImpersonation added in v1.1.0

func NewClientWithImpersonation(ctx context.Context, jsonCreds []byte, impersonateSA string) (*Client, error)

NewClient creates a new Clients using service account impersonation

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying connection to the GCP API

func (*Client) GetTrace

func (c *Client) GetTrace(ctx context.Context, q *TraceQuery) (*cloudtracepb.Trace, error)

GetTrace retrieves a single trace given a trace ID

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]string, error)

ListProjects returns the project IDs of all visible projects

func (*Client) ListTraces

func (c *Client) ListTraces(ctx context.Context, q *TracesQuery) ([]*cloudtracepb.Trace, error)

ListTraces retrieves all traces matching some query filter up to the given limit

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context, projectID string) error

TestConnection queries for any trace from the given project

type TimeRange

type TimeRange struct {
	From time.Time
	To   time.Time
}

TimeRange holds both a from and to time

type TraceQuery

type TraceQuery struct {
	ProjectID string
	TraceID   string
}

TraceQuery is the information from a Grafana query needed to query GCP for a trace

type TracesQuery

type TracesQuery struct {
	ProjectID string
	Filter    string
	Limit     int64
	TimeRange TimeRange
}

TracesQuery is the information from a Grafana query needed to query GCP for traces

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL