clickhouse

package
v0.0.0-...-a245e04 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

README

Useful queries

Inject structured log data

INSERT INTO logs (Timestamp, ProjectId, Body, LogAttributes) VALUES (now(), 1, 'body', {'user_id':'3'});
INSERT INTO logs (Timestamp, ProjectId, Body, LogAttributes) VALUES (now(), 2, 'body', {'user_id':'1'});


INSERT INTO logs (Timestamp, ProjectId, Body, LogAttributes) VALUES (now(), 1, 'body', {'workspace_id':'3'});
INSERT INTO logs (Timestamp, ProjectId, Body, LogAttributes) VALUES (now(), 2, 'body', {'workspace_id':'1'});

Get all log keys for a project

SELECT arrayJoin(LogAttributes.keys) as keys, count() as cnt FROM logs WHERE ProjectId = 1 GROUP BY keys ORDER BY cnt DESC;

Documentation

Index

Constants

View Source
const AlertStateChangesTable = "alert_state_changes"
View Source
const AllKeyValuesMaxRows = 100_000_000
View Source
const DbPrefix = "db."
View Source
const ErrorGroupsTable = "error_groups"
View Source
const ErrorObjectsTable = "error_objects"
View Source
const EventKeyValuesTable = "event_key_values_new"
View Source
const EventKeysTable = "event_keys_new"
View Source
const EventPrefix = "event."
View Source
const FieldsTable = "fields"
View Source
const HighlightKeyKey = "highlight.key"
View Source
const HighlightTypeKey = "highlight.type"
View Source
const HttpPrefix = "http."
View Source
const HttpRequestBodyKey = "http.request.body"
View Source
const HttpResponseBodyKey = "http.response.body"
View Source
const HttpUrlKey = "http.url"
View Source
const KeyValuesLimit int = 50
View Source
const KeyValuesMaxRows = 1_000_000
View Source
const KeysMaxRows = 1_000_000
View Source
const LogKeyValuesTable = "log_key_values"
View Source
const LogKeysTable = "log_keys"
View Source
const LogsLimit int = 50
View Source
const LogsSamplingTable = "logs_sampling"
View Source
const LogsTable = "logs"
View Source
const MaxBuckets = 240
View Source
const MetricHistoryMaxLookback = time.Hour
View Source
const MetricHistoryTable = "metric_history"
View Source
const MetricNamesTable = "trace_metrics"
View Source
const NoLimit = 1_000_000_000_000
View Source
const OrderBackwardInverted = "Timestamp DESC, UUID DESC"
View Source
const OrderBackwardNatural = "Timestamp ASC, UUID ASC"
View Source
const OrderForwardInverted = "Timestamp ASC, UUID ASC"
View Source
const OrderForwardNatural = "Timestamp DESC, UUID DESC"
View Source
const OsPrefix = "os."
View Source
const ProcessPrefix = "process."
View Source
const SamplingRows = 20_000_000
View Source
const SessionEventsTable = "session_events"
View Source
const SessionEventsView = "session_events_vw"
View Source
const SessionKeysTable = "session_keys"
View Source
const SessionsJoinedTable = "sessions_joined_vw"
View Source
const SessionsTable = "sessions"
View Source
const TelemetryPrefix = "telemetry."
View Source
const TraceAttributeValueLengthLimit = 2 << 15
View Source
const TraceKeyValuesTable = "trace_key_values"
View Source
const TraceKeysTable = "trace_keys"
View Source
const TracesSamplingTable = "traces_sampling_new"
View Source
const TracesTable = "traces"
View Source
const WsPrefix = "ws."

Variables

View Source
var (
	ServerAddr      = env.Config.ClickhouseAddress
	PrimaryDatabase = env.Config.ClickhouseDatabase // typically 'default', clickhouse needs an existing database to handle connections
	TestDatabase    = env.Config.ClickhouseTestDatabase
	Username        = env.Config.ClickhouseUsername
	Password        = env.Config.ClickhousePassword
)
View Source
var ErrorGroupsTableConfig = model.TableConfig{
	TableName: ErrorGroupsTable,
	KeysToColumns: map[string]string{
		string(modelInputs.ReservedErrorGroupKeyEvent):    "Event",
		string(modelInputs.ReservedErrorGroupKeySecureID): "SecureID",
		string(modelInputs.ReservedErrorGroupKeyStatus):   "Status",
		string(modelInputs.ReservedErrorGroupKeyTag):      "ErrorTagTitle",
		string(modelInputs.ReservedErrorGroupKeyType):     "Type",
	},
	BodyColumn:   "Event",
	ReservedKeys: reservedErrorGroupKeys,
}
View Source
var ErrorsSampleableTableConfig = SampleableTableConfig{
	// contains filtered or unexported fields
}
View Source
var EventsSampleableTableConfig = SampleableTableConfig{
	// contains filtered or unexported fields
}
View Source
var LogsSampleableTableConfig = SampleableTableConfig{
	// contains filtered or unexported fields
}
View Source
var LogsTableConfig = model.TableConfig{
	TableName:         LogsTable,
	KeysToColumns:     logKeysToColumns,
	ReservedKeys:      reservedLogKeys,
	BodyColumn:        "Body",
	SeverityColumn:    "SeverityText",
	AttributesColumns: []model.ColumnMapping{{Column: "LogAttributes"}},
	SelectColumns: []string{
		"ProjectId",
		"Timestamp",
		"UUID",
		"SeverityText",
		"Body",
		"LogAttributes",
		"TraceId",
		"SpanId",
		"SecureSessionId",
		"Source",
		"ServiceName",
		"ServiceVersion",
		"Environment",
	},
}
View Source
var MetricsSampleableTableConfig = SampleableTableConfig{
	// contains filtered or unexported fields
}
View Source
var SessionsJoinedTableConfig = model.TableConfig{
	TableName:         SessionsJoinedTable,
	AttributesColumns: []model.ColumnMapping{{Column: "RelevantFields"}},
	AttributesTable:   "fields",
	BodyColumn:        `concat(coalesce(nullif(arrayFilter((k, v) -> k = 'email', RelevantFields) [1].2,''), nullif(Identifier, ''), nullif(arrayFilter((k, v) -> k = 'device_id', RelevantFields) [1].2, ''), 'unidentified'), ': ', City, if(City != '', ', ', ''), Country)`,
	KeysToColumns: map[string]string{
		string(modelInputs.ReservedSessionKeyActiveLength):       "ActiveLength",
		string(modelInputs.ReservedSessionKeyServiceVersion):     "AppVersion",
		string(modelInputs.ReservedSessionKeyBrowserName):        "BrowserName",
		string(modelInputs.ReservedSessionKeyBrowserVersion):     "BrowserVersion",
		string(modelInputs.ReservedSessionKeyCity):               "City",
		string(modelInputs.ReservedSessionKeyCompleted):          "Processed",
		string(modelInputs.ReservedSessionKeyCountry):            "Country",
		string(modelInputs.ReservedSessionKeyEnvironment):        "Environment",
		string(modelInputs.ReservedSessionKeyExcluded):           "Excluded",
		string(modelInputs.ReservedSessionKeyFirstTime):          "FirstTime",
		string(modelInputs.ReservedSessionKeyHasComments):        "HasComments",
		string(modelInputs.ReservedSessionKeyHasErrors):          "HasErrors",
		string(modelInputs.ReservedSessionKeyHasRageClicks):      "HasRageClicks",
		string(modelInputs.ReservedSessionKeyIdentified):         "Identified",
		string(modelInputs.ReservedSessionKeyIdentifier):         "Identifier",
		string(modelInputs.ReservedSessionKeyIP):                 "IP",
		string(modelInputs.ReservedSessionKeyLength):             "Length",
		string(modelInputs.ReservedSessionKeyNormalness):         "Normalness",
		string(modelInputs.ReservedSessionKeyOsName):             "OSName",
		string(modelInputs.ReservedSessionKeyOsVersion):          "OSVersion",
		string(modelInputs.ReservedSessionKeyPagesVisited):       "PagesVisited",
		string(modelInputs.ReservedSessionKeySecureID):           "SecureID",
		string(modelInputs.ReservedSessionKeyState):              "State",
		string(modelInputs.ReservedSessionKeyTimestamp):          "Timestamp",
		string(modelInputs.ReservedSessionKeyViewedByAnyone):     "Viewed",
		string(modelInputs.ReservedSessionKeyWithinBillingQuota): "WithinBillingQuota",
		string(modelInputs.ReservedSessionKeyUpdatedAt):          "UpdatedAt",

		string(modelInputs.ReservedSessionKeyViewed):    "Viewed",
		string(modelInputs.ReservedSessionKeyProcessed): "Processed",
		string(modelInputs.ReservedSessionKeyLocState):  "State",
	},
	ReservedKeys: reservedSessionKeys,
	IgnoredFilters: map[string]bool{
		modelInputs.ReservedSessionKeySample.String():     true,
		modelInputs.ReservedSessionKeyViewedByMe.String(): true,
	},
	DefaultFilter: "excluded=false",
}
View Source
var SessionsSampleableTableConfig = SampleableTableConfig{
	// contains filtered or unexported fields
}
View Source
var SessionsTableConfig = model.TableConfig{
	TableName:         SessionsTable,
	KeysToColumns:     fieldMap,
	AttributesColumns: []model.ColumnMapping{{Column: "Fields"}},
	ReservedKeys: lo.Map(modelInputs.AllReservedSessionKey, func(item modelInputs.ReservedSessionKey, _ int) string {
		return item.String()
	}),
}
View Source
var TracesSampleableTableConfig = SampleableTableConfig{
	// contains filtered or unexported fields
}
View Source
var TracesTableConfig = model.TableConfig{
	TableName:         TracesTableNoDefaultConfig.TableName,
	KeysToColumns:     TracesTableNoDefaultConfig.KeysToColumns,
	ReservedKeys:      TracesTableNoDefaultConfig.ReservedKeys,
	BodyColumn:        TracesTableNoDefaultConfig.BodyColumn,
	AttributesColumns: TracesTableNoDefaultConfig.AttributesColumns,
	SelectColumns:     TracesTableNoDefaultConfig.SelectColumns,
	DefaultFilter:     fmt.Sprintf("%s!=%s %s!=%s", modelInputs.ReservedTraceKeySpanName, highlight.MetricSpanName, modelInputs.ReservedTraceKeyHighlightType, highlight.TraceTypeHighlightInternal),
}
View Source
var TracesTableNoDefaultConfig = model.TableConfig{
	TableName:         TracesTable,
	KeysToColumns:     traceKeysToColumns,
	ReservedKeys:      reservedTraceKeys,
	BodyColumn:        "SpanName",
	AttributesColumns: attributesColumns,
	SelectColumns:     traceColumns,
}

Functions

func ErrorMatchesQuery

func ErrorMatchesQuery(errorObject *model2.BackendErrorObjectInput, filters listener.Filters) bool

func GetEventsQueryImpl

func GetEventsQueryImpl(params modelInputs.QueryInput, projectId int, selectColumns string, orderBy *string, limit *int, offset *int) (string, []interface{}, error)

func GetPostgresConnectionString

func GetPostgresConnectionString() string

func GetSessionsQueryImpl

func GetSessionsQueryImpl(admin *model.Admin, params modelInputs.QueryInput, projectId int, retentionDate time.Time, selectColumns string, groupBy *string, orderBy *string, limit *int, offset *int) (string, []interface{}, bool, error)

func GetSessionsQueryImplDeprecated

func GetSessionsQueryImplDeprecated(admin *model.Admin, query modelInputs.ClickhouseQuery, projectId int, retentionDate time.Time, selectColumns string, groupBy *string, orderBy *string, limit *int, offset *int) (string, []interface{}, bool, error)

func KeyValuesAggregated

func KeyValuesAggregated(ctx context.Context, client *Client, tableName string, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int, event *string) ([]string, error)

func KeysAggregated

func KeysAggregated(ctx context.Context, client *Client, tableName string, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType, event *string) ([]*modelInputs.QueryKey, error)

func LogMatchesQuery

func LogMatchesQuery(logRow *LogRow, filters listener.Filters) bool

func RunMigrations

func RunMigrations(ctx context.Context, dbName string)

func SessionMatchesQuery

func SessionMatchesQuery(session *model.Session, filters listener.Filters) bool

func TraceMatchesQuery

func TraceMatchesQuery(trace *TraceRow, filters listener.Filters) bool

Types

type AggregatedMetricResults

type AggregatedMetricResults struct {
	GroupByKey string
	BucketId   uint64
	Value      float64
}

type AlertStateChangeRow

type AlertStateChangeRow struct {
	UUID       string
	ProjectID  uint32
	AlertID    uint32
	Timestamp  time.Time
	State      string
	GroupByKey string
}

type BlockNumberInfo

type BlockNumberInfo struct {
	Partition       string
	LastBlockNumber uint64
}

type ClickhouseErrorGroup

type ClickhouseErrorGroup struct {
	ProjectID           int32
	CreatedAt           int64
	UpdatedAt           int64
	ID                  int64
	SecureID            string
	Event               string
	Status              string
	Type                string
	ErrorTagID          int64
	ErrorTagTitle       string
	ErrorTagDescription string
}

type ClickhouseErrorObject

type ClickhouseErrorObject struct {
	ProjectID       int32
	Timestamp       int64
	ErrorGroupID    int64
	HasSession      bool
	ID              int64
	Browser         string
	Environment     string
	OSName          string
	ServiceName     string
	ServiceVersion  string
	ClientID        string
	VisitedURL      string
	TraceID         string
	SecureSessionID string
}

type ClickhouseField

type ClickhouseField struct {
	ProjectID        int32
	Type             string
	Name             string
	SessionCreatedAt int64
	SessionID        int64
	Value            string
	Timestamp        int64
}

type ClickhouseSession

type ClickhouseSession struct {
	ID                 int64
	ProjectID          int32
	PagesVisited       int32
	ViewedByAdmins     clickhouse.ArraySet
	FieldKeys          clickhouse.ArraySet
	FieldKeyValues     clickhouse.ArraySet
	CreatedAt          int64
	UpdatedAt          int64
	SecureID           string
	Identified         bool
	Identifier         string
	IP                 string
	City               string
	State              string
	Country            string
	OSName             string
	OSVersion          string
	BrowserName        string
	BrowserVersion     string
	Processed          *bool
	HasComments        bool
	HasRageClicks      *bool
	HasErrors          *bool
	Length             int64
	ActiveLength       int64
	Environment        string
	AppVersion         *string
	FirstTime          *bool
	Viewed             *bool
	WithinBillingQuota *bool
	EventCounts        *string
	Excluded           bool
	Normalness         *float64
}

type ClickhouseTraceRow

type ClickhouseTraceRow struct {
	Timestamp           time.Time
	UUID                string
	TraceId             string
	SpanId              string
	ParentSpanId        string
	ProjectId           uint32
	SecureSessionId     string
	TraceState          string
	SpanName            string
	SpanKind            string
	Duration            int64
	ServiceName         string
	ServiceVersion      string
	TraceAttributes     map[string]string
	StatusCode          string
	StatusMessage       string
	Environment         string
	HasErrors           bool
	EventsTimestamp     []time.Time         `json:"Events.Timestamp" ch:"Events.Timestamp"`
	EventsName          []string            `json:"Events.Name" ch:"Events.Name"`
	EventsAttributes    []map[string]string `json:"Events.Attributes" ch:"Events.Attributes"`
	LinksTraceId        []string            `json:"Links.TraceId" ch:"Links.TraceId"`
	LinksSpanId         []string            `json:"Links.SpanId" ch:"Links.SpanId"`
	LinksTraceState     []string            `json:"Links.TraceState" ch:"Links.TraceState"`
	LinksAttributes     []map[string]string `json:"Links.Attributes" ch:"Links.Attributes"`
	HttpResponseBody    string
	HttpRequestBody     string
	HttpUrl             string
	HighlightKey        string
	HighlightType       string
	HttpAttributes      map[string]string
	ProcessAttributes   map[string]string
	OsAttributes        map[string]string
	TelemetryAttributes map[string]string
	WsAttributes        map[string]string
	EventAttributes     map[string]string
	DbAttributes        map[string]string
}

func ConvertTraceRow

func ConvertTraceRow(traceRow *TraceRow) *ClickhouseTraceRow

type Client

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

func NewClient

func NewClient(dbName string) (*Client, error)

func SetupClickhouseTestDB

func SetupClickhouseTestDB() (*Client, error)

func (*Client) AggregateMetricStates

func (client *Client) AggregateMetricStates(ctx context.Context, metricId string, startDate time.Time, endDate time.Time, interval time.Duration, aggregator modelInputs.MetricAggregator, windowSeconds *int) ([]*modelInputs.MetricBucket, error)

func (*Client) AllKeyValues

func (client *Client) AllKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int) ([]string, error)

func (*Client) AllKeys

func (client *Client) AllKeys(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType) ([]*modelInputs.QueryKey, error)

func (*Client) BatchWriteLogRows

func (client *Client) BatchWriteLogRows(ctx context.Context, logRows []*LogRow) error

func (*Client) BatchWriteSessionEventRows

func (client *Client) BatchWriteSessionEventRows(ctx context.Context, eventRows []*SessionEventRow) error

func (*Client) BatchWriteTraceRows

func (client *Client) BatchWriteTraceRows(ctx context.Context, traceRows []*ClickhouseTraceRow) error

func (*Client) DeleteSessions

func (client *Client) DeleteSessions(ctx context.Context, projectId int, sessionIds []int) error

func (*Client) ErrorsKeyValues

func (client *Client) ErrorsKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int) ([]string, error)

func (*Client) ErrorsLogLines

func (client *Client) ErrorsLogLines(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogLine, error)

func (*Client) EventsKeyValues

func (client *Client) EventsKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int, event *string) ([]string, error)

func (*Client) EventsKeys

func (client *Client) EventsKeys(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType, event *string) ([]*modelInputs.QueryKey, error)

func (*Client) EventsLogLines

func (client *Client) EventsLogLines(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogLine, error)

func (*Client) ExistingTraceIds

func (client *Client) ExistingTraceIds(ctx context.Context, projectID int, traceIDs []string, startDate time.Time, endDate time.Time) ([]string, error)

func (*Client) GetAlertingAlertStateChanges

func (client *Client) GetAlertingAlertStateChanges(ctx context.Context, projectId int, alertId int, startDate time.Time, endDate time.Time, pageParam *int, countParam *int) ([]*modelInputs.AlertStateChange, int64, error)

func (*Client) GetBlockNumbers

func (client *Client) GetBlockNumbers(ctx context.Context, metricId string, startDate time.Time, endDate time.Time) ([]BlockNumberInfo, error)

func (*Client) GetConn

func (client *Client) GetConn() driver.Conn

func (*Client) GetLastAlertStateChanges

func (client *Client) GetLastAlertStateChanges(ctx context.Context, projectId int, alertId int) ([]*modelInputs.AlertStateChange, error)

func (*Client) GetLastAlertingStates

func (client *Client) GetLastAlertingStates(ctx context.Context, projectId int, alertId int, startDate time.Time, endDate time.Time) ([]modelInputs.AlertStateChange, error)

func (*Client) HealthCheck

func (client *Client) HealthCheck(ctx context.Context) error

func (*Client) LogsKeyValues

func (client *Client) LogsKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int) ([]string, error)

func (*Client) LogsKeys

func (client *Client) LogsKeys(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType) ([]*modelInputs.QueryKey, error)

func (*Client) LogsLogLines

func (client *Client) LogsLogLines(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogLine, error)

func (*Client) MetricsKeyValues

func (client *Client) MetricsKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int) ([]string, error)

func (*Client) MetricsKeys

func (client *Client) MetricsKeys(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType) ([]*modelInputs.QueryKey, error)

func (*Client) MetricsLogLines

func (client *Client) MetricsLogLines(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogLine, error)

func (*Client) QueryErrorFieldValues

func (client *Client) QueryErrorFieldValues(ctx context.Context, projectId int, count int, fieldName string, query string, start time.Time, end time.Time) ([]string, error)

func (*Client) QueryErrorGroupAggregateFrequency

func (client *Client) QueryErrorGroupAggregateFrequency(ctx context.Context, projectId int, errorGroupIds []int) ([]*modelInputs.ErrorDistributionItem, error)

func (*Client) QueryErrorGroupFrequencies

func (client *Client) QueryErrorGroupFrequencies(ctx context.Context, projectId int, errorGroupIds []int, params modelInputs.ErrorGroupFrequenciesParamsInput) ([]*modelInputs.ErrorDistributionItem, error)

func (*Client) QueryErrorGroupIdsDeprecated

func (client *Client) QueryErrorGroupIdsDeprecated(ctx context.Context, projectId int, count int, query modelInputs.ClickhouseQuery, page *int) ([]int64, int64, error)

func (*Client) QueryErrorGroupOccurrences

func (client *Client) QueryErrorGroupOccurrences(ctx context.Context, projectId int, errorGroupIds []int) (map[int]ErrorGroupOccurence, error)

func (*Client) QueryErrorGroupTags

func (client *Client) QueryErrorGroupTags(ctx context.Context, projectId int, errorGroupId int) ([]*modelInputs.ErrorGroupTagAggregation, error)

func (*Client) QueryErrorGroups

func (client *Client) QueryErrorGroups(ctx context.Context, projectId int, count int, params modelInputs.QueryInput, page *int) ([]int64, int64, error)

func (*Client) QueryErrorHistogramDeprecated

func (client *Client) QueryErrorHistogramDeprecated(ctx context.Context, projectId int, query modelInputs.ClickhouseQuery, options modelInputs.DateHistogramOptions) ([]time.Time, []int64, error)

func (*Client) QueryErrorObjects

func (client *Client) QueryErrorObjects(ctx context.Context, projectId int, errorGroupId *int, count int, params modelInputs.QueryInput, page *int) ([]int64, int64, error)

func (*Client) QueryErrorObjectsHistogram

func (client *Client) QueryErrorObjectsHistogram(ctx context.Context, projectId int, params modelInputs.QueryInput, options modelInputs.DateHistogramOptions) ([]time.Time, []int64, error)

func (*Client) QueryEventSessionIds

func (client *Client) QueryEventSessionIds(ctx context.Context, projectId int, count int, params modelInputs.QueryInput, sortField string, page *int) ([]int64, int64, error)

func (*Client) QueryFieldNames

func (client *Client) QueryFieldNames(ctx context.Context, projectId int, start time.Time, end time.Time) ([]*model.Field, error)

func (*Client) QueryFieldValues

func (client *Client) QueryFieldValues(ctx context.Context, projectId int, count int, fieldType string, fieldName string, query string, start time.Time, end time.Time) ([]string, error)

func (*Client) QuerySessionCustomMetrics

func (client *Client) QuerySessionCustomMetrics(ctx context.Context, projectId int, sessionSecureId string, metricNames []string) ([]*model.Metric, error)

func (*Client) QuerySessionHistogram

func (client *Client) QuerySessionHistogram(ctx context.Context, admin *model.Admin, projectId int, params modelInputs.QueryInput, retentionDate time.Time, options modelInputs.DateHistogramOptions) ([]time.Time, []int64, []int64, []int64, []int64, []int64, error)

func (*Client) QuerySessionHistogramDeprecated

func (client *Client) QuerySessionHistogramDeprecated(ctx context.Context, admin *model.Admin, projectId int, query modelInputs.ClickhouseQuery, retentionDate time.Time, options modelInputs.DateHistogramOptions) ([]time.Time, []int64, []int64, []int64, error)

func (*Client) QuerySessionIds

func (client *Client) QuerySessionIds(ctx context.Context, admin *model.Admin, projectId int, count int, params modelInputs.QueryInput, sortField string, page *int, retentionDate time.Time) ([]int64, int64, int64, int64, bool, error)

func (*Client) QuerySessionIdsDeprecated

func (client *Client) QuerySessionIdsDeprecated(ctx context.Context, admin *model.Admin, projectId int, count int, query modelInputs.ClickhouseQuery, sortField string, page *int, retentionDate time.Time) ([]int64, int64, bool, error)

func (*Client) ReadErrorsMetrics

func (client *Client) ReadErrorsMetrics(ctx context.Context, projectID int, params modelInputs.QueryInput, groupBy []string, nBuckets *int, bucketBy string, bucketWindow *int, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string, expressions []*modelInputs.MetricExpressionInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadEventMetrics

func (client *Client) ReadEventMetrics(ctx context.Context, projectID int, params modelInputs.QueryInput, column *string, metricTypes []modelInputs.MetricAggregator, groupBy []string, nBuckets *int, bucketBy string, bucketWindow *int, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadEventsMetrics

func (client *Client) ReadEventsMetrics(ctx context.Context, projectID int, params modelInputs.QueryInput, groupBy []string, nBuckets *int, bucketBy string, bucketWindow *int, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string, expressions []*modelInputs.MetricExpressionInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadLogs

func (client *Client) ReadLogs(ctx context.Context, projectID int, params modelInputs.QueryInput, pagination Pagination) (*modelInputs.LogConnection, error)

func (*Client) ReadLogsDailyAverage

func (client *Client) ReadLogsDailyAverage(ctx context.Context, projectIds []int, dateRange modelInputs.DateRangeRequiredInput) (float64, error)

func (*Client) ReadLogsDailySum

func (client *Client) ReadLogsDailySum(ctx context.Context, projectIds []int, dateRange modelInputs.DateRangeRequiredInput) (uint64, error)

func (*Client) ReadLogsHistogram

func (client *Client) ReadLogsHistogram(ctx context.Context, projectID int, params modelInputs.QueryInput, nBuckets int) (*modelInputs.LogsHistogram, error)

func (*Client) ReadLogsMetrics

func (client *Client) ReadLogsMetrics(ctx context.Context, projectID int, params modelInputs.QueryInput, groupBy []string, nBuckets *int, bucketBy string, bucketWindow *int, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string, expressions []*modelInputs.MetricExpressionInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadLogsTotalCount

func (client *Client) ReadLogsTotalCount(ctx context.Context, projectID int, params modelInputs.QueryInput) (uint64, error)

func (*Client) ReadMetrics

func (client *Client) ReadMetrics(ctx context.Context, input ReadMetricsInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadSessionLogs

func (client *Client) ReadSessionLogs(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogEdge, error)

This is a lighter weight version of the previous function for loading the minimal about of data for a session

func (*Client) ReadSessionsMetrics

func (client *Client) ReadSessionsMetrics(ctx context.Context, projectID int, params modelInputs.QueryInput, groupBy []string, nBuckets *int, bucketBy string, bucketWindow *int, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string, expressions []*modelInputs.MetricExpressionInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadTrace

func (client *Client) ReadTrace(ctx context.Context, projectID int, traceID string, timestamp time.Time) ([]*modelInputs.Trace, error)

func (*Client) ReadTraces

func (client *Client) ReadTraces(ctx context.Context, projectID int, params modelInputs.QueryInput, pagination Pagination) (*modelInputs.TraceConnection, error)

func (*Client) ReadTracesDailyAverage

func (client *Client) ReadTracesDailyAverage(ctx context.Context, projectIds []int, dateRange modelInputs.DateRangeRequiredInput) (float64, error)

func (*Client) ReadTracesDailySum

func (client *Client) ReadTracesDailySum(ctx context.Context, projectIds []int, dateRange modelInputs.DateRangeRequiredInput) (uint64, error)

func (*Client) ReadTracesMetrics

func (client *Client) ReadTracesMetrics(ctx context.Context, projectID int, params modelInputs.QueryInput, groupBy []string, nBuckets *int, bucketBy string, bucketWindow *int, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string, expressions []*modelInputs.MetricExpressionInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceErrorCounts

func (client *Client) ReadWorkspaceErrorCounts(ctx context.Context, projectIDs []int, params modelInputs.QueryInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceEventCounts

func (client *Client) ReadWorkspaceEventCounts(ctx context.Context, projectIDs []int, params modelInputs.QueryInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceLogCounts

func (client *Client) ReadWorkspaceLogCounts(ctx context.Context, projectIDs []int, params modelInputs.QueryInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceMetricCounts

func (client *Client) ReadWorkspaceMetricCounts(ctx context.Context, projectIDs []int, params modelInputs.QueryInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceSessionCounts

func (client *Client) ReadWorkspaceSessionCounts(ctx context.Context, projectIDs []int, params modelInputs.QueryInput) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceTraceCounts

func (client *Client) ReadWorkspaceTraceCounts(ctx context.Context, projectIDs []int, params modelInputs.QueryInput) (*modelInputs.MetricsBuckets, error)

func (*Client) SessionsKeyValues

func (client *Client) SessionsKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int) ([]string, error)

func (*Client) SessionsKeys

func (client *Client) SessionsKeys(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType) ([]*modelInputs.QueryKey, error)

func (*Client) SessionsLogLines

func (client *Client) SessionsLogLines(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogLine, error)

func (*Client) TracesKeyValues

func (client *Client) TracesKeyValues(ctx context.Context, projectID int, keyName string, startDate time.Time, endDate time.Time, query *string, limit *int) ([]string, error)

func (*Client) TracesKeys

func (client *Client) TracesKeys(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string, typeArg *modelInputs.KeyType) ([]*modelInputs.QueryKey, error)

func (*Client) TracesLogLines

func (client *Client) TracesLogLines(ctx context.Context, projectID int, params modelInputs.QueryInput) ([]*modelInputs.LogLine, error)

func (*Client) WriteAlertStateChanges

func (client *Client) WriteAlertStateChanges(ctx context.Context, projectId int, alertStates []modelInputs.AlertStateChange) error

func (*Client) WriteErrorGroups

func (client *Client) WriteErrorGroups(ctx context.Context, groups []*model.ErrorGroup) error

func (*Client) WriteErrorObjects

func (client *Client) WriteErrorObjects(ctx context.Context, objects []*model.ErrorObject, sessions []*model.Session) error

func (*Client) WriteSessions

func (client *Client) WriteSessions(ctx context.Context, sessions []*model.Session) error

type Connection

type Connection[T interface{}] struct {
	Edges    []*Edge[T]
	PageInfo *modelInputs.PageInfo
}

type Edge

type Edge[T interface{}] struct {
	Cursor string
	Node   *T
}

type ErrorGroupOccurence

type ErrorGroupOccurence struct {
	FirstOccurrence time.Time
	LastOccurrence  time.Time
}

type Event

type Event struct {
	Timestamp  time.Time
	Name       string
	Attributes map[string]string
}

type FieldType

type FieldType string
type Link struct {
	TraceId    string
	SpanId     string
	TraceState string
	Attributes map[string]string
}

type LogRow

type LogRow struct {
	Timestamp       time.Time
	ProjectId       uint32
	TraceId         string
	SpanId          string
	SecureSessionId string
	UUID            string
	TraceFlags      uint32
	SeverityText    string
	SeverityNumber  int32
	Source          modelInputs.LogSource
	ServiceName     string
	ServiceVersion  string
	Body            string
	LogAttributes   map[string]string
	Environment     string
}

func NewLogRow

func NewLogRow(timestamp time.Time, projectID uint32, opts ...LogRowOption) *LogRow

func (*LogRow) Cursor

func (l *LogRow) Cursor() string

type LogRowOption

type LogRowOption func(*LogRow)

func WithBody

func WithBody(ctx context.Context, body string) LogRowOption

func WithEnvironment

func WithEnvironment(environment string) LogRowOption

func WithLogAttributes

func WithLogAttributes(attributes map[string]string) LogRowOption

func WithSecureSessionID

func WithSecureSessionID(secureSessionID string) LogRowOption

func WithServiceName

func WithServiceName(serviceName string) LogRowOption

func WithServiceVersion

func WithServiceVersion(version string) LogRowOption

func WithSeverityText

func WithSeverityText(severityText string) LogRowOption

func WithSource

func WithSource(source modelInputs.LogSource) LogRowOption

func WithSpanID

func WithSpanID(spanID string) LogRowOption

func WithTraceID

func WithTraceID(traceID string) LogRowOption

type Operator

type Operator string
const (
	Is             Operator = "is"
	Contains       Operator = "contains"
	Exists         Operator = "exists"
	Between        Operator = "between"
	BetweenTime    Operator = "between_time"
	BetweenDate    Operator = "between_date"
	Matches        Operator = "matches"
	IsNot          Operator = "is_not"
	NotContains    Operator = "not_contains"
	NotExists      Operator = "not_exists"
	NotBetween     Operator = "not_between"
	NotBetweenTime Operator = "not_between_time"
	NotBetweenDate Operator = "not_between_date"
	NotMatches     Operator = "not_matches"
)

type Pagination

type Pagination struct {
	After     *string
	Before    *string
	At        *string
	Direction modelInputs.SortDirection
	CountOnly bool
	Limit     *int
}

type ReadMetricsInput

type ReadMetricsInput struct {
	SampleableConfig   SampleableTableConfig
	ProjectIDs         []int
	Params             modelInputs.QueryInput
	GroupBy            []string
	BucketCount        *int
	BucketWindow       *int
	BucketBy           string
	Limit              *int
	LimitAggregator    *modelInputs.MetricAggregator
	LimitColumn        *string
	SavedMetricState   *SavedMetricState
	PredictionSettings *modelInputs.PredictionSettings
	NoBucketMax        bool
	Expressions        []*modelInputs.MetricExpressionInput
}

type Rule

type Rule struct {
	Field string
	Op    Operator
	Val   []string
}

type SampleableTableConfig

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

type SamplingStats

type SamplingStats struct {
	Database string `ch:"database"`
	Table    string `ch:"table"`
	Parts    uint64 `ch:"parts"`
	Rows     uint64 `ch:"rows"`
	Marks    uint64 `ch:"marks"`
}

type SavedMetricState

type SavedMetricState struct {
	MetricId        string
	BlockNumberInfo []BlockNumberInfo
}

type SessionEventRow

type SessionEventRow struct {
	UUID             string
	ProjectID        uint32
	SessionID        uint64
	SessionCreatedAt int64
	Timestamp        int64
	Event            string
	Attributes       map[string]string
}

type TimeUnit

type TimeUnit uint8
const (
	Seconds      TimeUnit = 0
	MilliSeconds TimeUnit = 3
	MicroSeconds TimeUnit = 6
	NanoSeconds  TimeUnit = 9
)

type TraceRow

type TraceRow struct {
	Timestamp       time.Time
	UUID            string
	TraceId         string
	SpanId          string
	ParentSpanId    string
	TraceState      string
	SpanName        string
	SpanKind        string
	ServiceName     string
	ServiceVersion  string
	TraceAttributes map[string]string
	Duration        int64
	StatusCode      string
	StatusMessage   string
	Events          []*Event
	Links           []*Link
	ProjectId       uint32
	SecureSessionId string
	Environment     string
	HasErrors       bool
}

func NewTraceRow

func NewTraceRow(timestamp time.Time, projectID int) *TraceRow

func (*TraceRow) AsClickhouseTraceRow

func (t *TraceRow) AsClickhouseTraceRow() *ClickhouseTraceRow

func (*TraceRow) WithDuration

func (t *TraceRow) WithDuration(startTime time.Time, endTime time.Time) *TraceRow

func (*TraceRow) WithEnvironment

func (t *TraceRow) WithEnvironment(environment string) *TraceRow

func (*TraceRow) WithEvents

func (t *TraceRow) WithEvents(events []map[string]any) *TraceRow

func (*TraceRow) WithHasErrors

func (t *TraceRow) WithHasErrors(hasErrors bool) *TraceRow
func (t *TraceRow) WithLinks(links []map[string]any) *TraceRow

func (*TraceRow) WithParentSpanId

func (t *TraceRow) WithParentSpanId(parentSpanId string) *TraceRow

func (*TraceRow) WithSecureSessionId

func (t *TraceRow) WithSecureSessionId(sessionId string) *TraceRow

func (*TraceRow) WithServiceName

func (t *TraceRow) WithServiceName(serviceName string) *TraceRow

func (*TraceRow) WithServiceVersion

func (t *TraceRow) WithServiceVersion(serviceVersion string) *TraceRow

func (*TraceRow) WithSpanId

func (t *TraceRow) WithSpanId(spanId string) *TraceRow

func (*TraceRow) WithSpanKind

func (t *TraceRow) WithSpanKind(spanKind string) *TraceRow

func (*TraceRow) WithSpanName

func (t *TraceRow) WithSpanName(spanName string) *TraceRow

func (*TraceRow) WithStatusCode

func (t *TraceRow) WithStatusCode(statusCode string) *TraceRow

func (*TraceRow) WithStatusMessage

func (t *TraceRow) WithStatusMessage(statusMessage string) *TraceRow

func (*TraceRow) WithTraceAttributes

func (t *TraceRow) WithTraceAttributes(attributes map[string]string) *TraceRow

func (*TraceRow) WithTraceId

func (t *TraceRow) WithTraceId(traceId string) *TraceRow

func (*TraceRow) WithTraceState

func (t *TraceRow) WithTraceState(traceState string) *TraceRow

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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