Documentation ¶
Index ¶
- func Execute()
- func GetExitCode() int
- type BgEnd
- type BgSpan
- type BgSpanEvent
- type Config
- func (c Config) ToStringMap() map[string]string
- func (c *Config) UnmarshalJSON(js []byte) error
- 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) 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) 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) 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()
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 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"` Timeout string `json:"timeout"` Headers map[string]string `json:"headers"` // TODO: needs json marshaler hook to mask tokens Insecure bool `json:"insecure"` Blocking bool `json:"blocking"` NoTlsVerify bool `json:"no_tls_verify"` ServiceName string `json:"service_name"` SpanName string `json:"span_name"` Kind string `json:"span_kind"` Attributes map[string]string `json:"span_attributes"` TraceparentCarrierFile string `json:"traceparent_carrier_file"` TraceparentIgnoreEnv bool `json:"traceparent_ignore_env"` TraceparentPrint bool `json:"traceparent_print"` TraceparentPrintExport bool `json:"traceparent_print_export"` TraceparentRequired bool `json:"traceparent_required"` BackgroundParentPollMs int `json:"background_parent_poll_ms"` BackgroundSockdir string `json:"background_socket_directory"` BackgroundWait bool `json:"background_wait"` SpanStartTime string `json:"span_start_time"` SpanEndTime string `json:"span_end_time"` EventName string `json:"event_name"` EventTime string `json:"event_time"` CfgFile string `json:"config_file"` Verbose bool `json:"verbose"` }
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) 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) UnmarshalJSON ¶
UnmarshalJSON makes sure that any Config loaded from JSON has its default values set. This is critical to comparisons in the otel-cli test suite.
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) 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) 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) 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 is used in ../main_test.go for automated testing.