Documentation ¶
Index ¶
- func AbsInt(a int) int
- func ComputeDistance(a *coordinate.Coordinate, b *coordinate.Coordinate) float64
- func DecodeJSON(data io.Reader, out interface{}) error
- func DurationMinusBuffer(intv time.Duration, buffer time.Duration, jitter int64) time.Duration
- func DurationMinusBufferDomain(intv time.Duration, buffer time.Duration, jitter int64) (min time.Duration, max time.Duration)
- func EnsurePath(path string, dir bool) error
- func EnsureTrailingNewline(str string) string
- func GenerateCoordinate(rtt time.Duration) *coordinate.Coordinate
- func GenerateUUID(checkFn UUIDCheckFunc) (string, error)
- func IsErrEOF(err error) bool
- func MapWalk(input interface{}) (map[string]interface{}, error)
- func MaxInt(a, b int) int
- func MaxUint64(a, b uint64) uint64
- func MinInt(a, b int) int
- func RandomStagger(intv time.Duration) time.Duration
- func RandomStaggerWithRange(min time.Duration, max time.Duration) time.Duration
- func RateScaledInterval(rate float64, min time.Duration, n int) time.Duration
- func TranslateKeys(v map[string]interface{}, dict map[string]string)deprecated
- func UnmarshalJSON(data []byte, out interface{}) error
- func UserAgent() string
- type CoordinateSet
- type MetricsConfig
- type MetricsHandler
- type StopChannelContext
- type TelemetryConfig
- type UUIDCheckFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeDistance ¶ added in v0.8.0
func ComputeDistance(a *coordinate.Coordinate, b *coordinate.Coordinate) float64
ComputeDistance returns the distance between the two network coordinates in seconds. If either of the coordinates is nil then this will return positive infinity.
func DecodeJSON ¶ added in v1.16.100
DecodeJSON is a convenience function to create a JSON decoder set it up to disallow unknown fields and then decode into the given value
func DurationMinusBuffer ¶ added in v0.7.0
DurationMinusBuffer returns a duration, minus a buffer and jitter subtracted from the duration. This function is used primarily for servicing Consul TTL Checks in advance of the TTL.
func DurationMinusBufferDomain ¶ added in v0.7.0
func DurationMinusBufferDomain(intv time.Duration, buffer time.Duration, jitter int64) (min time.Duration, max time.Duration)
DurationMinusBufferDomain returns the domain of valid durations from a call to DurationMinusBuffer. This function is used to check user specified input values to DurationMinusBuffer.
func EnsurePath ¶ added in v0.7.3
EnsurePath is used to make sure a path exists
func EnsureTrailingNewline ¶ added in v1.16.100
EnsureTrailingNewline adds a newline suffix to the input if not present. This is typically used to fix a case where the CA provider does not return a new line after certificates as per the specification. See GH-8178 for more context.
func GenerateCoordinate ¶ added in v0.8.0
func GenerateCoordinate(rtt time.Duration) *coordinate.Coordinate
GenerateCoordinate creates a new coordinate with the given distance from the origin. This should only be used for tests.
func GenerateUUID ¶ added in v1.4.0
func GenerateUUID(checkFn UUIDCheckFunc) (string, error)
func IsErrEOF ¶ added in v1.0.0
IsErrEOF returns true if we get an EOF error from the socket itself, or an EOF equivalent error from yamux.
func MapWalk ¶ added in v1.16.100
MapWalk will traverse through the supplied input which should be a map[string]interface{} (or something compatible that we can coerce to a map[string]interface{}) and from it create a new map[string]interface{} with all internal values coerced to JSON compatible types. i.e. a []uint8 can be converted (in most cases) to a string so it will not be base64 encoded when output in JSON
func RandomStagger ¶
RandomStagger returns an interval between 0 and the duration
func RandomStaggerWithRange ¶ added in v1.16.100
RandomStaggerWithRange returns an interval between min and the max duration
func RateScaledInterval ¶
RateScaledInterval is used to choose an interval to perform an action in order to target an aggregate number of actions per second across the whole cluster.
func TranslateKeys
deprecated
added in
v1.16.100
TranslateKeys recursively translates all keys from m in-place to their canonical form as defined in dict which maps an alias name to the canonical name. If m already has a value for the canonical name then that one is used and the value for the alias name is discarded. Alias names are matched case-insensitive.
Example:
m = TranslateKeys(m, map[string]string{"snake_case": "CamelCase"})
If the canonical string provided is the empty string, the effect is to stop recursing into any key matching the left hand side. In this case the left hand side must use periods to specify a full path e.g. `connect.proxy.config`. The path must be the canonical key names (i.e. CamelCase) AFTER translation so NodeName not node_name. These are still match in a case-insensitive way.
This is needed for example because parts of the Service Definition are "opaque" maps of metadata or config passed to another process or component. If we allow translation to recurse we might mangle the "opaque" keys given where the clash with key names in other parts of the definition :sob:
Example:
m - TranslateKeys(m, map[string]string{ "foo_bar": "FooBar", "widget.config": "", // Assume widgets is an array, this will prevent recursing into any // item's config field "widgets.config": "", })
Deprecated: Use lib/decode.HookTranslateKeys instead.
func UnmarshalJSON ¶ added in v1.16.100
UnmarshalJSON is a convenience function around calling DecodeJSON. It will mainly be useful in many of our UnmarshalJSON methods for structs.
Types ¶
type CoordinateSet ¶ added in v0.9.3
type CoordinateSet map[string]*coordinate.Coordinate
CoordinateSet holds all the coordinates for a given node, indexed by network segment name.
func (CoordinateSet) Intersect ¶ added in v0.9.3
func (cs CoordinateSet) Intersect(other CoordinateSet) (*coordinate.Coordinate, *coordinate.Coordinate)
Intersect tries to return a pair of coordinates which are compatible with the current set and a given set. We employ some special knowledge about network segments to avoid doing a full intersection, since this is in several hot paths. This might return nil for either coordinate in the output pair if an intersection cannot be found. The ComputeDistance function above is designed to deal with that.
type MetricsConfig ¶ added in v1.16.100
type MetricsConfig struct { Handler MetricsHandler // contains filtered or unexported fields }
func InitTelemetry ¶ added in v1.2.0
func InitTelemetry(cfg TelemetryConfig, logger hclog.Logger, extraSinks ...metrics.MetricSink) (*MetricsConfig, error)
InitTelemetry configures go-metrics based on map of telemetry config values as returned by Runtimecfg.Config(). InitTelemetry retries configurating the sinks in case error is retriable and retry_failed_connection is set to true.
func (*MetricsConfig) Cancel ¶ added in v1.16.100
func (cfg *MetricsConfig) Cancel()
type MetricsHandler ¶ added in v1.16.100
type MetricsHandler interface { DisplayMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error) Stream(ctx context.Context, encoder metrics.Encoder) }
MetricsHandler provides an http.Handler for displaying metrics.
type StopChannelContext ¶ added in v1.4.0
type StopChannelContext struct {
StopCh <-chan struct{}
}
StopChannelContext implements the context.Context interface You provide the channel to select on to determine whether the context should be canceled and other code such as the rate.Limiter will automatically use the channel appropriately
func (*StopChannelContext) Deadline ¶ added in v1.4.0
func (c *StopChannelContext) Deadline() (deadline time.Time, ok bool)
func (*StopChannelContext) Done ¶ added in v1.4.0
func (c *StopChannelContext) Done() <-chan struct{}
func (*StopChannelContext) Err ¶ added in v1.4.0
func (c *StopChannelContext) Err() error
func (*StopChannelContext) Value ¶ added in v1.4.0
func (c *StopChannelContext) Value(key interface{}) interface{}
type TelemetryConfig ¶ added in v1.2.0
type TelemetryConfig struct { // Disable may be set to true to have InitTelemetry to skip initialization // and return a nil MetricsSink. Disable bool // CirconusAPIApp is an app name associated with API token. // Default: "consul" // // hcl: telemetry { circonus_api_app = string } CirconusAPIApp string `json:"circonus_api_app,omitempty" mapstructure:"circonus_api_app"` // CirconusAPIToken is a valid API Token used to create/manage check. If provided, // metric management is enabled. // Default: none // // hcl: telemetry { circonus_api_token = string } CirconusAPIToken string `json:"circonus_api_token,omitempty" mapstructure:"circonus_api_token"` // CirconusAPIURL is the base URL to use for contacting the Circonus API. // Default: "https://api.circonus.com/v2" // // hcl: telemetry { circonus_api_url = string } CirconusAPIURL string `json:"circonus_apiurl,omitempty" mapstructure:"circonus_apiurl"` // CirconusBrokerID is an explicit broker to use when creating a new check. The numeric portion // of broker._cid. If metric management is enabled and neither a Submission URL nor Check ID // is provided, an attempt will be made to search for an existing check using Instance ID and // Search Tag. If one is not found, a new HTTPTRAP check will be created. // Default: use Select Tag if provided, otherwise, a random Enterprise Broker associated // with the specified API token or the default Circonus Broker. // Default: none // // hcl: telemetry { circonus_broker_id = string } CirconusBrokerID string `json:"circonus_broker_id,omitempty" mapstructure:"circonus_broker_id"` // CirconusBrokerSelectTag is a special tag which will be used to select a broker when // a Broker ID is not provided. The best use of this is to as a hint for which broker // should be used based on *where* this particular instance is running. // (e.g. a specific geo location or datacenter, dc:sfo) // Default: none // // hcl: telemetry { circonus_broker_select_tag = string } CirconusBrokerSelectTag string `json:"circonus_broker_select_tag,omitempty" mapstructure:"circonus_broker_select_tag"` // CirconusCheckDisplayName is the name for the check which will be displayed in the Circonus UI. // Default: value of CirconusCheckInstanceID // // hcl: telemetry { circonus_check_display_name = string } CirconusCheckDisplayName string `json:"circonus_check_display_name,omitempty" mapstructure:"circonus_check_display_name"` // CirconusCheckForceMetricActivation will force enabling metrics, as they are encountered, // if the metric already exists and is NOT active. If check management is enabled, the default // behavior is to add new metrics as they are encountered. If the metric already exists in the // check, it will *NOT* be activated. This setting overrides that behavior. // Default: "false" // // hcl: telemetry { circonus_check_metrics_activation = (true|false) CirconusCheckForceMetricActivation string `json:"circonus_check_force_metric_activation,omitempty" mapstructure:"circonus_check_force_metric_activation"` // CirconusCheckID is the check id (not check bundle id) from a previously created // HTTPTRAP check. The numeric portion of the check._cid field. // Default: none // // hcl: telemetry { circonus_check_id = string } CirconusCheckID string `json:"circonus_check_id,omitempty" mapstructure:"circonus_check_id"` // CirconusCheckInstanceID serves to uniquely identify the metrics coming from this "instance". // It can be used to maintain metric continuity with transient or ephemeral instances as // they move around within an infrastructure. // Default: hostname:app // // hcl: telemetry { circonus_check_instance_id = string } CirconusCheckInstanceID string `json:"circonus_check_instance_id,omitempty" mapstructure:"circonus_check_instance_id"` // CirconusCheckSearchTag is a special tag which, when coupled with the instance id, helps to // narrow down the search results when neither a Submission URL or Check ID is provided. // Default: service:app (e.g. service:consul) // // hcl: telemetry { circonus_check_search_tag = string } CirconusCheckSearchTag string `json:"circonus_check_search_tag,omitempty" mapstructure:"circonus_check_search_tag"` // CirconusCheckSearchTag is a special tag which, when coupled with the instance id, helps to // narrow down the search results when neither a Submission URL or Check ID is provided. // Default: service:app (e.g. service:consul) // // hcl: telemetry { circonus_check_tags = string } CirconusCheckTags string `json:"circonus_check_tags,omitempty" mapstructure:"circonus_check_tags"` // CirconusSubmissionInterval is the interval at which metrics are submitted to Circonus. // Default: 10s // // hcl: telemetry { circonus_submission_interval = "duration" } CirconusSubmissionInterval string `json:"circonus_submission_interval,omitempty" mapstructure:"circonus_submission_interval"` // CirconusCheckSubmissionURL is the check.config.submission_url field from a // previously created HTTPTRAP check. // Default: none // // hcl: telemetry { circonus_submission_url = string } CirconusSubmissionURL string `json:"circonus_submission_url,omitempty" mapstructure:"circonus_submission_url"` // DisableHostname will disable hostname prefixing for all metrics. // // hcl: telemetry { disable_hostname = (true|false) DisableHostname bool `json:"disable_hostname,omitempty" mapstructure:"disable_hostname"` // DogStatsdAddr is the address of a dogstatsd instance. If provided, // metrics will be sent to that instance // // hcl: telemetry { dogstatsd_addr = string } DogstatsdAddr string `json:"dogstatsd_addr,omitempty" mapstructure:"dogstatsd_addr"` // DogStatsdTags are the global tags that should be sent with each packet to dogstatsd // It is a list of strings, where each string looks like "my_tag_name:my_tag_value" // // hcl: telemetry { dogstatsd_tags = []string } DogstatsdTags []string `json:"dogstatsd_tags,omitempty" mapstructure:"dogstatsd_tags"` // RetryFailedConfiguration retries transient errors when setting up sinks (e.g. network errors when connecting to telemetry backends). // // hcl: telemetry { retry_failed_connection = (true|false) } RetryFailedConfiguration bool `json:"retry_failed_connection,omitempty" mapstructure:"retry_failed_connection"` // FilterDefault is the default for whether to allow a metric that's not // covered by the filter. // // hcl: telemetry { filter_default = (true|false) } FilterDefault bool `json:"filter_default,omitempty" mapstructure:"filter_default"` // AllowedPrefixes is a list of filter rules to apply for allowing metrics // by prefix. Use the 'prefix_filter' option and prefix rules with '+' to be // included. // // hcl: telemetry { prefix_filter = []string{"+<expr>", "+<expr>", ...} } AllowedPrefixes []string `json:"allowed_prefixes,omitempty" mapstructure:"allowed_prefixes"` // BlockedPrefixes is a list of filter rules to apply for blocking metrics // by prefix. Use the 'prefix_filter' option and prefix rules with '-' to be // excluded. // // hcl: telemetry { prefix_filter = []string{"-<expr>", "-<expr>", ...} } BlockedPrefixes []string `json:"blocked_prefixes,omitempty" mapstructure:"blocked_prefixes"` // MetricsPrefix is the prefix used to write stats values to. // Default: "consul." // // hcl: telemetry { metrics_prefix = string } MetricsPrefix string `json:"metrics_prefix,omitempty" mapstructure:"metrics_prefix"` // StatsdAddr is the address of a statsd instance. If provided, // metrics will be sent to that instance. // // hcl: telemetry { statsd_address = string } StatsdAddr string `json:"statsd_address,omitempty" mapstructure:"statsd_address"` // StatsiteAddr is the address of a statsite instance. If provided, // metrics will be streamed to that instance. // // hcl: telemetry { statsite_address = string } StatsiteAddr string `json:"statsite_address,omitempty" mapstructure:"statsite_address"` // EnableHostMetrics will enable metrics collected about the host system such as cpu memory and disk usage. // // hcl: telemetry { enable_host_metrics = (true|false) } EnableHostMetrics bool `json:"enable_host_metrics,omitempty" mapstructure:"enable_host_metrics"` // PrometheusOpts provides configuration for the PrometheusSink. Currently the only configuration // we acquire from hcl is the retention time. We also use definition slices that are set in agent setup // before being passed to InitTelemmetry. // // hcl: telemetry { prometheus_retention_time = "duration" } PrometheusOpts prometheus.PrometheusOpts }
TelemetryConfig is embedded in config.RuntimeConfig and holds the configuration variables for go-metrics. It is a separate struct to allow it to be exported as JSON and passed to other process like managed connect proxies so they can inherit the agent's telemetry config.
It is in lib package rather than agent/config because we need to use it in the shared InitTelemetry functions below, but we can't import agent/config due to a dependency cycle.
type UUIDCheckFunc ¶ added in v1.4.0
UUIDCheckFunc should determine whether the given UUID is actually unique and allowed to be used
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package decode provides tools for customizing the decoding of configuration, into structures using mapstructure.
|
Package decode provides tools for customizing the decoding of configuration, into structures using mapstructure. |
Package mutex implements the sync.Locker interface using x/sync/semaphore.
|
Package mutex implements the sync.Locker interface using x/sync/semaphore. |
Package semaphore implements a simple semaphore that is based on golang.org/x/sync/semaphore but doesn't support weights.
|
Package semaphore implements a simple semaphore that is based on golang.org/x/sync/semaphore but doesn't support weights. |
Package ttlcache provides an ExpiryHeap that can be used by a cache to track the expiration time of its entries.
|
Package ttlcache provides an ExpiryHeap that can be used by a cache to track the expiration time of its entries. |