cloudtrace

package
v0.0.0-...-bfa3054 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 25 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 AlertManagerAlert

type AlertManagerAlert struct {
	Status      string            `json:"status"`
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`

	StartsAt AlertManagerTime `json:"startsAt"`
	EndsAt   AlertManagerTime `json:"endsAt,omitempty"`
}

type AlertManagerTime

type AlertManagerTime time.Time

AlertManagerTime takes care of representing time.Time as RFC3339. See https://prometheus.io/docs/alerting/0.27/clients/

func (AlertManagerTime) MarshalJSON

func (a AlertManagerTime) MarshalJSON() ([]byte, error)

func (AlertManagerTime) String

func (a AlertManagerTime) String() string

func (*AlertManagerTime) UnmarshalJSON

func (a *AlertManagerTime) UnmarshalJSON(jsonRepr []byte) error

type Alertmanager

type Alertmanager struct {
	URL      string
	ProxyURL string
	CertPool *x509.CertPool
}

func NewAlertmanager

func NewAlertmanager(hookURL string, proxyURL string, certPool *x509.CertPool) (*Alertmanager, error)

func (*Alertmanager) Post

func (s *Alertmanager) Post(ctx context.Context, entries []*cloudtracepb.Trace) error

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

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