Documentation
¶
Index ¶
- func Execute(version string)
- func FormatVersion(version, commit, date string) string
- func GetExitCode() int
- type BgEnd
- type BgSpan
- type BgSpanEvent
- type Config
- func (c *Config) LoadEnv(getenv func(string) string) error
- func (c *Config) LoadFile() error
- func (c Config) ToStringMap() map[string]string
- func (c Config) WithAttributes(with map[string]string) Config
- func (c Config) WithBackgroundParentPollMs(with int) Config
- func (c Config) WithBackgroundSockdir(with string) Config
- func (c Config) WithBackgroundWait(with bool) Config
- func (c Config) WithBlocking(with bool) Config
- func (c Config) WithCfgFile(with string) Config
- func (c Config) WithEndpoint(with string) Config
- func (c Config) WithEventName(with string) Config
- func (c Config) WithEventTime(with string) Config
- func (c Config) WithFail(with bool) Config
- func (c Config) WithHeaders(with map[string]string) Config
- func (c Config) WithInsecure(with bool) Config
- func (c Config) WithKind(with string) Config
- func (c Config) WithNoTlsVerify(with bool) Config
- func (c Config) WithProtocol(with string) Config
- func (c Config) WithServiceName(with string) Config
- func (c Config) WithSpanEndTime(with string) Config
- func (c Config) WithSpanName(with string) Config
- func (c Config) WithSpanStartTime(with string) Config
- func (c Config) WithStatusCode(with string) Config
- func (c Config) WithStatusDescription(with string) Config
- func (c Config) WithTimeout(with string) Config
- func (c Config) WithTraceparentCarrierFile(with string) Config
- func (c Config) WithTraceparentIgnoreEnv(with bool) Config
- func (c Config) WithTraceparentPrint(with bool) Config
- func (c Config) WithTraceparentPrintExport(with bool) Config
- func (c Config) WithTraceparentRequired(with bool) Config
- func (c Config) WithVerbose(with bool) Config
- type Diagnostics
- type OtelCliCarrier
- type StatusOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(version string)
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func FormatVersion ¶ added in v0.1.0
FormatVersion pretty-prints the global version, commit, and date values into a string to enable the --version flag. Public to be called from main.
func GetExitCode ¶
func GetExitCode() int
GetExitCode() is a helper for Cobra to retrieve the exit code, mainly used by exec to make otel-cli return the child program's exit code.
Types ¶
type BgSpan ¶
type BgSpan struct { TraceID string `json:"trace_id"` SpanID string `json:"span_id"` Traceparent string `json:"traceparent"` Error string `json:"error"` // contains filtered or unexported fields }
BgSpan is what is returned to all RPC clients and its methods are exported.
func (BgSpan) AddEvent ¶
func (bs BgSpan) AddEvent(bse *BgSpanEvent, reply *BgSpan) error
AddEvent takes a BgSpanEvent from the client and attaches an event to the span.
type BgSpanEvent ¶
type BgSpanEvent struct { Name string `json:"name"` Timestamp string `json:"timestamp"` Attributes map[string]string }
BgSpanEvent is a span event that the client will send.
type Config ¶
type Config struct { Endpoint string `json:"endpoint" env:"OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"` Protocol string `json:"protocol" env:"OTEL_EXPORTER_OTLP_PROTOCOL,OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"` Timeout string `json:"timeout" env:"OTEL_EXPORTER_OTLP_TIMEOUT,OTEL_EXPORTER_OTLP_TRACES_TIMEOUT"` Headers map[string]string `json:"otlp_headers" env:"OTEL_EXPORTER_OTLP_HEADERS"` // TODO: needs json marshaler hook to mask tokens Insecure bool `json:"insecure" env:"OTEL_EXPORTER_OTLP_INSECURE"` Blocking bool `json:"otlp_blocking" env:"OTEL_EXPORTER_OTLP_BLOCKING"` NoTlsVerify bool `json:"no_tls_verify" env:"OTEL_CLI_NO_TLS_VERIFY"` ServiceName string `json:"service_name" env:"OTEL_CLI_SERVICE_NAME"` SpanName string `json:"span_name" env:"OTEL_CLI_SPAN_NAME"` Kind string `json:"span_kind" env:"OTEL_CLI_TRACE_KIND"` Attributes map[string]string `json:"span_attributes" env:"OTEL_CLI_ATTRIBUTES"` StatusCode string `json:"span_status_code" env:"OTEL_CLI_STATUS_CODE"` StatusDescription string `json:"span_status_description" env:"OTEL_CLI_STATUS_DESCRIPTION"` TraceparentCarrierFile string `json:"traceparent_carrier_file" env:"OTEL_CLI_CARRIER_FILE"` TraceparentIgnoreEnv bool `json:"traceparent_ignore_env" env:"OTEL_CLI_IGNORE_ENV"` TraceparentPrint bool `json:"traceparent_print" env:"OTEL_CLI_PRINT_TRACEPARENT"` TraceparentPrintExport bool `json:"traceparent_print_export" env:"OTEL_CLI_EXPORT_TRACEPARENT"` TraceparentRequired bool `json:"traceparent_required" env:"OTEL_CLI_TRACEPARENT_REQUIRED"` BackgroundParentPollMs int `json:"background_parent_poll_ms" env:""` BackgroundSockdir string `json:"background_socket_directory" env:""` BackgroundWait bool `json:"background_wait" env:""` SpanStartTime string `json:"span_start_time" env:""` SpanEndTime string `json:"span_end_time" env:""` EventName string `json:"event_name" env:""` EventTime string `json:"event_time" env:""` CfgFile string `json:"config_file" env:"OTEL_CLI_CONFIG_FILE"` Verbose bool `json:"verbose" env:"OTEL_CLI_VERBOSE"` Fail bool `json:"fail" env:"OTEL_CLI_FAIL"` }
Config stores the runtime configuration for otel-cli. This is used as a singleton as "config" and accessed from many other files. Data structure is public so that it can serialize to json easily.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with all defaults set.
func (*Config) LoadEnv ¶ added in v0.1.0
LoadEnv loads environment variables into the config, overwriting current values. Environment variable to config key mapping is tagged on the Config struct. Multiple names for envvars is supported, comma-separated. Takes a func(string)string that's usually os.Getenv, and is swappable to make testing easier.
func (*Config) LoadFile ¶ added in v0.1.0
LoadFile reads the file specified by -c/--config and overwrites the current config values with any found in the file.
func (Config) ToStringMap ¶
ToStringMap flattens the configuration into a stringmap that is easy to work with in tests especially with cmp.Diff. See test_main.go.
func (Config) WithAttributes ¶
WithAttributes returns the config with Attributes set to the provided value.
func (Config) WithBackgroundParentPollMs ¶
WithBackgroundParentPollMs returns the config with BackgroundParentPollMs set to the provided value.
func (Config) WithBackgroundSockdir ¶
WithBackgroundSockdir returns the config with BackgroundSockdir set to the provided value.
func (Config) WithBackgroundWait ¶
WithBackgroundWait returns the config with BackgroundWait set to the provided value.
func (Config) WithBlocking ¶
WithBlocking returns the config with Blocking set to the provided value.
func (Config) WithCfgFile ¶
WithCfgFile returns the config with CfgFile set to the provided value.
func (Config) WithEndpoint ¶
WithEndpoint returns the config with Endpoint set to the provided value.
func (Config) WithEventName ¶
WithEventName returns the config with EventName set to the provided value.
func (Config) WithEventTime ¶
WithEventTIme returns the config with EventTIme set to the provided value.
func (Config) WithFail ¶ added in v0.1.0
WithFail returns the config with Fail set to the provided value.
func (Config) WithHeaders ¶
WithHeades returns the config with Heades set to the provided value.
func (Config) WithInsecure ¶
WithInsecure returns the config with Insecure set to the provided value.
func (Config) WithNoTlsVerify ¶
WithNoTlsVerify returns the config with NoTlsVerify set to the provided value.
func (Config) WithProtocol ¶ added in v0.1.0
WithProtocol returns the config with protocol set to the provided value.
func (Config) WithServiceName ¶
WithServiceName returns the config with ServiceName set to the provided value.
func (Config) WithSpanEndTime ¶
WithSpanEndTime returns the config with SpanEndTime set to the provided value.
func (Config) WithSpanName ¶
WithSpanName returns the config with SpanName set to the provided value.
func (Config) WithSpanStartTime ¶
WithSpanStartTime returns the config with SpanStartTime set to the provided value.
func (Config) WithStatusCode ¶ added in v0.1.0
WithStatusCode returns the config with StatusCode set to the provided value.
func (Config) WithStatusDescription ¶ added in v0.1.0
WithStatusDescription returns the config with StatusDescription set to the provided value.
func (Config) WithTimeout ¶
WithTimeout returns the config with Timeout set to the provided value.
func (Config) WithTraceparentCarrierFile ¶
WithTraceparentCarrierFile returns the config with TraceparentCarrierFile set to the provided value.
func (Config) WithTraceparentIgnoreEnv ¶
WithTraceparentIgnoreEnv returns the config with TraceparentIgnoreEnv set to the provided value.
func (Config) WithTraceparentPrint ¶
WithTraceparentPrint returns the config with TraceparentPrint set to the provided value.
func (Config) WithTraceparentPrintExport ¶
WithTraceparentPrintExport returns the config with TraceparentPrintExport set to the provided value.
func (Config) WithTraceparentRequired ¶
WithTraceparentRequired returns the config with TraceparentRequired set to the provided value.
func (Config) WithVerbose ¶
WithVerbose returns the config with Verbose set to the provided value.
type Diagnostics ¶
type Diagnostics struct { CliArgs []string `json:"cli_args"` IsRecording bool `json:"is_recording"` ConfigFileLoaded bool `json:"config_file_loaded"` NumArgs int `json:"number_of_args"` DetectedLocalhost bool `json:"detected_localhost"` ParsedTimeoutMs int64 `json:"parsed_timeout_ms"` OtelError string `json:"otel_error"` ExecExitCode int `json:"exec_exit_code"` }
Diagnostics is a place to put things that are useful for testing and diagnosing issues with otel-cli. The only user-facing feature that should be using these is otel-cli status.
func (Diagnostics) Handle ¶
func (Diagnostics) Handle(err error)
Handle complies with the otel error handler interface to capture errors both for diagnostics and to make sure the error output goes through softLog so it doesn't pollute output of caller scripts. hack: ignores the Diagnostics assigned to it and writes to the global
func (*Diagnostics) ToStringMap ¶
func (d *Diagnostics) ToStringMap() map[string]string
ToMap returns the Diagnostics struct as a string map for testing.
type OtelCliCarrier ¶
type OtelCliCarrier struct{}
OtelCliCarrier implements the OpenTelemetry TextMapCarrier interface that supports only one key/value for the traceparent and does nothing else
func NewOtelCliCarrier ¶
func NewOtelCliCarrier() OtelCliCarrier
func (OtelCliCarrier) Clear ¶
func (ec OtelCliCarrier) Clear()
Clear sets the traceparent to empty string. Mainly for testing.
func (OtelCliCarrier) Get ¶
func (ec OtelCliCarrier) Get(key string) string
Get returns the traceparent string if key is "traceparent" otherwise nothing
func (OtelCliCarrier) Keys ¶
func (ec OtelCliCarrier) Keys() []string
Keys returns a list of strings containing just "traceparent"
func (OtelCliCarrier) Set ¶
func (ec OtelCliCarrier) Set(key string, value string)
Set sets the global traceparent if key is "traceparent" otherwise nothing
type StatusOutput ¶
type StatusOutput struct { Config Config `json:"config"` SpanData map[string]string `json:"span_data"` Env map[string]string `json:"env"` Diagnostics Diagnostics `json:"diagnostics"` }
StatusOutput captures all the data we want to print out for this subcommand and is also used in ../main_test.go for automated testing.