Documentation
¶
Overview ¶
Package record defines what factorymeter keeps about a line: tickets, changes, CI runs, deploys and the links between them.
A source adapter (GitHub, Linear, Jira) turns what it reads into these records and nothing else. Every metric is computed from records, so a new source needs no change to a metric and a new metric needs no change to a source.
Index ¶
- Constants
- func CIRunID(source, repo string, run int64, attempt int) string
- func ChangeID(source, repo string, number int) string
- func DeployID(source, repo, via, name string) string
- func KeyPrefix(key string) (string, bool)
- func KeyPrefixes(tickets []Ticket) []string
- func SourceName(source string) string
- func SourceOf(id string) string
- func TicketID(source, key string) string
- type Actor
- type CIRun
- type Change
- type Commit
- type CommitAuthor
- type Deploy
- type Link
- type Review
- type Ticket
- type Trailer
Constants ¶
const ( GitHub = "github" Linear = "linear" Jira = "jira" )
Sources.
const ( KindTicket = "ticket" KindChange = "change" KindCIRun = "ci_run" KindDeploy = "deploy" KindLink = "link" )
Record kinds. They match the names the metric registry uses.
const ( ActorUser = "user" ActorBot = "bot" )
Actor kinds.
const ( ChangeOpen = "open" ChangeClosed = "closed" ChangeMerged = "merged" )
Change states.
const ( ReviewApproved = "approved" ReviewChangesRequested = "changes_requested" ReviewCommented = "commented" ReviewDismissed = "dismissed" )
Review states.
const ( DeploySuccess = "success" DeployFailure = "failure" DeployRunning = "running" DeployUnknown = "unknown" )
Deploy outcomes.
const ( TicketBacklog = "backlog" TicketUnstarted = "unstarted" TicketStarted = "started" TicketDone = "done" TicketCancelled = "cancelled" )
Ticket states. Every source maps its own workflow onto these five.
const ( // LinkCloses ties a change to the ticket it resolves. LinkCloses = "closes" // LinkMentions ties a change to a ticket it names without resolving it. LinkMentions = "mentions" // LinkReverts ties a change to the earlier change it reverts. LinkReverts = "reverts" )
Link kinds.
const SchemaVersion = 1
SchemaVersion is the version of the record layout. The store writes it down and refuses to read a store with a newer one. A new field does not raise it: a file written before the field reads with the field empty. It goes up when a field goes away or comes to mean something else.
Variables ¶
This section is empty.
Functions ¶
func DeployID ¶
DeployID builds the id of a deploy. via is "deployment" or "release" and name is the deployment number or the release tag.
func KeyPrefix ¶ added in v0.5.0
KeyPrefix is the part of a ticket key before its number, in upper case: ENG for ENG-12. It is false for a key with no prefix or no number.
func KeyPrefixes ¶ added in v0.5.0
KeyPrefixes are the prefixes of the keys of tickets, and of the keys they had before, each once and sorted.
func SourceName ¶
SourceName is how a source is written for a reader.
Types ¶
type Actor ¶
type Actor struct {
Login string `json:"login" parquet:"login" doc:"The account name on the source. A GitHub bot keeps its [bot] suffix."`
Kind string `json:"kind" parquet:"kind" doc:"What the source says the account is." enum:"user,bot"`
}
Actor is an account on a source.
type CIRun ¶
type CIRun struct {
Source string `json:"source" parquet:"source" doc:"Where the record came from." enum:"github"`
ID string `json:"id" parquet:"id" doc:"Stable id, unique among CI runs: source:owner/repo/run/attempt."`
Repo string `json:"repo" parquet:"repo" doc:"The repository, as owner/name."`
Workflow string `json:"workflow" parquet:"workflow" doc:"The name of the workflow."`
Event string `json:"event" parquet:"event" doc:"What started the run, in the source's words, such as pull_request or push."`
SHA string `json:"sha" parquet:"sha" doc:"The commit the run ran on. It ties the run to a change."`
Branch string `` /* 154-byte string literal not displayed */
Attempt int `json:"attempt" parquet:"attempt" doc:"1 for the first run, more for a run that was started again."`
Status string `json:"status" parquet:"status" doc:"Whether the run has finished, in the source's words."`
Conclusion string `` /* 135-byte string literal not displayed */
CreatedAt time.Time `json:"created_at" parquet:"created_at,timestamp(microsecond)" doc:"When the run was created."`
StartedAt time.Time `json:"started_at" parquet:"started_at,timestamp(microsecond)" doc:"When this attempt started."`
UpdatedAt time.Time `` /* 139-byte string literal not displayed */
}
CIRun is one run of a CI workflow on one commit.
type Change ¶
type Change struct {
Source string `json:"source" parquet:"source" doc:"Where the record came from." enum:"github"`
ID string `json:"id" parquet:"id" doc:"Stable id, unique among changes: source:owner/repo#number."`
Repo string `json:"repo" parquet:"repo" doc:"The repository, as owner/name."`
Number int `json:"number" parquet:"number" doc:"The number of the change in its repository."`
URL string `json:"url" parquet:"url" doc:"Link to the change on the source."`
Title string `json:"title" parquet:"title" doc:"The title."`
Body string `json:"body" parquet:"body" doc:"The description. It is read for agent signatures and for ticket keys."`
Author Actor `json:"author" parquet:"author" doc:"The account that opened the change."`
HeadRef string `json:"head_ref" parquet:"head_ref" doc:"The branch the change comes from."`
BaseRef string `json:"base_ref" parquet:"base_ref" doc:"The branch the change goes to."`
State string `json:"state" parquet:"state" doc:"Where the change stands now." enum:"open,closed,merged"`
Draft bool `json:"draft" parquet:"draft" doc:"True while the change is a draft."`
CreatedAt time.Time `json:"created_at" parquet:"created_at,timestamp(microsecond)" doc:"When the change was opened."`
UpdatedAt time.Time `` /* 137-byte string literal not displayed */
ReadyAt *time.Time `` /* 154-byte string literal not displayed */
MergedAt *time.Time `json:"merged_at" parquet:"merged_at,optional,timestamp(microsecond)" doc:"When the change merged. Null when it has not."`
MergeSHA string `` /* 195-byte string literal not displayed */
ClosedAt *time.Time `` /* 136-byte string literal not displayed */
Additions int `json:"additions" parquet:"additions" doc:"Lines added."`
Deletions int `json:"deletions" parquet:"deletions" doc:"Lines deleted."`
ChangedFiles int `json:"changed_files" parquet:"changed_files" doc:"Files touched."`
CommitCount int `` /* 141-byte string literal not displayed */
Commits []Commit `json:"commits" parquet:"commits,list" doc:"The commits of the change, oldest first."`
Reviews []Review `json:"reviews" parquet:"reviews,list" doc:"The submitted reviews, oldest first."`
}
Change is a pull request or a merge request.
type Commit ¶
type Commit struct {
SHA string `json:"sha" parquet:"sha" doc:"The commit id."`
AuthoredAt time.Time `json:"authored_at" parquet:"authored_at,timestamp(microsecond)" doc:"When the commit was written."`
CommittedAt time.Time `json:"committed_at" parquet:"committed_at,timestamp(microsecond)" doc:"When the commit was last applied. A rebase moves it."`
Parents int `json:"parents" parquet:"parents" doc:"How many parents the commit has. Two or more make it a merge commit."`
Authors []CommitAuthor `json:"authors" parquet:"authors,list" doc:"The author and every co-author."`
Trailers []Trailer `json:"trailers" parquet:"trailers,list" doc:"The trailer lines of the commit message, such as Co-Authored-By."`
}
Commit is one commit of a change.
type CommitAuthor ¶
type CommitAuthor struct {
Login string `json:"login" parquet:"login" doc:"The account the source matched the author to. Empty when it matched none."`
Email string `json:"email" parquet:"email" doc:"The email on the commit."`
Name string `json:"name" parquet:"name" doc:"The name on the commit."`
}
CommitAuthor is an author or a co-author of a commit.
type Deploy ¶
type Deploy struct {
Source string `json:"source" parquet:"source" doc:"Where the record came from." enum:"github"`
ID string `` /* 131-byte string literal not displayed */
Repo string `json:"repo" parquet:"repo" doc:"The repository, as owner/name."`
Via string `json:"via" parquet:"via" doc:"What kind of event this is on the source." enum:"deployment,release"`
Environment string `json:"environment" parquet:"environment" doc:"The environment name. Empty for a release."`
Production bool `json:"production" parquet:"production" doc:"True when the environment is production. A release always is."`
Ref string `json:"ref" parquet:"ref" doc:"The branch or tag that was deployed."`
SHA string `json:"sha" parquet:"sha" doc:"The commit that was deployed, when the source gives it."`
CreatedAt time.Time `json:"created_at" parquet:"created_at,timestamp(microsecond)" doc:"When the deploy started."`
FinishedAt *time.Time `` /* 154-byte string literal not displayed */
Outcome string `json:"outcome" parquet:"outcome" doc:"How the deploy ended." enum:"success,failure,running,unknown"`
}
Deploy is one deployment to an environment, or one published release.
type Link ¶
type Link struct {
Kind string `json:"kind" parquet:"kind" doc:"What the link means." enum:"closes,mentions,reverts"`
From string `json:"from" parquet:"from" doc:"The id of the change the link starts at."`
FromKind string `json:"from_kind" parquet:"from_kind" doc:"The kind of the record the link starts at." enum:"change"`
To string `json:"to" parquet:"to" doc:"The id of the record the link points at."`
ToKind string `json:"to_kind" parquet:"to_kind" doc:"The kind of the record the link points at." enum:"ticket,change"`
Found string `json:"found" parquet:"found" doc:"Where the link was read." enum:"source,body,title,branch"`
}
Link ties two records together.
type Review ¶
type Review struct {
Author Actor `json:"author" parquet:"author" doc:"The account that wrote the review."`
State string `json:"state" parquet:"state" doc:"What the review said." enum:"approved,changes_requested,commented,dismissed"`
SubmittedAt time.Time `json:"submitted_at" parquet:"submitted_at,timestamp(microsecond)" doc:"When the review was submitted."`
}
Review is one submitted review of a change.
type Ticket ¶
type Ticket struct {
Source string `json:"source" parquet:"source" doc:"Where the record came from." enum:"github,linear,jira"`
ID string `` /* 333-byte string literal not displayed */
Key string `json:"key" parquet:"key" doc:"The name people use for the ticket: owner/repo#12 on GitHub, ENG-123 on Linear or Jira."`
Aliases []string `` /* 203-byte string literal not displayed */
Project string `json:"project" parquet:"project" doc:"The repository, team or project the ticket belongs to."`
URL string `json:"url" parquet:"url" doc:"Link to the ticket on the source."`
Title string `json:"title" parquet:"title" doc:"The title."`
Type string `` /* 130-byte string literal not displayed */
Labels []string `json:"labels" parquet:"labels,list" doc:"The labels on the ticket."`
Author Actor `json:"author" parquet:"author" doc:"The account that created the ticket."`
State string `` /* 136-byte string literal not displayed */
RawState string `json:"raw_state" parquet:"raw_state" doc:"The state in the source's own words."`
CreatedAt time.Time `json:"created_at" parquet:"created_at,timestamp(microsecond)" doc:"When the ticket was created."`
UpdatedAt time.Time `` /* 137-byte string literal not displayed */
StartedAt *time.Time `` /* 185-byte string literal not displayed */
DoneAt *time.Time `` /* 131-byte string literal not displayed */
ClosedAt *time.Time `` /* 140-byte string literal not displayed */
Reopened int `json:"reopened" parquet:"reopened" doc:"How many times the ticket went from done back to an open state."`
}
Ticket is an issue on GitHub, Linear or Jira.