pkg

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PtrToString

func PtrToString(v string) *string

func QueryToURL

func QueryToURL(query HoneycombQuery, baseURL string, dataset string) (string, error)

QueryToURL converts a query to a URL. It uses Honeycomb's query parameter and template links feature https://docs.honeycomb.io/investigate/collaborate/share-query/

func SaveHoneycombGraph

func SaveHoneycombGraph(url string, outFile string, port int) error

SaveHoneycombGraph saves a screenshot of a Honeycomb graph to a file It uses Chrome's remote debugging protocol to take a screenshot. You need to manually start a Chrome instance with remote debugging enabled e.g. chrome --remote-debugging-port=9222 Then you must login into honeycomb. This will use your most recent chrome session so if you are logged into chrome with multiple accounts make sure the most recently used chrome is the one with the Honeycomb account.

Types

type HoneycombClient

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

func NewHoneycombClient

func NewHoneycombClient(config config.Config) (*HoneycombClient, error)

func (*HoneycombClient) CreateQuery

func (h *HoneycombClient) CreateQuery(datasetSlug string, q HoneycombQuery) (string, error)

func (*HoneycombClient) GetColumns

func (h *HoneycombClient) GetColumns(datasetSlug string) ([]HoneycombColumn, error)

type HoneycombColumn

type HoneycombColumn struct {
	Id          string    `json:"id,omitempty"`
	KeyName     string    `json:"key_name,omitempty"`
	Hidden      bool      `json:"hidden,omitempty"`
	Description string    `json:"description,omitempty"`
	Type        string    `json:"type,omitempty"`
	LastWritten time.Time `json:"last_written,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
}

type HoneycombQuery

type HoneycombQuery struct {
	ID           *string  `json:"id,omitempty"`
	Breakdowns   []string `json:"breakdowns,omitempty"`
	Calculations []struct {
		Op     string      `json:"op,omitempty"`
		Column interface{} `json:"column,omitempty"`
	} `json:"calculations,omitempty"`
	Filters []struct {
		Op     string      `json:"op,omitempty"`
		Column interface{} `json:"column,omitempty"`
		Value  string      `json:"value,omitempty"`
	} `json:"filters"`
	FilterCombination string `json:"filter_combination,omitempty"`
	Granularity       int    `json:"granularity,omitempty"`
	Orders            []struct {
		Column string `json:"column,omitempty"`
		Op     string `json:"op,omitempty"`
		Order  string `json:"order,omitempty"`
	} `json:"orders,omitempty"`
	Limit     int `json:"limit,omitempty"`
	StartTime int `json:"start_time,omitempty"`
	EndTime   int `json:"end_time,omitempty"`
	TimeRange int `json:"time_range,omitempty"`
	Havings   []struct {
		CalculateOp string      `json:"calculate_op,omitempty"`
		Column      interface{} `json:"column,omitempty"`
		Op          string      `json:"op,omitempty"`
		Value       int         `json:"value,omitempty"`
	} `json:"havings,omitempty"`
}

type Metrics

type Metrics struct {
	PredictTime float64 `json:"predict_time"`
}

type Predictor

type Predictor struct {
	Config *config.Config
}

func (*Predictor) Predict

func (p *Predictor) Predict(inQuery QueryInput) (*Query, error)

func (*Predictor) Translate

func (p *Predictor) Translate(inQuery QueryInput) (string, error)

type Query

type Query struct {
	Input               *QueryInput  `json:"input,omitempty"`
	Output              *string      `json:"output,omitempty"`
	Id                  *string      `json:"id,omitempty"`
	Version             *string      `json:"version,omitempty"`
	CreatedAt           *time.Time   `json:"created_at,omitempty"`
	StartedAt           *time.Time   `json:"started_at,omitempty"`
	CompletedAt         *time.Time   `json:"completed_at,omitempty"`
	Logs                *string      `json:"logs,omitempty"`
	Error               *interface{} `json:"error,omitempty"`
	Status              *string      `json:"status,omitempty"`
	Metrics             Metrics      `json:"metrics,omitempty"`
	OutputFilePrefix    *string      `json:"output_file_prefix,omitempty"`
	Webhook             *string      `json:"webhook,omitempty"`
	WebhookEventsFilter []string     `json:"webhook_events_filter,omitempty"`
}

Query represents a query for the model; not a honeycomb query.

type QueryInput

type QueryInput struct {
	NLQ string `json:"nlq"`
	// cols is a string representing a json list of cols.
	COLS string `json:"cols"`
}

type ReplicateClient

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

ReplicateClient is a client for the model when deployed on Replicate (as opposed to K8s)

func NewReplicateClient

func NewReplicateClient(cfg config.Config) (*ReplicateClient, error)

func (*ReplicateClient) Translate

func (p *ReplicateClient) Translate(inQuery QueryInput) (string, error)

Translate takes a natural language query and returns the honeycomb query as a string

type Translator

type Translator interface {
	Translate(nlq QueryInput) (string, error)
}

Translator translates a natural language query to a honeycomb query.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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