Documentation ¶
Overview ¶
Copyright 2024 The Prometheus Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2024 The Prometheus Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // ListMetrics returns the list of metrics and dimensions for a given namespace // and metric name. Results pagination is handled automatically: the caller can // optionally pass a non-nil func in order to handle results pages. ListMetrics(ctx context.Context, namespace string, metric *model.MetricConfig, recentlyActiveOnly bool, fn func(page []*model.Metric)) error // GetMetricData returns the output of the GetMetricData CloudWatch API. // Results pagination is handled automatically. GetMetricData(ctx context.Context, getMetricData []*model.CloudwatchData, namespace string, startTime time.Time, endTime time.Time) []MetricDataResult // GetMetricStatistics returns the output of the GetMetricStatistics CloudWatch API. GetMetricStatistics(ctx context.Context, logger *slog.Logger, dimensions []model.Dimension, namespace string, metric *model.MetricConfig) []*model.Datapoint }
func NewLimitedConcurrencyClient ¶
func NewLimitedConcurrencyClient(client Client, limiter ConcurrencyLimiter) Client
type ConcurrencyConfig ¶
type ConcurrencyConfig struct { // PerAPIEnabled configures whether to have a limit per API call. PerAPILimitEnabled bool // SingleLimit configures the concurrency limit when using a single limiter for api calls. SingleLimit int // ListMetrics limits the number for ListMetrics API concurrent API calls. ListMetrics int // GetMetricData limits the number for GetMetricData API concurrent API calls. GetMetricData int // GetMetricStatistics limits the number for GetMetricStatistics API concurrent API calls. GetMetricStatistics int }
ConcurrencyConfig configures how concurrency should be limited in a Cloudwatch API client. It allows one to pick between different limiter implementations: a single limit limiter, or one with a different limit per API call.
func (ConcurrencyConfig) NewLimiter ¶
func (cfg ConcurrencyConfig) NewLimiter() ConcurrencyLimiter
NewLimiter creates a new ConcurrencyLimiter, according to the ConcurrencyConfig.
type ConcurrencyLimiter ¶
type ConcurrencyLimiter interface { // Acquire takes one "ticket" from the concurrency limiter for op. If there's none available, the caller // routine will be blocked until there's room available. Acquire(op string) // Release gives back one "ticket" to the concurrency limiter identified by op. If there's one or more // routines waiting for one, one will be woken up. Release(op string) }
ConcurrencyLimiter limits the concurrency when calling AWS CloudWatch APIs. The functions implemented by this interface follow the same as a normal semaphore, but accept and operation identifier. Some implementations might use this to keep a different semaphore, with different reentrance values, per operation.
func NewPerAPICallLimiter ¶
func NewPerAPICallLimiter(listMetrics, getMetricData, getMetricStatistics int) ConcurrencyLimiter
NewPerAPICallLimiter creates a new PerAPICallLimiter.
func NewSingleLimiter ¶
func NewSingleLimiter(limit int) ConcurrencyLimiter
NewSingleLimiter creates a new SingleLimiter.