Documentation ¶
Index ¶
- Constants
- Variables
- func BuildDSN(conf *bunconf.Config, token string) string
- func BuildFacetMap(items []*FacetItem) map[string]*Facet
- func CompareAttrs(a, b string) int
- func ContextWithAnnotation(ctx context.Context, ann *Annotation) context.Context
- func ContextWithProject(ctx context.Context, project *Project) context.Context
- func ContextWithUser(ctx context.Context, user *User) context.Context
- func CreateAchievementOnce(ctx context.Context, app *bunapp.App, achievement *Achievement)
- func DSNFromMetadata(ctx context.Context) (string, error)
- func DSNFromRequest(req bunrouter.Request, extraHeaders ...string) (string, error)
- func GetOrCreateUser(ctx context.Context, app *bunapp.App, user *User) error
- func GroupingInterval(f *TimeFilter) (tableResolution, groupingInterval time.Duration)
- func GroupingIntervalLarge(gte, lt time.Time) time.Duration
- func GroupingIntervalSmall(gte, lt time.Time) time.Duration
- func Init(ctx context.Context, app *bunapp.App)
- func InsertAlert(ctx context.Context, app *bunapp.App, db bun.IDB, alert Alert) (bool, error)
- func InsertAlertEvent(ctx context.Context, db bun.IDB, event AlertEvent) error
- func InsertMonitor(ctx context.Context, db bun.IDB, monitor Monitor) error
- func PauseMonitor(ctx context.Context, app *bunapp.App, monitorID uint64) error
- func SelectPinnedFacetMap(ctx context.Context, app *bunapp.App, userID uint64) (map[string]bool, error)
- func SelectPinnedFacets(ctx context.Context, app *bunapp.App, userID uint64) ([]string, error)
- func TableWhereResolution(f *TimeFilter) time.Duration
- func UpdateMonitorState(ctx context.Context, app *bunapp.App, monitorID uint64, ...) error
- func UpsertAchievement(ctx context.Context, app *bunapp.App, achievement *Achievement) error
- type Achievement
- type AchievementHandler
- type Alert
- type AlertEvent
- type AlertEventName
- type AlertStatus
- type AlertType
- type Annotation
- type AnnotationFilter
- type AnnotationHandler
- func (h *AnnotationHandler) AnnotationMiddleware(next bunrouter.HandlerFunc) bunrouter.HandlerFunc
- func (h *AnnotationHandler) Create(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AnnotationHandler) CreatePublic(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AnnotationHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AnnotationHandler) List(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AnnotationHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AnnotationHandler) Update(w http.ResponseWriter, req bunrouter.Request) error
- type AnnotationIn
- type AttrMatcher
- type AttrMatcherOp
- type BaseAlert
- type BaseAlertEvent
- type BaseMonitor
- type CloudflareProvider
- type DSN
- type ErrorAlertParams
- type ErrorMonitor
- type ErrorMonitorParams
- type Facet
- type FacetFilter
- type FacetItem
- type JWTProvider
- type MetricMonitor
- type MetricMonitorParams
- type Middleware
- type Monitor
- type MonitorChannel
- type MonitorState
- type MonitorType
- type OrderByMixin
- func (f *OrderByMixin) CHOrder(q *ch.SelectQuery) *ch.SelectQuery
- func (f OrderByMixin) MarshalJSON() ([]byte, error)
- func (f *OrderByMixin) PGOrder(q *bun.SelectQuery) *bun.SelectQuery
- func (f *OrderByMixin) Reset()
- func (f OrderByMixin) SortDir() string
- func (f *OrderByMixin) UnmarshalValues(ctx context.Context, values url.Values) error
- type PinnedFacet
- type PinnedFacetHandler
- type Project
- func ProjectFromContext(ctx context.Context) *Project
- func ProjectFromRequest(app *bunapp.App, req bunrouter.Request) (*Project, error)
- func SelectProject(ctx context.Context, app *bunapp.App, projectID uint32) (*Project, error)
- func SelectProjectByDSN(ctx context.Context, app *bunapp.App, dsnStr string) (*Project, error)
- func SelectProjectByToken(ctx context.Context, app *bunapp.App, token string) (*Project, error)
- func SelectProjects(ctx context.Context, app *bunapp.App) ([]*Project, error)
- type ProjectHandler
- type SSOHandler
- type SSOMethod
- type SSOMethodHandler
- type TimeFilter
- type TrackableModel
- type Usage
- type Usage2
- type UsageHandler
- type User
- func NewUserFromConfig(src *bunconf.User) (*User, error)
- func SelectUser(ctx context.Context, app *bunapp.App, id uint64) (*User, error)
- func SelectUserByEmail(ctx context.Context, app *bunapp.App, email string) (*User, error)
- func SelectUserByToken(ctx context.Context, app *bunapp.App, token string) (*User, error)
- func UserFromContext(ctx context.Context) *User
- type UserHandler
- type UserProjectData
- type UserProvider
Constants ¶
View Source
const ( AchievConfigureTracing = "configure-tracing" AchievConfigureMetrics = "configure-metrics" AchievInstallCollector = "install-collector" AchievCreateMetricMonitor = "create-metric-monitor" )
View Source
const ( AttrEqual = "=" AttrNotEqual = "!=" )
Variables ¶
View Source
var ( ErrAccessDenied = httperror.Forbidden("access denied") ErrProjectNotFound = httperror.NotFound("project not found") )
View Source
var CreateErrorAlertTask = taskq.NewTask("create-error-alert")
Functions ¶
func BuildFacetMap ¶
func CompareAttrs ¶
func ContextWithAnnotation ¶
func ContextWithAnnotation(ctx context.Context, ann *Annotation) context.Context
func ContextWithProject ¶
func CreateAchievementOnce ¶
func CreateAchievementOnce( ctx context.Context, app *bunapp.App, achievement *Achievement, )
func DSNFromRequest ¶
func GroupingInterval ¶
func GroupingInterval(f *TimeFilter) (tableResolution, groupingInterval time.Duration)
func InsertAlert ¶
func InsertAlertEvent ¶
func SelectPinnedFacetMap ¶
func SelectPinnedFacets ¶
func TableWhereResolution ¶
func TableWhereResolution(f *TimeFilter) time.Duration
func UpdateMonitorState ¶
func UpsertAchievement ¶
Types ¶
type Achievement ¶
type Achievement struct { bun.BaseModel `bun:"achievements,alias:a"` ID uint64 `json:"id" bun:",pk,autoincrement"` UserID uint64 `json:"-" bun:",nullzero"` ProjectID uint32 `json:"-" bun:",nullzero"` Name string `json:"name"` }
func SelectAchievements ¶
type AchievementHandler ¶
func NewAchievementHandler ¶
func NewAchievementHandler(app *bunapp.App) *AchievementHandler
func (*AchievementHandler) List ¶
func (h *AchievementHandler) List(w http.ResponseWriter, req bunrouter.Request) error
type Alert ¶
type Alert interface { Base() *BaseAlert GetEvent() AlertEvent SetEvent(event AlertEvent) URL() string Muted() bool }
type AlertEvent ¶
type AlertEvent interface { Validate() error Base() *BaseAlertEvent Clone() AlertEvent }
type AlertEventName ¶
type AlertEventName string
const ( AlertEventCreated AlertEventName = "created" AlertEventStatusChanged AlertEventName = "status-changed" AlertEventRecurring AlertEventName = "recurring" )
type AlertStatus ¶
type AlertStatus string
const ( AlertStatusOpen AlertStatus = "open" AlertStatusClosed AlertStatus = "closed" )
type Annotation ¶
type Annotation struct { bun.BaseModel `bun:"alias:e"` ID uint64 `json:"id" bun:",pk,autoincrement"` ProjectID uint32 `json:"projectId"` Hash uint64 `json:"-" bun:",nullzero"` Name string `json:"name"` Description string `json:"description"` Color string `json:"color"` Attrs map[string]string `json:"attrs"` CreatedAt time.Time `json:"createdAt" bun:",nullzero"` }
func AnnotationFromContext ¶
func AnnotationFromContext(ctx context.Context) *Annotation
type AnnotationFilter ¶
type AnnotationFilter struct { ProjectID uint32 `urlstruct:"-"` TimeFilter urlstruct.Pager OrderByMixin }
func (*AnnotationFilter) UnmarshalValues ¶
func (*AnnotationFilter) WhereClause ¶
func (f *AnnotationFilter) WhereClause(q *bun.SelectQuery) *bun.SelectQuery
type AnnotationHandler ¶
func NewAnnotationHandler ¶
func NewAnnotationHandler(app *bunapp.App) *AnnotationHandler
func (*AnnotationHandler) AnnotationMiddleware ¶
func (h *AnnotationHandler) AnnotationMiddleware(next bunrouter.HandlerFunc) bunrouter.HandlerFunc
func (*AnnotationHandler) Create ¶
func (h *AnnotationHandler) Create(w http.ResponseWriter, req bunrouter.Request) error
func (*AnnotationHandler) CreatePublic ¶
func (h *AnnotationHandler) CreatePublic(w http.ResponseWriter, req bunrouter.Request) error
func (*AnnotationHandler) Delete ¶
func (h *AnnotationHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
func (*AnnotationHandler) List ¶
func (h *AnnotationHandler) List(w http.ResponseWriter, req bunrouter.Request) error
func (*AnnotationHandler) Show ¶
func (h *AnnotationHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
func (*AnnotationHandler) Update ¶
func (h *AnnotationHandler) Update(w http.ResponseWriter, req bunrouter.Request) error
type AnnotationIn ¶
type AnnotationIn struct { Name string `json:"name"` Description string `json:"description"` Fingerprint string `json:"fingerprint"` Color string `json:"color"` Attrs map[string]string `json:"attrs"` Time time.Time `json:"time"` }
func (*AnnotationIn) Validate ¶
func (in *AnnotationIn) Validate(ann *Annotation) error
type AttrMatcher ¶
type AttrMatcher struct { Attr string `json:"attr"` Op AttrMatcherOp `json:"op"` Value string `json:"value"` }
type AttrMatcherOp ¶
type AttrMatcherOp string
type BaseAlert ¶
type BaseAlert struct { bun.BaseModel `bun:"alerts,alias:a"` ID uint64 `json:"id" bun:",pk,autoincrement"` ProjectID uint32 `json:"projectId"` EventID uint64 `json:"-" bun:",nullzero"` Event *BaseAlertEvent `json:"-" bun:"rel:belongs-to,join:event_id=id"` Name string `json:"name"` Attrs map[string]string `json:"attrs"` AttrsHash uint64 `json:"-"` Type AlertType `json:"type"` SpanGroupID uint64 `json:"spanGroupId,string" bun:",nullzero"` MonitorID uint64 `json:"monitorId" bun:",nullzero"` CreatedAt time.Time `json:"createdAt" bun:",nullzero"` MutedUntil time.Time `json:"mutedUntil" bun:",nullzero"` }
func NewBaseAlert ¶
func (*BaseAlert) MarshalJSON ¶
type BaseAlertEvent ¶ added in v1.7.0
type BaseAlertEvent struct { bun.BaseModel `bun:"alert_events,alias:e"` ID uint64 `bun:",pk,autoincrement"` UserID uint64 `bun:",nullzero"` User *User `bun:"rel:belongs-to,join:user_id=id"` ProjectID uint32 AlertID uint64 Alert *BaseAlert `bun:"rel:belongs-to,join:alert_id=id"` Name AlertEventName Status AlertStatus Params bunutil.Params `bun:"type:jsonb,nullzero"` // immutable Time time.Time `bun:",nullzero"` CreatedAt time.Time `bun:",nullzero"` }
func (*BaseAlertEvent) Validate ¶ added in v1.7.0
func (e *BaseAlertEvent) Validate() error
type BaseMonitor ¶
type BaseMonitor struct { bun.BaseModel `bun:"monitors,alias:m"` ID uint64 `json:"id,string" bun:",pk,autoincrement"` ProjectID uint32 `json:"projectId"` Name string `json:"name"` State MonitorState `json:"state"` NotifyEveryoneByEmail bool `json:"notifyEveryoneByEmail"` Type MonitorType `json:"type"` Params bunutil.Params `json:"params"` CreatedAt time.Time `json:"createdAt" bun:",nullzero"` UpdatedAt bun.NullTime `json:"updatedAt"` ChannelIDs []uint64 `json:"channelIds" bun:"-"` AlertCount int `json:"alertCount" bun:"-"` }
func SelectBaseMonitor ¶
func (*BaseMonitor) Validate ¶
func (m *BaseMonitor) Validate() error
type CloudflareProvider ¶
type CloudflareProvider struct {
// contains filtered or unexported fields
}
Adapted from https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/validating-json/
func NewCloudflareProvider ¶
func NewCloudflareProvider(conf *bunconf.CloudflareProvider) *CloudflareProvider
type DSN ¶
type ErrorAlertParams ¶
type ErrorAlertParams struct { TraceID idgen.TraceID `json:"traceId"` SpanID idgen.SpanID `json:"spanId"` SpanCount int64 `json:"spanCount"` }
func (*ErrorAlertParams) Clone ¶
func (p *ErrorAlertParams) Clone() *ErrorAlertParams
type ErrorMonitor ¶
type ErrorMonitor struct { *BaseMonitor `bun:",inherit"` Params ErrorMonitorParams `json:"params"` }
func NewErrorMonitor ¶
func NewErrorMonitor() *ErrorMonitor
func (*ErrorMonitor) Base ¶
func (m *ErrorMonitor) Base() *BaseMonitor
func (*ErrorMonitor) Validate ¶
func (m *ErrorMonitor) Validate() error
type ErrorMonitorParams ¶
type ErrorMonitorParams struct { NotifyOnNewErrors bool `json:"notifyOnNewErrors"` NotifyOnRecurringErrors bool `json:"notifyOnRecurringErrors"` Matchers []AttrMatcher `json:"matchers"` }
type Facet ¶
func FacetMapToList ¶
type FacetFilter ¶
func (*FacetFilter) UnmarshalValues ¶
func (*FacetFilter) WhereClause ¶
func (f *FacetFilter) WhereClause(q *bun.SelectQuery) *bun.SelectQuery
type JWTProvider ¶
type JWTProvider struct {
// contains filtered or unexported fields
}
func NewJWTProvider ¶
func NewJWTProvider(app *bunapp.App, secretKey string) *JWTProvider
type MetricMonitor ¶
type MetricMonitor struct { *BaseMonitor `bun:",inherit"` Params MetricMonitorParams `json:"params"` }
func NewMetricMonitor ¶
func NewMetricMonitor() *MetricMonitor
func (*MetricMonitor) Base ¶
func (m *MetricMonitor) Base() *BaseMonitor
func (*MetricMonitor) MadalarmOptions ¶
func (m *MetricMonitor) MadalarmOptions() ([]madalarm.Option, error)
func (*MetricMonitor) Validate ¶
func (m *MetricMonitor) Validate() error
type MetricMonitorParams ¶
type MetricMonitorParams struct { Metrics []mql.MetricAlias `json:"metrics"` Query string `json:"query"` Column string `json:"column"` ColumnUnit string `json:"columnUnit"` CheckNumPoint int `json:"checkNumPoint"` TimeOffset unixtime.Millis `json:"timeOffset"` MinAllowedValue bunutil.NullFloat64 `json:"minAllowedValue"` MaxAllowedValue bunutil.NullFloat64 `json:"maxAllowedValue"` }
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(app *bunapp.App) *Middleware
func (*Middleware) User ¶
func (m *Middleware) User(next bunrouter.HandlerFunc) bunrouter.HandlerFunc
func (*Middleware) UserAndProject ¶
func (m *Middleware) UserAndProject(next bunrouter.HandlerFunc) bunrouter.HandlerFunc
type Monitor ¶
type Monitor interface {
Base() *BaseMonitor
}
func DecodeMonitor ¶
func DecodeMonitor(base *BaseMonitor) (Monitor, error)
type MonitorChannel ¶
type MonitorState ¶
type MonitorState string
const ( MonitorActive MonitorState = "active" MonitorPaused MonitorState = "paused" MonitorFiring MonitorState = "firing" MonitorNoData MonitorState = "no-data" MonitorFailed MonitorState = "failed" )
type MonitorType ¶
type MonitorType string
const ( MonitorMetric MonitorType = "metric" MonitorError MonitorType = "error" )
type OrderByMixin ¶
func (*OrderByMixin) CHOrder ¶
func (f *OrderByMixin) CHOrder(q *ch.SelectQuery) *ch.SelectQuery
func (OrderByMixin) MarshalJSON ¶
func (f OrderByMixin) MarshalJSON() ([]byte, error)
func (*OrderByMixin) PGOrder ¶
func (f *OrderByMixin) PGOrder(q *bun.SelectQuery) *bun.SelectQuery
func (*OrderByMixin) Reset ¶
func (f *OrderByMixin) Reset()
func (OrderByMixin) SortDir ¶
func (f OrderByMixin) SortDir() string
func (*OrderByMixin) UnmarshalValues ¶
type PinnedFacet ¶
type PinnedFacetHandler ¶
func NewPinnedFacetHandler ¶
func NewPinnedFacetHandler(app *bunapp.App) *PinnedFacetHandler
func (*PinnedFacetHandler) Add ¶
func (h *PinnedFacetHandler) Add(w http.ResponseWriter, req bunrouter.Request) error
func (*PinnedFacetHandler) List ¶
func (h *PinnedFacetHandler) List(w http.ResponseWriter, req bunrouter.Request) error
func (*PinnedFacetHandler) Remove ¶
func (h *PinnedFacetHandler) Remove(w http.ResponseWriter, req bunrouter.Request) error
type Project ¶
type Project struct { bun.BaseModel `bun:"projects,alias:p"` ID uint32 `json:"id" bun:",pk,autoincrement"` Name string `json:"name" bun:",nullzero"` Token string `json:"token" bun:",nullzero"` PinnedAttrs []string `json:"pinnedAttrs" bun:",array"` GroupByEnv bool `json:"groupByEnv"` GroupFuncsByService bool `json:"groupFuncsByService"` PromCompat bool `json:"promCompat"` ForceSpanName []string `json:"forceSpanName" bun:",array"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
func ProjectFromContext ¶
func ProjectFromRequest ¶
func SelectProject ¶
func SelectProjectByDSN ¶
func SelectProjectByToken ¶
func (*Project) EmailSettingsURL ¶
func (*Project) SettingsURL ¶
type ProjectHandler ¶
func NewProjectHandler ¶
func NewProjectHandler(app *bunapp.App) *ProjectHandler
func (*ProjectHandler) Show ¶
func (h *ProjectHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
type SSOHandler ¶
func NewSSOHandler ¶
func NewSSOHandler(app *bunapp.App, router *bunrouter.Group) *SSOHandler
func (*SSOHandler) ListMethods ¶
func (h *SSOHandler) ListMethods(w http.ResponseWriter, req bunrouter.Request) error
type SSOMethodHandler ¶
func NewSSOMethodHandler ¶
func NewSSOMethodHandler( app *bunapp.App, conf *bunconf.OIDCProvider, ) (*SSOMethodHandler, error)
func (*SSOMethodHandler) Callback ¶
func (h *SSOMethodHandler) Callback(w http.ResponseWriter, req bunrouter.Request) error
func (*SSOMethodHandler) Start ¶
func (h *SSOMethodHandler) Start(w http.ResponseWriter, req bunrouter.Request) error
type TimeFilter ¶
type TimeFilter struct { TimeGTE time.Time TimeLT time.Time TimeOffset unixtime.Millis Interval unixtime.Millis MinInterval unixtime.Millis }
func (*TimeFilter) Duration ¶
func (f *TimeFilter) Duration() time.Duration
func (*TimeFilter) GroupingInterval ¶
func (f *TimeFilter) GroupingInterval() time.Duration
func (*TimeFilter) IsZero ¶
func (f *TimeFilter) IsZero() bool
func (*TimeFilter) Round ¶
func (f *TimeFilter) Round(d time.Duration)
func (*TimeFilter) UnmarshalValues ¶
type TrackableModel ¶
type TrackableModel string
const ( ModelUser TrackableModel = "User" ModelProject TrackableModel = "Project" ModelSpan TrackableModel = "Span" ModelSpanGroup TrackableModel = "SpanGroup" )
type UsageHandler ¶ added in v1.7.0
func NewUsageHandler ¶ added in v1.7.0
func NewUsageHandler(app *bunapp.App) *UsageHandler
func (*UsageHandler) Show ¶ added in v1.7.0
func (h *UsageHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
type User ¶
type User struct { bun.BaseModel `bun:"users,alias:u"` ID uint64 `json:"id" bun:",pk,autoincrement"` Email string `json:"email" bun:",nullzero"` Password string `json:"-" bun:"-"` Name string `json:"name" bun:",nullzero"` Avatar string `json:"avatar" bun:",nullzero"` NotifyByEmail bool `json:"notifyByEmail"` AuthToken string `json:"authToken"` CreatedAt time.Time `json:"createdAt" bun:",nullzero"` UpdatedAt time.Time `json:"updatedAt" bun:",nullzero"` }
func SelectUserByEmail ¶
func SelectUserByToken ¶ added in v1.7.0
func UserFromContext ¶
func (*User) SetPassword ¶
type UserHandler ¶
func NewUserHandler ¶
func NewUserHandler(app *bunapp.App) *UserHandler
func (*UserHandler) Current ¶
func (h *UserHandler) Current(w http.ResponseWriter, req bunrouter.Request) error
func (*UserHandler) Login ¶
func (h *UserHandler) Login(w http.ResponseWriter, req bunrouter.Request) error
func (*UserHandler) Logout ¶
func (h *UserHandler) Logout(w http.ResponseWriter, req bunrouter.Request) error
type UserProjectData ¶
Source Files ¶
- achievement.go
- achievement_handler.go
- alert.go
- alert_event.go
- annotation.go
- annotation_filter.go
- annotation_handler.go
- auth.go
- dsn.go
- filters.go
- init.go
- monitor.go
- pinned_facet.go
- pinned_facet_handler.go
- project.go
- project_handler.go
- sso_handler.go
- usage_handler.go
- user.go
- user_handler.go
- user_project_data.go
- user_provider.go
- util.go
Click to show internal directories.
Click to hide internal directories.