nettrace

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const Version int32 = 4

Variables

View Source
var (
	ErrInvalidNetTraceHeader    = errors.New("invalid NetTrace header")
	ErrUnsupportedObjectVersion = errors.New("unsupported object version")
	ErrInvalidObjectType        = errors.New("invalid object type")
	ErrUnexpectedObjectType     = errors.New("unexpected object type")
	ErrUnexpectedTag            = errors.New("unexpected tag")
)
View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

This section is empty.

Types

type Blob

type Blob struct {
	Header BlobHeader
	// Payload contains Event and Metadata records.
	Payload *bytes.Buffer
	// contains filtered or unexported fields
}

func (*Blob) IsSorted

func (b *Blob) IsSorted() bool

type BlobBlock

type BlobBlock struct {
	Header BlobBlockHeader
	// Payload contains Blobs - serialized fragments which represent
	// actual events and metadata records.
	Payload *bytes.Buffer
	// contains filtered or unexported fields
}

BlobBlock contains a set of Blobs.

func BlobBlockFromObject

func BlobBlockFromObject(o Object) (*BlobBlock, error)

func (*BlobBlock) IsCompressed

func (b *BlobBlock) IsCompressed() bool

func (*BlobBlock) Next

func (b *BlobBlock) Next(blob *Blob) error

type BlobBlockHeader

type BlobBlockHeader struct {
	// Size of the header including this field.
	Size  int16
	Flags int16
	// MinTimestamp specifies the minimum timestamp of any event in this block.
	MinTimestamp int64
	// MinTimestamp specifies the maximum timestamp of any event in this block.
	MaxTimestamp int64
}

type BlobHeader

type BlobHeader struct {
	MetadataID        int32
	SequenceNumber    int32
	ThreadID          int64
	CaptureThreadID   int64
	CaptureProcNumber int32
	StackID           int32
	TimeStamp         int64
	ActivityID        [16]byte
	RelatedActivityID [16]byte
	PayloadSize       int32
	// contains filtered or unexported fields
}

BlobHeader used for both compressed and uncompressed blobs.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(o *Object) error

Decode deserializes next NetTrace Object from stream to o. The call returns io.EOF when the stream is properly terminated, any further attempts to decode will return io.ErrUnexpectedEOF.

func (*Decoder) Offset

func (d *Decoder) Offset() uint64

func (*Decoder) OpenTrace

func (d *Decoder) OpenTrace() (*Trace, error)

type Metadata

type Metadata struct {
	Header  MetadataHeader
	Payload MetadataPayload
	// contains filtered or unexported fields
}

func MetadataFromBlob

func MetadataFromBlob(blob Blob) (*Metadata, error)

type MetadataField

type MetadataField struct {
	TypeCode typecode.TypeCode
	// ArrayTypeCode is an optional field only appears when TypeCode is Array.
	ArrayTypeCode typecode.TypeCode
	// For primitive types and strings Payload is not present, however if TypeCode is Object (1)
	// then Payload is another payload description (that is a field count, followed by a list of
	// field definitions). These can be nested to arbitrary depth.
	Payload MetadataPayload
	Name    string
}

type MetadataHeader

type MetadataHeader struct {
	MetaDataID   int32
	ProviderName string
	EventID      int32
	EventName    string
	Keywords     int64
	Version      MetadataVersion
	Level        int32
}

type MetadataPayload

type MetadataPayload struct {
	Fields []MetadataField
}

type MetadataVersion

type MetadataVersion int32
const (
	MetadataLegacyV1 MetadataVersion // Used by NetPerf version 1
	MetadataLegacyV2                 // Used by NetPerf version 2
	MetadataNetTrace                 // Used by NetPerf (version 3) and NetTrace (version 4+)
)

type Object

type Object struct {
	Type                 ObjectType
	Version              int32
	MinimumReaderVersion int32
	Payload              *bytes.Buffer
}

type ObjectType

type ObjectType string
const (
	ObjectTypeTrace         ObjectType = "Trace"
	ObjectTypeEventBlock    ObjectType = "EventBlock"
	ObjectTypeMetadataBlock ObjectType = "MetadataBlock"
	ObjectTypeStackBlock    ObjectType = "StackBlock"
	ObjectTypeSPBlock       ObjectType = "SPBlock"
)

func (ObjectType) IsValid

func (t ObjectType) IsValid() bool

type Parser

type Parser struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

func (*Parser) Err

func (p *Parser) Err() error

func (*Parser) Read

func (p *Parser) Read(v interface{})

func (*Parser) Skip

func (p *Parser) Skip(n int)

func (*Parser) UTF16NTS

func (p *Parser) UTF16NTS() string

UTF16NTS returns UTF8 string read from 2-bytes UTF16 null terminated string. Bytes are speculatively interpreted as 2-byte ASCII chars, and decoding takes place only if a code unit is not representable in ASCII.

func (*Parser) Uvarint

func (p *Parser) Uvarint() uint64

type SequencePointBlock

type SequencePointBlock struct {
	TimeStamp int64
	Threads   []Thread
}

func SequencePointBlockFromObject

func SequencePointBlockFromObject(o Object) (*SequencePointBlock, error)

type Stack

type Stack struct {
	ID   int32
	Data []byte
}

func (Stack) InstructionPointers added in v1.0.1

func (s Stack) InstructionPointers(size int32) []uint64

type StackBlock

type StackBlock struct {
	Stacks []Stack
}

func StackBlockFromObject

func StackBlockFromObject(o Object) (*StackBlock, error)

type Stream

type Stream struct {
	EventHandler              func(*Blob) error
	MetadataHandler           func(*Metadata) error
	StackBlockHandler         func(*StackBlock) error
	SequencePointBlockHandler func(*SequencePointBlock) error
	// contains filtered or unexported fields
}

func NewStream

func NewStream(r io.Reader) *Stream

func (*Stream) Next

func (s *Stream) Next() error

func (*Stream) Open

func (s *Stream) Open() (*Trace, error)

type Tag

type Tag byte
const (
	NullReference      Tag = 0x1
	BeginPrivateObject Tag = 0x5
	EndObject          Tag = 0x6
)

type Thread

type Thread struct {
	ThreadID       int64
	SequenceNumber int32
}

type Trace

type Trace struct {
	Year                    int16
	Month                   int16
	DayOfWeek               int16
	Day                     int16
	Hour                    int16
	Minute                  int16
	Second                  int16
	Millisecond             int16
	SyncTimeQPC             int64
	QPCFrequency            int64
	PointerSize             int32
	ProcessID               int32
	NumberOfProcessors      int32
	ExpectedCPUSamplingRate int32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL