perfetto

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Overview

Package perfetto contains libraries for displaying trace information in the Perfetto UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a trace database that stores traces on the local file system.

Trace data is stored in a JSON format [1] that is compatible with the Perfetto UI[2].

For each trace span, the following Perfetto events are generated:

  • A complete event, encapsulating the span duration.
  • A number of metadata events, encapsulating the span events.

[1] https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview# [2] https://ui.perfetto.dev/

func Open

func Open(ctx context.Context, fname string) (*DB, error)

Open opens the default trace database on the local machine, which is persisted in the provided file.

func (*DB) Close

func (d *DB) Close() error

Close closes the trace database.

func (*DB) Serve

func (d *DB) Serve(ctx context.Context)

Serve runs an HTTP server that serves traces stored in the database. In order to view the traces, open the following URL in a Chrome browser:

https://ui.perfetto.dev/#!/?url=http://<hostname>:9001?app=<app>&version=<version>

, where <hostname> is the hostname of the machine running this server (e.g., "127.0.0.1"), <app> is the application name, and <version> is the application version. If <version> is empty, all of the application's traces will be displayed. If <app> is also empty, all of the database traces will be displayed.

Perfetto UI requires that the server runs on the local port 9001. For that reason, this method will block until port 9001 becomes available.

func (*DB) Store

func (d *DB) Store(ctx context.Context, app, version string, spans []sdktrace.ReadOnlySpan) error

Store stores the given traces in the database.

Jump to

Keyboard shortcuts

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