github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/v2/raw/writer.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package raw
     6  
     7  import (
     8  	"github.com/shogo82148/std/io"
     9  
    10  	"github.com/shogo82148/std/internal/trace/v2/event"
    11  	"github.com/shogo82148/std/internal/trace/v2/version"
    12  )
    13  
    14  // Writer emits the wire format of a trace.
    15  //
    16  // It may not produce a byte-for-byte compatible trace from what is
    17  // produced by the runtime, because it may be missing extra padding
    18  // in the LEB128 encoding that the runtime adds but isn't necessary
    19  // when you know the data up-front.
    20  type Writer struct {
    21  	w     io.Writer
    22  	buf   []byte
    23  	v     version.Version
    24  	specs []event.Spec
    25  }
    26  
    27  // NewWriter creates a new byte format writer.
    28  func NewWriter(w io.Writer, v version.Version) (*Writer, error)
    29  
    30  // WriteEvent writes a single event to the trace wire format stream.
    31  func (w *Writer) WriteEvent(e Event) error