clickhouse

package
v0.0.0-...-53546a6 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 39 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 ErrorGroupsTable = "error_groups"
View Source
const ErrorObjectsTable = "error_objects"
View Source
const FieldsTable = "fields"
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 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 SamplingRows = 20_000_000
View Source
const SessionKeysTable = "session_keys"
View Source
const SessionsJoinedTable = "sessions_joined_vw"
View Source
const SessionsTable = "sessions"
View Source
const TraceAttributeValueLengthLimit = 2 << 15
View Source
const TraceKeyValuesTable = "trace_key_values"
View Source
const TraceKeysTable = "trace_keys"
View Source
const TraceMetricsTable = "trace_metrics"
View Source
const TracesByIdTable = "traces_by_id"
View Source
const TracesSamplingTable = "traces_sampling"
View Source
const TracesTable = "traces"

Variables

View Source
var (
	ServerAddr      = os.Getenv("CLICKHOUSE_ADDRESS")
	PrimaryDatabase = os.Getenv("CLICKHOUSE_DATABASE") // typically 'default', clickhouse needs an existing database to handle connections
	TestDatabase    = os.Getenv("CLICKHOUSE_TEST_DATABASE")
	Username        = os.Getenv("CLICKHOUSE_USERNAME")
	Password        = os.Getenv("CLICKHOUSE_PASSWORD")
)
View Source
var LogsTableConfig = model.TableConfig[modelInputs.ReservedLogKey]{
	TableName:        LogsTable,
	KeysToColumns:    logKeysToColumns,
	ReservedKeys:     modelInputs.AllReservedLogKey,
	BodyColumn:       "Body",
	SeverityColumn:   "SeverityText",
	AttributesColumn: "LogAttributes",
	SelectColumns: []string{
		"ProjectId",
		"Timestamp",
		"UUID",
		"SeverityText",
		"Body",
		"LogAttributes",
		"TraceId",
		"SpanId",
		"SecureSessionId",
		"Source",
		"ServiceName",
		"ServiceVersion",
		"Environment",
	},
}
View Source
var SessionsJoinedTableConfig = model.TableConfig[modelInputs.ReservedSessionKey]{
	TableName:        SessionsJoinedTable,
	AttributesColumn: "SessionAttributes",
	BodyColumn:       `concat(coalesce(nullif(SessionAttributes['email'],''), nullif(Identifier, ''), nullif(toString(Fingerprint), ''), 'unidentified'), ': ', City, if(City != '', ', ', ''), Country)`,
	KeysToColumns: map[modelInputs.ReservedSessionKey]string{
		modelInputs.ReservedSessionKeyActiveLength:       "ActiveLength",
		modelInputs.ReservedSessionKeyServiceVersion:     "AppVersion",
		modelInputs.ReservedSessionKeyBrowserName:        "BrowserName",
		modelInputs.ReservedSessionKeyBrowserVersion:     "BrowserVersion",
		modelInputs.ReservedSessionKeyCity:               "City",
		modelInputs.ReservedSessionKeyCountry:            "Country",
		modelInputs.ReservedSessionKeyEnvironment:        "Environment",
		modelInputs.ReservedSessionKeyExcluded:           "Excluded",
		modelInputs.ReservedSessionKeyDeviceID:           "Fingerprint",
		modelInputs.ReservedSessionKeyFirstTime:          "FirstTime",
		modelInputs.ReservedSessionKeyHasComments:        "HasComments",
		modelInputs.ReservedSessionKeyHasErrors:          "HasErrors",
		modelInputs.ReservedSessionKeyHasRageClicks:      "HasRageClicks",
		modelInputs.ReservedSessionKeyIdentified:         "Identified",
		modelInputs.ReservedSessionKeyIdentifier:         "Identifier",
		modelInputs.ReservedSessionKeyIP:                 "IP",
		modelInputs.ReservedSessionKeyLength:             "Length",
		modelInputs.ReservedSessionKeyNormalness:         "Normalness",
		modelInputs.ReservedSessionKeyOsName:             "OSName",
		modelInputs.ReservedSessionKeyOsVersion:          "OSVersion",
		modelInputs.ReservedSessionKeyPagesVisited:       "PagesVisited",
		modelInputs.ReservedSessionKeyProcessed:          "Processed",
		modelInputs.ReservedSessionKeySecureID:           "SecureID",
		modelInputs.ReservedSessionKeyLocState:           "State",
		modelInputs.ReservedSessionKeyViewed:             "Viewed",
		modelInputs.ReservedSessionKeyWithinBillingQuota: "WithinBillingQuota",
	},
	ReservedKeys: modelInputs.AllReservedSessionKey,
	IgnoredFilters: map[string]bool{
		modelInputs.ReservedSessionKeySample.String():     true,
		modelInputs.ReservedSessionKeyViewedByMe.String(): true,
	},
}
View Source
var SessionsTableConfig = model.TableConfig[string]{
	TableName:        SessionsTable,
	KeysToColumns:    fieldMap,
	AttributesColumn: "Fields",
	ReservedKeys: lo.Map(modelInputs.AllReservedSessionKey, func(item modelInputs.ReservedSessionKey, _ int) string {
		return item.String()
	}),
}
View Source
var TracesTableConfig = model.TableConfig[modelInputs.ReservedTraceKey]{
	TableName:        TracesTableNoDefaultConfig.TableName,
	KeysToColumns:    TracesTableNoDefaultConfig.KeysToColumns,
	ReservedKeys:     TracesTableNoDefaultConfig.ReservedKeys,
	BodyColumn:       TracesTableNoDefaultConfig.BodyColumn,
	AttributesColumn: TracesTableNoDefaultConfig.AttributesColumn,
	SelectColumns:    TracesTableNoDefaultConfig.SelectColumns,
	DefaultFilter:    fmt.Sprintf("%s!=%s %s!=%s", modelInputs.ReservedTraceKeySpanName, highlight.MetricSpanName, highlight.TraceTypeAttribute, highlight.TraceTypeHighlightInternal),
}
View Source
var TracesTableNoDefaultConfig = model.TableConfig[modelInputs.ReservedTraceKey]{
	TableName:        TracesTable,
	KeysToColumns:    traceKeysToColumns,
	ReservedKeys:     modelInputs.AllReservedTraceKey,
	BodyColumn:       "SpanName",
	AttributesColumn: "TraceAttributes",
	SelectColumns:    traceColumns,
}

Functions

func ErrorMatchesQuery

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

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) ([]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) ([]*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 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
}

type ClickhouseSession

type ClickhouseSession struct {
	ID                 int64
	Fingerprint        int32
	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  clickhouse.ArraySet `ch:"Events.Timestamp"`
	EventsName       clickhouse.ArraySet `ch:"Events.Name"`
	EventsAttributes clickhouse.ArraySet `ch:"Events.Attributes"`
	LinksTraceId     clickhouse.ArraySet `ch:"Links.TraceId"`
	LinksSpanId      clickhouse.ArraySet `ch:"Links.SpanId"`
	LinksTraceState  clickhouse.ArraySet `ch:"Links.TraceState"`
	LinksAttributes  clickhouse.ArraySet `ch:"Links.Attributes"`
}

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) BatchWriteLogRows

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

func (*Client) BatchWriteTraceRows

func (client *Client) BatchWriteTraceRows(ctx context.Context, traceRows []*TraceRow) 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) ([]string, error)

func (*Client) ErrorsLogLines

func (client *Client) ErrorsLogLines(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) GetConn

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

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) ([]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) 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, errorGroupId int) (*time.Time, *time.Time, 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) QueryErrorObjectsHistogram

func (client *Client) QueryErrorObjectsHistogram(ctx context.Context, projectId int, params modelInputs.QueryInput, options modelInputs.DateHistogramOptions) ([]time.Time, []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, 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, 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, column string, metricTypes []modelInputs.MetricAggregator, groupBy []string, nBuckets *int, bucketBy string, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string) (*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, column string, metricTypes []modelInputs.MetricAggregator, groupBy []string, nBuckets *int, bucketBy string, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadLogsTotalCount

func (client *Client) ReadLogsTotalCount(ctx context.Context, projectID int, params modelInputs.QueryInput) (uint64, 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, column string, metricTypes []modelInputs.MetricAggregator, groupBy []string, nBuckets *int, bucketBy string, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadTrace

func (client *Client) ReadTrace(ctx context.Context, projectID int, traceID string) ([]*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, column string, metricTypes []modelInputs.MetricAggregator, groupBy []string, nBuckets *int, bucketBy string, limit *int, limitAggregator *modelInputs.MetricAggregator, limitColumn *string) (*modelInputs.MetricsBuckets, error)

func (*Client) ReadWorkspaceErrorCounts

func (client *Client) ReadWorkspaceErrorCounts(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) 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) ([]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) ([]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) TracesMetrics

func (client *Client) TracesMetrics(ctx context.Context, projectID int, startDate time.Time, endDate time.Time, query *string) ([]*modelInputs.QueryKey, 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 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
}

type Rule

type Rule struct {
	Field string
	Op    Operator
	Val   []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) 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