luci: Index | Files | Directories

package annotee

import ""


Package Files

link_generator.go processor.go


const (
    // STDOUT is the system STDOUT stream name.
    STDOUT = types.StreamName("stdout")
    // STDERR is the system STDERR stream.
    STDERR = types.StreamName("stderr")

    // DefaultAnnotationSubpath is the default annotation subpath. It will be used
    // if an explicit subpath is not provided.
    DefaultAnnotationSubpath = types.StreamName("annotations")
const (
    // DefaultBufferSize is the Stream BufferSize value that will be used if no
    // buffer size is provided.
    DefaultBufferSize = 8192

type CoordinatorLinkGenerator Uses

type CoordinatorLinkGenerator struct {
    Host    string
    Project string
    Prefix  types.StreamName

CoordinatorLinkGenerator is a LinkGenerator implementation

func (g *CoordinatorLinkGenerator) CanGenerateLinks() bool

CanGenerateLinks returns true if g is sufficiently configured to generate LogDog Coordinator links.

func (g *CoordinatorLinkGenerator) GetLink(names ...types.StreamName) string

GetLink implements LinkGenerator.

type LinkGenerator Uses

type LinkGenerator interface {
    // GetLink returns a link for the specified aggregate streams.
    // If no link could be generated, GetLink may return an empty string.
    GetLink(name ...types.StreamName) string

LinkGenerator generates links for a given log stream.

type Options Uses

type Options struct {
    // Base is the base log stream name. This is prepended to every log name, as
    // well as any generate log names.
    Base types.StreamName
    // AnnotationSubpath is the path underneath of Base where the annotation
    // stream will be written.
    // If empty, DefaultAnnotationSubpath will be used.
    AnnotationSubpath types.StreamName

    // LinkGenerator generates links to alias for a given log stream.
    // If nil, no link annotations will be injected.
    LinkGenerator LinkGenerator

    // Client is the LogDog Butler Client to use for stream creation.
    Client *streamclient.Client

    // Execution describes the current applicaton's execution parameters. This
    // will be used to construct annotation state.
    Execution *annotation.Execution

    // TeeAnnotations, if true, causes all encountered annotations to be
    // tee'd, if teeing is configured.
    TeeAnnotations bool
    // TeeText, if true, causes all encountered non-annotation lines to be
    // tee'd, if teeing is configured.
    TeeText bool

    // MetadataUpdateInterval is the amount of time to wait after stream metadata
    // updates to push the updated metadata protobuf to the metadata stream.
    //	- If this is < 0, metadata will only be pushed at the beginning and end of
    //	  a step.
    //	- If this equals 0, metadata will be pushed every time it's updated.
    //	- If this is 0, DefaultMetadataUpdateInterval will be used.
    MetadataUpdateInterval time.Duration

    // Offline specifies whether parsing happens not at the same time as
    // emitting. If true and CURRENT_TIMESTAMP annotations are not provided
    // then step start/end times are left empty.
    Offline bool

    // CloseSteps specified whether outstanding open steps must be closed.
    CloseSteps bool

    // AnnotationUpdated is synchronously called when the annotation message
    // changes.
    // miloStepBinary is binary-serialized milo.Step.
    // miloStepBinary must not be mutated.
    // The call blocks writing datagrams to the output stream.
    AnnotationUpdated func(miloStepBinary []byte)

Options are the configuration options for a Processor.

type Processor Uses

type Processor struct {
    // contains filtered or unexported fields

Processor consumes data from a list of Stream entries and interacts with the supplied Client instance.

A Processor must be instantiated with New.

func New Uses

func New(c context.Context, o Options) *Processor

New instantiates a new Processor.

func (*Processor) Finish Uses

func (p *Processor) Finish() *annotation.State

Finish instructs the Processor to close any outstanding state. This should be called when all automatic state updates have completed in case any steps didn't properly close their state.

Finish will return the closed annotation state that was accumulated during processing.

func (*Processor) IngestLine Uses

func (p *Processor) IngestLine(s *Stream, line string) error

IngestLine ingests a single line of text from an input stream, responding to any annotations encountered.

This method is not goroutine-safe.

func (*Processor) RunStreams Uses

func (p *Processor) RunStreams(streams []*Stream) error

RunStreams executes the Processor, consuming data from its configured streams and forwarding it to LogDog. Run will block until all streams have terminated.

If a stream terminates with an error, or if there is an error processing the stream data, Run will return an error. If multiple Streams fail with errors, an errors.MultiError will be returned. io.EOF does not count as an error.

type Stream Uses

type Stream struct {
    // Reader is the stream data reader. It will be processed until it returns
    // an error or io.EOF.
    Reader io.Reader
    // Name is the logdog stream name.
    Name types.StreamName
    // Tee, if not nil, is a writer where all consumed stream data should be
    // forwarded.
    Tee io.Writer
    // Alias is the base stream name that this stream should alias to.
    Alias string

    // Annotate, if true, causes annotations in this Stream to be captured and
    // an annotation LogDog stream to be emitted.
    Annotate bool

    // StripAnnotations, if true, causes all encountered annotations to be
    // stripped from incoming stream data. Otherwise, those annotations will
    // still advnace the annotation state (if Annotate is true), but will not be
    // included in any output streams.
    StripAnnotations bool

    // EmitAllLink, if true, instructs an "all STDOUT/STDERR" link to be injected
    // into this Stream.
    EmitAllLink bool

    // BufferSize is the size of the read buffer that will be used when processing
    // this stream's data.
    BufferSize int

Stream describes a single process stream.


annotationPackage annotation implements a state machine that constructs Milo annotation protobufs from a series of annotation commands.
executorPackage executor contains an implementation of the Annotee Executor.

Package annotee imports 20 packages (graph) and is imported by 6 packages. Updated 2019-10-21. Refresh now. Tools for package owners.