Documentation
¶
Index ¶
- Constants
- Variables
- func DescribeErrorTrackingIssue(issue ErrorTrackingIssue, alert AlertDetails) string
- func IssueHasWorkOrder(tx *gorm.DB, factory *models.Factory, issueID string) (bool, error)
- func IssueIDFromEventData(eventData any) (string, bool)
- func IssueIDFromURL(rawURL string) (string, bool)
- func ReceiptIDFromEventData(eventData any) (uuid.UUID, bool)
- func ReleaseRetiredIntakeMonitor(ctx core.TriggerContext) error
- func WebhookRequestAuthenticated(integration core.IntegrationContext, request *http.Request) bool
- func WithWebhookReceipt(r *http.Request, state *WebhookReceiptState) *http.Request
- type APIError
- type AlertDetails
- type Client
- func (c *Client) CreateEvent(req CreateEventRequest) (*Event, error)
- func (c *Client) CreateMonitor(monitor Monitor) (*Monitor, error)
- func (c *Client) DeleteMonitor(id int64) error
- func (c *Client) DeleteWebhook(name string) error
- func (c *Client) GetErrorTrackingIssue(issueID string) (*ErrorTrackingIssue, error)
- func (c *Client) GetMonitor(id int64) (*Monitor, error)
- func (c *Client) IssueURL(issueID string) string
- func (c *Client) ListEnvironments(service string) ([]string, error)
- func (c *Client) ListServices() ([]string, error)
- func (c *Client) LoadErrorTrackingIssue(issueID string, warn func(string, ...any)) (*ErrorTrackingIssue, error)
- func (c *Client) LogsURL(query string, from, to time.Time) string
- func (c *Client) SearchErrorTrackingIssues(query string, limit int) ([]ErrorTrackingIssue, error)
- func (c *Client) SearchMonitors(query string) ([]Monitor, error)
- func (c *Client) SetRequestDeadline(deadline time.Time)
- func (c *Client) TraceURL(traceID string) string
- func (c *Client) UpdateMonitor(id int64, monitor Monitor) (*Monitor, error)
- func (c *Client) UpsertWebhook(config WebhookConfiguration) error
- func (c *Client) ValidateCredentials() error
- type Configuration
- type CreateEvent
- func (c *CreateEvent) Cancel(ctx core.ExecutionContext) error
- func (c *CreateEvent) Cleanup(ctx core.SetupContext) error
- func (c *CreateEvent) Color() string
- func (c *CreateEvent) Configuration() []configuration.Field
- func (c *CreateEvent) Description() string
- func (c *CreateEvent) Documentation() string
- func (c *CreateEvent) ExampleOutput() map[string]any
- func (c *CreateEvent) Execute(ctx core.ExecutionContext) error
- func (c *CreateEvent) HandleHook(ctx core.ActionHookContext) error
- func (c *CreateEvent) HandleWebhook(ctx core.WebhookRequestContext) (int, *core.WebhookResponseBody, error)
- func (c *CreateEvent) Hooks() []core.Hook
- func (c *CreateEvent) Icon() string
- func (c *CreateEvent) Label() string
- func (c *CreateEvent) Name() string
- func (c *CreateEvent) OutputChannels(configuration any) []core.OutputChannel
- func (c *CreateEvent) Setup(ctx core.SetupContext) error
- type CreateEventRequest
- type CreateEventResponse
- type CreateEventSpec
- type Datadog
- func (d *Datadog) Actions() []core.Action
- func (d *Datadog) Cleanup(ctx core.IntegrationCleanupContext) error
- func (d *Datadog) Configuration() []configuration.Field
- func (d *Datadog) Description() string
- func (d *Datadog) HandleHook(ctx core.IntegrationHookContext) error
- func (d *Datadog) HandleRequest(ctx core.HTTPRequestContext)
- func (d *Datadog) Hooks() []core.Hook
- func (d *Datadog) Icon() string
- func (d *Datadog) Instructions() string
- func (d *Datadog) Label() string
- func (d *Datadog) ListResources(resourceType string, ctx core.ListResourcesContext) ([]core.IntegrationResource, error)
- func (d *Datadog) Name() string
- func (d *Datadog) Sync(ctx core.SyncContext) error
- func (d *Datadog) Triggers() []core.Trigger
- type ErrorSample
- type ErrorTrackingAlertPayload
- type ErrorTrackingIssue
- type ErrorTrackingRegression
- type Event
- type LogLine
- type Monitor
- type MonitorOptions
- type MonitorThresholds
- type OnErrorTrackingAlert
- func (t *OnErrorTrackingAlert) Cleanup(ctx core.TriggerContext) error
- func (t *OnErrorTrackingAlert) Color() string
- func (t *OnErrorTrackingAlert) Configuration() []configuration.Field
- func (t *OnErrorTrackingAlert) Description() string
- func (t *OnErrorTrackingAlert) Documentation() string
- func (t *OnErrorTrackingAlert) ExampleData() map[string]any
- func (t *OnErrorTrackingAlert) HandleHook(ctx core.TriggerHookContext) (map[string]any, error)
- func (t *OnErrorTrackingAlert) HandleWebhook(ctx core.WebhookRequestContext) (int, *core.WebhookResponseBody, error)
- func (t *OnErrorTrackingAlert) Hooks() []core.Hook
- func (t *OnErrorTrackingAlert) Icon() string
- func (t *OnErrorTrackingAlert) Label() string
- func (t *OnErrorTrackingAlert) Name() string
- func (t *OnErrorTrackingAlert) OnIntegrationMessage(ctx core.IntegrationMessageContext) error
- func (t *OnErrorTrackingAlert) Setup(ctx core.TriggerContext) error
- type OnErrorTrackingAlertConfiguration
- type OnErrorTrackingAlertMetadata
- type SubscriptionConfiguration
- type WebhookConfiguration
- type WebhookReceiptState
- type WebhookSummary
Constants ¶
const ( ResourceTypeListNotice = "list-notice" ListNoticeIssueSearchFailed = "issue-search-failed" )
const ( IntegrationWebhookName = "superplane" WebhookSecretName = "webhookToken" WebhookHeaderName = "X-SuperPlane-Token" ErrorTrackingAlertEventType = "error_tracking_alert" AlertTransitionTriggered = "Triggered" AlertTransitionRetriggered = "Re-Triggered" )
const ErrorTrackingAlertPayloadType = "datadog.errorTrackingAlert"
const ErrorTrackingForbiddenMessage = "Datadog refused the request. The application key needs error_tracking_read."
ErrorTrackingForbiddenMessage is the user-facing text for ErrErrorTrackingForbidden.
const (
MonitorsWriteForbiddenMessage = "Datadog refused the request. The application key needs monitors_write."
)
const ReceiptField = "superplaneReceiptId"
ReceiptField is the canvas payload key for the stored receipt ID. Work order source payloads omit this key.
const (
ResourceTypeEnvironment = "environment"
)
const ResourceTypeService = "service"
Variables ¶
var ErrErrorTrackingForbidden = errors.New(
"datadog refused the request: the application key needs error_tracking_read",
)
ErrErrorTrackingForbidden is returned when Datadog refuses an Error Tracking call, usually because a restricted application key lacks error_tracking_read.
Functions ¶
func DescribeErrorTrackingIssue ¶
func DescribeErrorTrackingIssue(issue ErrorTrackingIssue, alert AlertDetails) string
DescribeErrorTrackingIssue renders the issue and the alert as task markdown. Empty sections are omitted. The result stays within the work order limit.
func IssueHasWorkOrder ¶
IssueHasWorkOrder reports whether this factory already has a work order for the Error Tracking issue. Matching covers every work-order state.
func IssueIDFromEventData ¶
IssueIDFromEventData reads the Error Tracking issue id from a canvas root event envelope. Seeded issues carry the issue page in link. A monitor alert link does not.
func IssueIDFromURL ¶
IssueIDFromURL reads the Error Tracking issue id from a Datadog issue page.
func ReceiptIDFromEventData ¶
ReceiptIDFromEventData reads the SuperPlane webhook receipt ID stored on a datadog.errorTrackingAlert canvas event. Datadog does not send this field.
func ReleaseRetiredIntakeMonitor ¶
func ReleaseRetiredIntakeMonitor(ctx core.TriggerContext) error
ReleaseRetiredIntakeMonitor deletes the monitor stored on an intake that was already removed. The intake is no longer in the active count.
func WebhookRequestAuthenticated ¶
func WebhookRequestAuthenticated(integration core.IntegrationContext, request *http.Request) bool
WebhookRequestAuthenticated reports whether the request carries this integration's webhook token.
func WithWebhookReceipt ¶
func WithWebhookReceipt(r *http.Request, state *WebhookReceiptState) *http.Request
Types ¶
type AlertDetails ¶
type AlertDetails struct {
Title string
Body string
EventMessage string
Link string
Tags string
AlertScope string
AlertQuery string
AggregKey string
}
AlertDetails is the monitor text that arrived with an Error Tracking alert.
type Client ¶
type Client struct {
APIKey string
AppKey string
Site string
BaseURL string
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(httpCtx core.HTTPContext, ctx core.IntegrationContext) (*Client, error)
func (*Client) CreateEvent ¶
func (c *Client) CreateEvent(req CreateEventRequest) (*Event, error)
CreateEvent creates a new event in Datadog.
func (*Client) DeleteMonitor ¶
func (*Client) DeleteWebhook ¶
func (*Client) GetErrorTrackingIssue ¶
func (c *Client) GetErrorTrackingIssue(issueID string) (*ErrorTrackingIssue, error)
GetErrorTrackingIssue loads one Error Tracking issue by id.
func (*Client) ListEnvironments ¶
ListEnvironments returns distinct env tag values seen on spans, then logs, for the last 30 days. service narrows the query when it is set.
func (*Client) ListServices ¶
ListServices returns service names seen in spans or logs in the last 30 days, plus services on open Error Tracking issues. The three reads run together under one time limit. A refused or failed telemetry query is skipped. A refused issue search is skipped when another source succeeds. Any other issue search failure keeps telemetry names when one exists, so a temporary error does not hide those services. That result includes ListNoticeIssueSearchFailed so the missing names are not silent. The list fails when that search fails and no telemetry name is available.
func (*Client) LoadErrorTrackingIssue ¶
func (c *Client) LoadErrorTrackingIssue(issueID string, warn func(string, ...any)) (*ErrorTrackingIssue, error)
LoadErrorTrackingIssue reads the issue, its recent impact, a sample error event, and logs that share the sample trace. Impact, sample, and log lookups are optional: a missing permission still returns the issue and reports the failure to warn, which can be nil.
func (*Client) SearchErrorTrackingIssues ¶
func (c *Client) SearchErrorTrackingIssues(query string, limit int) ([]ErrorTrackingIssue, error)
SearchErrorTrackingIssues searches open and acknowledged Error Tracking issues from about the last 30 days. Empty query means "*". Results are the newest created issues, first-seen time descending. Limit is capped at 100.
func (*Client) SetRequestDeadline ¶
SetRequestDeadline stops later Datadog calls at deadline. The zero time clears the limit.
func (*Client) TraceURL ¶
TraceURL is the Datadog APM URL for a trace. A 128-bit hex ID uses the decimal lower 64 bits, which the Datadog app expects.
func (*Client) UpdateMonitor ¶
func (*Client) UpsertWebhook ¶
func (c *Client) UpsertWebhook(config WebhookConfiguration) error
func (*Client) ValidateCredentials ¶
ValidateCredentials verifies that the API and Application keys are valid by calling the Datadog validate endpoint.
type Configuration ¶
type CreateEvent ¶
type CreateEvent struct{}
func (*CreateEvent) Cancel ¶
func (c *CreateEvent) Cancel(ctx core.ExecutionContext) error
func (*CreateEvent) Cleanup ¶ added in v0.7.0
func (c *CreateEvent) Cleanup(ctx core.SetupContext) error
func (*CreateEvent) Color ¶
func (c *CreateEvent) Color() string
func (*CreateEvent) Configuration ¶
func (c *CreateEvent) Configuration() []configuration.Field
func (*CreateEvent) Description ¶
func (c *CreateEvent) Description() string
func (*CreateEvent) Documentation ¶
func (c *CreateEvent) Documentation() string
func (*CreateEvent) ExampleOutput ¶
func (c *CreateEvent) ExampleOutput() map[string]any
func (*CreateEvent) Execute ¶
func (c *CreateEvent) Execute(ctx core.ExecutionContext) error
func (*CreateEvent) HandleHook ¶ added in v0.18.0
func (c *CreateEvent) HandleHook(ctx core.ActionHookContext) error
func (*CreateEvent) HandleWebhook ¶
func (c *CreateEvent) HandleWebhook(ctx core.WebhookRequestContext) (int, *core.WebhookResponseBody, error)
func (*CreateEvent) Hooks ¶ added in v0.18.0
func (c *CreateEvent) Hooks() []core.Hook
func (*CreateEvent) Icon ¶
func (c *CreateEvent) Icon() string
func (*CreateEvent) Label ¶
func (c *CreateEvent) Label() string
func (*CreateEvent) Name ¶
func (c *CreateEvent) Name() string
func (*CreateEvent) OutputChannels ¶
func (c *CreateEvent) OutputChannels(configuration any) []core.OutputChannel
func (*CreateEvent) Setup ¶
func (c *CreateEvent) Setup(ctx core.SetupContext) error
type CreateEventRequest ¶
type CreateEventRequest struct {
Title string `json:"title"`
Text string `json:"text"`
AlertType string `json:"alert_type,omitempty"`
Priority string `json:"priority,omitempty"`
Tags []string `json:"tags,omitempty"`
}
CreateEventRequest represents the request payload for creating a Datadog event.
type CreateEventResponse ¶
CreateEventResponse represents the response from creating an event.
type CreateEventSpec ¶
type Datadog ¶
type Datadog struct{}
func (*Datadog) Configuration ¶
func (d *Datadog) Configuration() []configuration.Field
func (*Datadog) Description ¶
func (*Datadog) HandleHook ¶ added in v0.18.0
func (d *Datadog) HandleHook(ctx core.IntegrationHookContext) error
func (*Datadog) HandleRequest ¶
func (d *Datadog) HandleRequest(ctx core.HTTPRequestContext)
func (*Datadog) Instructions ¶
func (*Datadog) ListResources ¶
func (d *Datadog) ListResources(resourceType string, ctx core.ListResourcesContext) ([]core.IntegrationResource, error)
type ErrorSample ¶
type ErrorSample struct {
Source string
Timestamp time.Time
TraceID string
SpanID string
Env string
Version string
Host string
Resource string
HTTPMethod string
HTTPPath string
HTTPStatus string
UserID string
RequestID string
Fingerprint string
Origin string
Route string
Action string
Breadcrumbs []string
Stack string
TraceURL string
LogsURL string
}
ErrorSample is one error event that Datadog grouped into the issue.
type ErrorTrackingAlertPayload ¶
type ErrorTrackingAlertPayload struct {
ID string `json:"id" mapstructure:"id"`
EventType string `json:"event_type" mapstructure:"event_type"`
Title string `json:"title" mapstructure:"title"`
Body string `json:"body" mapstructure:"body"`
EventMessage string `json:"event_message,omitempty" mapstructure:"event_message"`
AlertID string `json:"alert_id" mapstructure:"alert_id"`
AlertTransition string `json:"alert_transition" mapstructure:"alert_transition"`
Tags string `json:"tags" mapstructure:"tags"`
AlertQuery string `json:"alert_query,omitempty" mapstructure:"alert_query"`
AlertScope string `json:"alert_scope,omitempty" mapstructure:"alert_scope"`
AggregKey string `json:"aggreg_key,omitempty" mapstructure:"aggreg_key"`
Link string `json:"link" mapstructure:"link"`
Description string `json:"description,omitempty" mapstructure:"description"`
Environment string `json:"environment,omitempty" mapstructure:"environment"`
ReceiptID string `json:"superplaneReceiptId,omitempty" mapstructure:"superplaneReceiptId"`
}
func ErrorTrackingIssuePayload ¶
func ErrorTrackingIssuePayload(issue ErrorTrackingIssue) ErrorTrackingAlertPayload
ErrorTrackingIssuePayload shapes one Error Tracking issue like the alert the intake trigger emits, so a seeded issue and a received alert take the same path through the graph.
type ErrorTrackingIssue ¶
type ErrorTrackingIssue struct {
ID string
ErrorType string
ErrorMessage string
Service string
FilePath string
FunctionName string
Platform string
State string
Languages []string
IsCrash bool
FirstSeen time.Time
LastSeen time.Time
FirstSeenVersion string
LastSeenVersion string
Regression *ErrorTrackingRegression
Assignee string
Teams []string
CaseKey string
CaseTitle string
CaseURL string
TotalCount int64
ImpactedUsers int64
ImpactedSessions int64
HasActivity bool
Stack string
Sample *ErrorSample
RelatedLogs []LogLine
URL string
}
ErrorTrackingIssue is one Error Tracking issue from Datadog.
func NewestCreatedErrorTrackingIssues ¶
func NewestCreatedErrorTrackingIssues(issues []ErrorTrackingIssue, limit int) []ErrorTrackingIssue
NewestCreatedErrorTrackingIssues returns up to limit issues, most recently created first. Issues with no first-seen time stay after issues that have one. Equal times keep their incoming order.
func NewestErrorTrackingIssues ¶
func NewestErrorTrackingIssues(issues []ErrorTrackingIssue, limit int) []ErrorTrackingIssue
NewestErrorTrackingIssues returns up to limit issues, most recently seen first. Issues with no last-seen time stay after issues that have one. Equal times keep their incoming order.
func (ErrorTrackingIssue) IssueTitle ¶
func (i ErrorTrackingIssue) IssueTitle() string
IssueTitle is the list and import title for an Error Tracking issue.
type ErrorTrackingRegression ¶
type ErrorTrackingRegression struct {
RegressedAt time.Time
RegressedAtVersion string
ResolvedAt time.Time
}
ErrorTrackingRegression is a resolved issue that started again.
type Event ¶
type Event struct {
ID int64 `json:"id"`
Title string `json:"title"`
Text string `json:"text"`
DateHappened int64 `json:"date_happened"`
AlertType string `json:"alert_type"`
Priority string `json:"priority"`
Tags []string `json:"tags"`
URL string `json:"url"`
}
Event represents a Datadog event response.
type LogLine ¶
type LogLine struct {
Timestamp time.Time
Status string
Service string
Message string
HTTPMethod string
HTTPPath string
HTTPStatus string
ErrorKind string
}
LogLine is one log that shares the error sample trace or span.
type MonitorOptions ¶
type MonitorOptions struct {
GroupbySimpleMonitor bool `json:"groupby_simple_monitor"`
NewHostDelay int `json:"new_host_delay"`
Thresholds MonitorThresholds `json:"thresholds"`
}
type MonitorThresholds ¶
type MonitorThresholds struct {
Critical float64 `json:"critical"`
}
type OnErrorTrackingAlert ¶
type OnErrorTrackingAlert struct{}
func (*OnErrorTrackingAlert) Cleanup ¶
func (t *OnErrorTrackingAlert) Cleanup(ctx core.TriggerContext) error
func (*OnErrorTrackingAlert) Color ¶
func (t *OnErrorTrackingAlert) Color() string
func (*OnErrorTrackingAlert) Configuration ¶
func (t *OnErrorTrackingAlert) Configuration() []configuration.Field
func (*OnErrorTrackingAlert) Description ¶
func (t *OnErrorTrackingAlert) Description() string
func (*OnErrorTrackingAlert) Documentation ¶
func (t *OnErrorTrackingAlert) Documentation() string
func (*OnErrorTrackingAlert) ExampleData ¶
func (t *OnErrorTrackingAlert) ExampleData() map[string]any
func (*OnErrorTrackingAlert) HandleHook ¶
func (t *OnErrorTrackingAlert) HandleHook(ctx core.TriggerHookContext) (map[string]any, error)
func (*OnErrorTrackingAlert) HandleWebhook ¶
func (t *OnErrorTrackingAlert) HandleWebhook(ctx core.WebhookRequestContext) (int, *core.WebhookResponseBody, error)
func (*OnErrorTrackingAlert) Hooks ¶
func (t *OnErrorTrackingAlert) Hooks() []core.Hook
func (*OnErrorTrackingAlert) Icon ¶
func (t *OnErrorTrackingAlert) Icon() string
func (*OnErrorTrackingAlert) Label ¶
func (t *OnErrorTrackingAlert) Label() string
func (*OnErrorTrackingAlert) Name ¶
func (t *OnErrorTrackingAlert) Name() string
func (*OnErrorTrackingAlert) OnIntegrationMessage ¶
func (t *OnErrorTrackingAlert) OnIntegrationMessage(ctx core.IntegrationMessageContext) error
func (*OnErrorTrackingAlert) Setup ¶
func (t *OnErrorTrackingAlert) Setup(ctx core.TriggerContext) error
type SubscriptionConfiguration ¶
type SubscriptionConfiguration struct{}
type WebhookConfiguration ¶
type WebhookReceiptState ¶
WebhookReceiptState carries one receipt from the public webhook handler into the integration request. The handler fills the outcome.
func WebhookReceiptFromRequest ¶
func WebhookReceiptFromRequest(r *http.Request) *WebhookReceiptState
type WebhookSummary ¶
type WebhookSummary struct {
EventType string
AlertTransition string
AlertID string
Service string
IssueID string
}
WebhookSummary is the metadata stored for one Datadog call. It does not include the body or the webhook token.
func SummarizeWebhook ¶
func SummarizeWebhook(body []byte) WebhookSummary
SummarizeWebhook reads event metadata from a Datadog webhook body.