Help us shape the future of Go! Take the 2026 Go Developer Survey

flags

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressionNone = "none"
	CompressionGzip = "gzip"
)

Compression names accepted by --remote-store-compression.

View Source
const (
	RemoteStoreFormatArrowV1 = "arrow-v1"
	RemoteStoreFormatArrowV2 = "arrow-v2"
	RemoteStoreFormatOTLP    = "otlp"
)

Profile wire formats accepted by --remote-store-format.

View Source
const (
	ExporterTypeGRPC  ExporterType = "grpc"
	ExporterTypeHTTP  ExporterType = "http"
	ExporterTypeStdio ExporterType = "stdout"

	SamplerTypeAlways     SamplerType = "always"
	SamplerTypeNever      SamplerType = "never"
	SamplerTypeRatioBased SamplerType = "ratio_based"
)
View Source
const Name = "proto"

Name is the name registered for the proto compressor.

Variables

This section is empty.

Functions

func ConfigureCompression added in v0.50.0

func ConfigureCompression(name string) (grpc.CallOption, bool, error)

ConfigureCompression resolves the compression flag into a gRPC call option, and reports whether there is one to apply. This is transport compression, unrelated to the LZ4 inside an Arrow v2 payload.

It must run before any dial: SetLevel mutates the registered compressor's writer pool, which grpc-go documents as initialization-time only.

func CustomHeadersStreamInterceptor added in v0.50.0

func CustomHeadersStreamInterceptor(headers map[string]string) grpc.StreamClientInterceptor

CustomHeadersStreamInterceptor is the streaming counterpart.

func CustomHeadersUnaryInterceptor added in v0.50.0

func CustomHeadersUnaryInterceptor(headers map[string]string) grpc.UnaryClientInterceptor

CustomHeadersUnaryInterceptor attaches headers to every unary call. Exported so the OTLP profiles dial can reuse it for --otlp-headers.

func NewPerRequestBearerToken

func NewPerRequestBearerToken(token string, insecure bool) *perRequestBearerToken

func NewProvider

func NewProvider(ctx context.Context, version string, exporter sdktrace.SpanExporter, externalLabels map[string]string, opts ...sdktrace.TracerProviderOption) (trace.TracerProvider, error)

NewProvider returns an OTLP exporter based tracer.

func RegisterProtoCodec added in v0.50.0

func RegisterProtoCodec()

RegisterProtoCodec installs the vtproto codec as the global "proto" codec. Idempotent, and it must run before any dial carrying pdata: those types satisfy no proto.Message variant and marshal only through this codec's pdataProtoMarshaler branch, so without it an export fails at the first flush with an opaque "failed to marshal, message is *internal.Export...".

Types

type ExitCode

type ExitCode int
const (
	ExitSuccess ExitCode = 0
	ExitFailure ExitCode = 1

	// Go 'flag' package calls os.Exit(2) on flag parse errors, if ExitOnError is set
	ExitParseError ExitCode = 2
)

func Failure

func Failure(msg string, args ...interface{}) ExitCode

func ParseError

func ParseError(msg string, args ...interface{}) ExitCode

type Exporter

type Exporter interface {
	sdktrace.SpanExporter

	Start(ctx context.Context) error
}

func NewConsoleExporter

func NewConsoleExporter(w io.Writer) (Exporter, error)

NewConsoleExporter returns a console exporter.

func NewExporter

func NewExporter(exType, otlpAddress string) (Exporter, error)

func NewGRPCExporter

func NewGRPCExporter(otlpAddress string) (Exporter, error)

NewGRPCExporter returns a gRPC exporter.

func NewHTTPExporter

func NewHTTPExporter(otlpAddress string) (Exporter, error)

NewHTTPExporter returns a HTTP exporter.

type ExporterType

type ExporterType string

type Flags

type Flags struct {
	Log         FlagsLogs `embed:""                         prefix:"log-"`
	HTTPAddress string    `default:"127.0.0.1:7071"         help:"Address to bind HTTP server to."`
	Version     bool      `help:"Show application version."`

	EnvironmentType string   `help:"The type of environment."`
	MachineID       string   `help:"The machine ID."`
	IncludeEnvVar   []string `help:"Environment variables to include in the profile."`

	// The go tracer is disabled by default because Parca symbolizes native Go
	// frames server-side from uploaded debuginfo, and doing it in both places
	// wastes agent CPU. Turn it on when the backend has no symbolizer: the
	// upstream interpreter reads gopclntab out of the binary and resolves
	// function, file and line in-agent, so frames arrive named with no
	// debuginfo upload at all.
	SymbolizeGo bool `` /* 215-byte string literal not displayed */

	OtelTags string `default:"" help:"Otel tags to attach to all traces."`
	Tracers  string `default:"all" help:"Tracers to enable."`

	PIDNamespaceTranslationMode tracer.PIDNamespaceTranslationMode `` /* 273-byte string literal not displayed */

	Node          string `` /* 155-byte string literal not displayed */
	ConfigPath    string `default:""                          help:"Path to config file."`
	MemlockRlimit uint64 `` /* 216-byte string literal not displayed */

	// pprof.
	MutexProfileFraction int `default:"0" help:"Fraction of mutex profile samples to collect."`
	BlockProfileRate     int `default:"0" help:"Sample rate for block profile."`

	Profiling      FlagsProfiling      `embed:"" prefix:"profiling-"`
	Metadata       FlagsMetadata       `embed:"" prefix:"metadata-"`
	LocalStore     FlagsLocalStore     `embed:"" prefix:"local-store-"`
	RemoteStore    FlagsRemoteStore    `embed:"" prefix:"remote-store-"`
	Debuginfo      FlagsDebuginfo      `embed:"" prefix:"debuginfo-"`
	Symbolizer     FlagsSymbolizer     `embed:"" prefix:"symbolizer-"`
	OTLP           FlagsOTLP           `embed:"" prefix:"otlp-"`
	ObjectFilePool FlagsObjectFilePool `embed:"" prefix:"object-file-pool-"`

	ClockSyncInterval time.Duration `default:"3m" help:"How frequently to synchronize with the realtime clock."`

	DWARFUnwinding         FlagsDWARFUnwinding `embed:""        prefix:"dwarf-unwinding-"`
	PythonUnwindingDisable bool                `default:"false" help:"[deprecated] Disable Python unwinder."`
	RubyUnwindingDisable   bool                `default:"false" help:"[deprecated] Disable Ruby unwinder."`
	JavaUnwindingDisable   bool                `default:"true"  help:"[deprecated] Disable Java unwinder."`

	InstrumentCudaLaunch bool `default:"true" help:"instrument calls to cudaLaunchKernel."`

	AnalyticsOptOut bool `default:"false" help:"Opt out of sending anonymous usage statistics."`

	Telemetry FlagsTelemetry `embed:"" prefix:"telemetry-"`
	Hidden    FlagsHidden    `embed:"" hidden:""           prefix:""`

	BPF FlagsBPF `embed:"" prefix:"bpf-"`

	OfflineMode     FlagsOfflineMode `embed:"" prefix:"offline-mode-"`
	OffCPUThreshold float64          `default:"0" help:"The probability (0.0-1.0) of off-CPU event being recorded."`

	EnableOOMProf       bool `default:"false" help:"Enable OOMProf profiling integration."`
	EnableOOMProfAllocs bool `default:"false" help:"Enable OOMProf alloc counts."`

	MergeGpuProfiles bool `` /* 325-byte string literal not displayed */

	GpuMetrics FlagsGpuMetrics `embed:"" prefix:"gpu-metrics-"`

	GpuNvtx FlagsGpuNvtx `embed:"" prefix:"gpu-nvtx-"`

	// OTLPLogging is a pointer so "unset" can follow the profile format; see
	// SendLogs.
	OTLPLogging *bool `` /* 243-byte string literal not displayed */

	ProbeConfigFile string `` /* 236-byte string literal not displayed */
}

func Parse

func Parse() (Flags, error)

func (Flags) CollectorConfig added in v0.50.1

func (f Flags) CollectorConfig() *config.Config

CollectorConfig maps the flags onto the ebpf-profiler collector's config, so the profiler's own Validate decides which tracer settings are valid, including the minimum kernel version. Fields parca-agent has no flag for take the collector's defaults.

func (Flags) ProfileFormat added in v0.50.0

func (f Flags) ProfileFormat() string

ProfileFormat resolves the effective format, honouring the deprecated --use-v2-schema=false as a request for arrow-v1 so existing invocations keep working. An explicit --remote-store-format always wins.

func (Flags) SendLogs added in v0.50.1

func (f Flags) SendLogs() bool

SendLogs reports whether the agent's own logs should go to the remote store. Unless set explicitly, that is when profiles go there as OTLP: a store that speaks OTLP profiles takes OTLP logs too, while a Parca server would reject them.

func (Flags) Validate

func (f Flags) Validate() ExitCode

type FlagsBPF

type FlagsBPF struct {
	VerboseLogging        bool   `help:"Enable verbose BPF logging from eBPF code to ebpf trace_pipe."`
	LogTracePipe          bool   `help:"Copy bpf trace_pipe to info logging."`
	EventsBufferSize      uint32 `default:"8192"                     help:"Size in pages of the events buffer."`
	MapScaleFactor        int    `` /* 284-byte string literal not displayed */
	CUPTIEventScaleFactor int    `` /* 361-byte string literal not displayed */
	VerifierLogLevel      uint32 `default:"0" help:"Log level of the eBPF verifier output (0,1,2). Default is 0."`
	VerifierLogSize       int    `default:"0" help:"[deprecated] Unused."`
}

type FlagsDWARFUnwinding

type FlagsDWARFUnwinding struct {
	Disable bool `help:"[deprecated] Do not unwind using .eh_frame information."`
	Mixed   bool `default:"true"                                    help:"[deprecated] Unwind using .eh_frame information and frame pointers."`
}

FlagsDWARFUnwinding contains flags to configure DWARF unwinding.

type FlagsDebuginfo

type FlagsDebuginfo struct {
	FlagsGRPC `` /* 226-byte string literal not displayed */

	Directories           []string      `default:"/usr/lib/debug" help:"Ordered list of local directories to search for debuginfo files."`
	TempDir               string        `default:"/tmp"           help:"The local directory path to store the interim debuginfo files."`
	Strip                 bool          `` /* 151-byte string literal not displayed */
	Compress              bool          `default:"false"          help:"Compress debuginfo files' DWARF sections before uploading."`
	UploadDisable         bool          `default:"false"          help:"Disable debuginfo collection and upload."`
	UploadMaxParallel     int           `default:"25"             help:"The maximum number of debuginfo upload requests to make in parallel."`
	UploadTimeoutDuration time.Duration `default:"2m"             help:"The timeout duration to cancel upload requests."`
	UploadCacheDuration   time.Duration `default:"5m"             help:"The duration to cache debuginfo upload responses for."`
	DisableCaching        bool          `default:"false"          help:"Disable caching of debuginfo."`
	UploadQueueSize       uint32        `` /* 141-byte string literal not displayed */
}

FlagsDebuginfo contains flags to configure debuginfo.

type FlagsGRPC added in v0.51.0

type FlagsGRPC struct {
	Address            string `help:"gRPC address to send requests to. ${address_help}"`
	BearerToken        string `help:"Bearer token to authenticate with store." env:"${bearer_token_env}"`
	BearerTokenFile    string `help:"File to read bearer token from to authenticate with store."`
	Insecure           bool   `help:"Send gRPC requests via plaintext instead of TLS."`
	InsecureSkipVerify bool   `help:"Skip TLS certificate verification."`

	RPCUnaryTimeout time.Duration `default:"5m" help:"Maximum timeout window for unary gRPC requests including retries."`

	GRPCMaxCallRecvMsgSize   int               `default:"33554432" help:"The maximum message size the client can receive."`
	GRPCMaxCallSendMsgSize   int               `default:"33554432" help:"The maximum message size the client can send."`
	GRPCStartupBackoffTime   time.Duration     `default:"1m" help:"The time between failed gRPC requests during startup phase."`
	GRPCConnectionTimeout    time.Duration     `default:"3s" help:"The timeout duration for gRPC connection establishment."`
	GRPCMaxConnectionRetries uint32            `default:"5" help:"The maximum number of retries to establish a gRPC connection."`
	GRPCHeaders              map[string]string `help:"Additional gRPC headers to send with each request (key=value pairs)."`

	ClientCert string `help:"Client certificate for mTLS"`
	ClientKey  string `help:"Client key for mTLS"`
}

FlagsGRPC contains connection settings shared by the sample and debuginfo stores.

func (FlagsGRPC) NewGrpcClient added in v0.51.0

func (f FlagsGRPC) NewGrpcClient(reg prometheus.Registerer, tp trace.TracerProvider) (*grpc.ClientConn, error)

NewGrpcClient creates a lazy connection. An unavailable endpoint does not prevent startup; gRPC reconnects on subsequent calls. The caller must Close it. Credentials, TLS, headers, RPC deadlines and retry limits remain endpoint-local.

func (FlagsGRPC) WaitGrpcEndpoint added in v0.51.0

func (f FlagsGRPC) WaitGrpcEndpoint(ctx context.Context, reg prometheus.Registerer, tp trace.TracerProvider) (*grpc.ClientConn, error)

WaitGrpcEndpoint waits until the gRPC connection to the configured store is established.

type FlagsGpuMetrics added in v0.50.1

type FlagsGpuMetrics struct {
	Disable        bool          `` /* 154-byte string literal not displayed */
	ExportInterval time.Duration `default:"10s"   help:"How frequently collected GPU metrics are batched and exported over OTLP."`
}

FlagsGpuMetrics configures NVML-based GPU metrics (utilization, power, temperature, clocks, PCIe throughput, and per-process GPU utilization), exported over OTLP to the remote-store. Only parca-agent builds with the gpumetrics build tag collect them; the static build ignores these flags.

type FlagsGpuNvtx added in v0.50.1

type FlagsGpuNvtx struct {
	Disable        bool    `default:"false" help:"Don't forward NVTX annotations from instrumented CUDA processes."`
	MaxSpansPerSec float64 `` /* 153-byte string literal not displayed */
}

FlagsGpuNvtx configures forwarding of NVTX annotations captured by parcagpu to the remote-store: ranges as OTLP spans (one trace per top-level range), marks as span events, or as log records when no range is open. It is on whenever CUDA is instrumented and the node has NVIDIA GPUs.

type FlagsHidden

type FlagsHidden struct {
	AllowRunningAsNonRoot             bool `` /* 152-byte string literal not displayed */
	AllowRunningInNonRootPIDNamespace bool `` /* 152-byte string literal not displayed */

	ForcePanic bool `default:"false" help:"Panics the agent in a goroutine to test that telemetry works." hidden:""`

	IgnoreUnsafeKernelVersion bool `` /* 127-byte string literal not displayed */

	RateLimitUnwindInfo         uint32 `default:"50" hidden:""`
	RateLimitProcessMappings    uint32 `default:"50" hidden:""`
	RateLimitRefreshProcessInfo uint32 `default:"50" hidden:""`
	RateLimitRead               uint32 `default:"50" hidden:""`
}

FlagsHidden contains hidden flags used for debugging or running with untested configurations.

type FlagsLocalStore

type FlagsLocalStore struct {
	Directory string `help:"The local directory to store the profiling data."`
}

FlagsLocalStore provides local store configuration flags.

type FlagsLogs

type FlagsLogs struct {
	Level  string `default:"info"   enum:"error,warn,info,debug" help:"Log level."`
	Format string `default:"logfmt" enum:"logfmt,json"           help:"Configure if structured logging as JSON or as logfmt"`
}

FlagsLocalStore provides local store configuration flags.

func (FlagsLogs) ConfigureLogger

func (f FlagsLogs) ConfigureLogger()

ConfigureLogger installs the stderr logger for the agent and the profiler.

type FlagsMetadata

type FlagsMetadata struct {
	Discovery                  string            `` /* 217-byte string literal not displayed */
	ExternalLabels             map[string]string `help:"String labels to attach to all profiles and as default resource attributes on all OTLP exports."`
	ContainerRuntimeSocketPath string            `help:"The filesystem path to the container runtimes socket. Leave this empty to use the defaults."`

	DisableCaching       bool `default:"false" help:"[deprecated] Disable caching of metadata."`
	EnableProcessCmdline bool `` /* 142-byte string literal not displayed */

	DisableCPULabel        bool `default:"false" help:"Disable adding the cpu label to profiling data."`
	DisableThreadIDLabel   bool `default:"false" help:"Disable adding the thread_id label to profiling data."`
	DisableThreadCommLabel bool `default:"false" help:"Disable adding the thread_comm label to profiling data."`
}

FlagsMetadata provides metadadata configuration flags.

type FlagsOTLP

type FlagsOTLP struct {
	Address  string `help:"The endpoint to send the agent's own OTLP traces to."`
	Exporter string `default:"grpc" enum:"grpc,http,stdout" help:"The OTLP exporter to use."`
}

FlagsOTLP configures where the agent sends telemetry about *itself*: its own spans, and (with --otlp-logging) its own logs. Profile data does not travel this path -- that is --remote-store-address plus --remote-store-format.

type FlagsObjectFilePool

type FlagsObjectFilePool struct {
	EvictionPolicy string `` /* 286-byte string literal not displayed */
	Size           int    `` /* 226-byte string literal not displayed */
}

type FlagsOfflineMode added in v0.36.0

type FlagsOfflineMode struct {
	StoragePath      string        `` /* 182-byte string literal not displayed */
	RotationInterval time.Duration `default:"10m" help:"[deprecated] How often to rotate and compress the offline mode log."`
	Upload           bool          `help:"[deprecated] Run the uploader for data written in offline mode."`
}

type FlagsProfiling

type FlagsProfiling struct {
	Duration             time.Duration `default:"5s"                                help:"The agent profiling duration to use. Leave this empty to use the defaults."`
	LabelTTL             time.Duration `default:"10m"                               help:"The interval at which the agent will refresh the labels of a tid."`
	CPUSamplingFrequency int           `` /* 131-byte string literal not displayed */

	PerfEventBufferPollInterval       time.Duration `default:"250ms" help:"[deprecated] The interval at which the perf event buffer is polled for new events."`
	PerfEventBufferProcessingInterval time.Duration `default:"100ms" help:"[deprecated] The interval at which the perf event buffer is processed."`
	PerfEventBufferWorkerCount        int           `default:"4"     help:"[deprecated] The number of workers that process the perf event buffer."`

	ProbabilisticInterval  time.Duration `default:"1m" help:"Time interval for which probabilistic profiling will be enabled or disabled."`
	ProbabilisticThreshold uint          `` /* 321-byte string literal not displayed */

	EnableErrorFrames bool `default:"false" help:"Enable collection of error frames."`
}

FlagsProfiling provides profiling configuration flags.

type FlagsRemoteStore

type FlagsRemoteStore struct {
	FlagsGRPC `embed:"" set:"bearer_token_env=PARCA_BEARER_TOKEN" set:"address_help=Sends profiles and, by default, symbols."`

	BatchWriteInterval time.Duration `` /* 130-byte string literal not displayed */
	RPCLoggingEnable   bool          `default:"false" help:"[deprecated] Enable gRPC logging."`

	// Format selects the wire encoding profiles are sent in. It supersedes
	// --use-v2-schema, which was a bool when there were only two encodings.
	Format string `` /* 253-byte string literal not displayed */

	// Compression applies to the OTLP profiles export. The arrow paths carry
	// their own compression inside the IPC payload (v2 uses LZ4), so adding a
	// transport codec on top of them would compress twice.
	//
	// gzip only, because it is the one compressor grpc-go ships on both sides,
	// so every OTLP receiver can decompress it. A codec the receiver has not
	// installed fails at the first flush with "Decompressor is not installed
	// for grpc-encoding <name>", and at the volumes the agent sends -- tens of
	// KiB/s -- a better ratio is not worth a flag value that works against some
	// receivers and not others.
	Compression string `` /* 155-byte string literal not displayed */

	UseV2Schema bool `` /* 218-byte string literal not displayed */
}

FlagsRemoteStore provides remote store configuration flags.

type FlagsSymbolizer

type FlagsSymbolizer struct {
	JITDisable bool `help:"[deprecated] Disable JIT symbolization."`
}

FlagsSymbolizer contains flags to configure symbolization.

type FlagsTelemetry

type FlagsTelemetry struct {
	DisablePanicReporting bool  `default:"false"`
	StderrBufferSizeKb    int64 `default:"4096"`
}

type NoopExporter

type NoopExporter struct{}

func NewNoopExporter

func NewNoopExporter() *NoopExporter

func (NoopExporter) ExportSpans

func (n NoopExporter) ExportSpans(_ context.Context, _ []sdktrace.ReadOnlySpan) error

func (NoopExporter) MarshalLog

func (n NoopExporter) MarshalLog() interface{}

func (NoopExporter) Shutdown

func (n NoopExporter) Shutdown(_ context.Context) error

func (NoopExporter) Start

func (n NoopExporter) Start(_ context.Context) error

type SamplerType

type SamplerType string

Jump to

Keyboard shortcuts

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