Skip to content

Commit bccc121

Browse files
Review docs about embedding yace (prometheus-community#868)
1 parent a17342f commit bccc121

File tree

4 files changed

+26
-29
lines changed

4 files changed

+26
-29
lines changed

README.md

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ To provide backwards compatibility, some of YACE's new features or breaking chan
113113

114114
## Installing and running
115115

116-
Refer to the [installing guide](docs/install.md).
116+
Refer to the [installation guide](docs/installation.md).
117117

118118
## Authentication
119119

@@ -278,31 +278,9 @@ This protects from the abuse of API requests that can cause extra billing in AWS
278278
The flag 'scraping-interval' defines the seconds between scrapes.
279279
The default value is 300.
280280
281-
## Using YACE as a Go library
282-
283-
It is possible to embed YACE in to an external application. This mode might be useful to you if you would like to scrape on demand or run in a stateless manner.
284-
285-
The entrypoint to use YACE as a library is the `UpdateMetrics` func in [update.go](./pkg/exporter.go#L35) which requires,
286-
- `config`: this is the struct representation of the configuration defined in [Top Level Configuration](#top-level-configuration)
287-
- `registry`: any prometheus compatible registry where scraped AWS metrics will be written
288-
- `metricsPerQuery`: controls the same behavior defined by the CLI flag `metrics-per-query`
289-
- `labelsSnakeCase`: controls the same behavior defined by the CLI flag `labels-snake-case`
290-
- `cloudwatchSemaphore`/`tagSemaphore`: adjusts the concurrency of requests as defined by [Requests concurrency](#requests-concurrency). Pass in a different length channel to adjust behavior
291-
- `cache`
292-
- Any implementation of the [SessionCache Interface](./pkg/session/sessions.go#L41)
293-
- `session.NewSessionCache(config, <fips value>)` would be the default
294-
- `<fips value>` is defined by the `fips` CLI flag
295-
- `observedMetricLabels`
296-
- Prometheus requires that all metrics exported with the same key have the same labels
297-
- This map will track all labels observed and ensure they are exported on all metrics with the same key in the provided `registry`
298-
- You should provide the same instance of this map if you intend to re-use the `registry` between calls
299-
- `logger`
300-
- Any implementation of the [Logger Interface](./pkg/logging/logger.go#L13)
301-
- `logging.NewLogger(logrus.StandardLogger())` is an acceptable default
302-
303-
The update definition also includes an exported slice of [Metrics](./pkg/exporter.go#L18) which includes AWS API call metrics. These can be registered with the provided `registry` if you want them
304-
included in the AWS scrape results. If you are using multiple instances of `registry` it might make more sense to register these metrics in the application using YACE as a library to better
305-
track them over the lifetime of the application.
281+
## Embedding YACE in your application
282+
283+
YACE can be used as a library and embedded into your application, see the [embedding guide](docs/embedding.md).
306284
307285
## Troubleshooting / Debugging
308286

docs/embedding.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Embedding YACE in your application
2+
3+
It is possible to embed YACE into an external Go application. This mode might be useful to you if you would like to scrape on demand or run in a stateless manner.
4+
5+
See [`exporter.UpdateMetrics()`](https://pkg.go.dev/github.com/nerdswords/[email protected]/pkg#UpdateMetrics) for the documentation of the exporter entrypoint.
6+
7+
Applications embedding YACE:
8+
- [Grafana Agent](https://github.com/grafana/agent/tree/release-v0.33/pkg/integrations/cloudwatch_exporter)
File renamed without changes.

pkg/exporter.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,20 @@ func EnableFeatureFlag(flags ...string) OptionsFunc {
114114
}
115115
}
116116

117-
// UpdateMetrics can be used to scrape metrics from AWS on demand using the provided parameters. Scraped metrics will be added to the provided registry and
118-
// any labels discovered during the scrape will be added to observedMetricLabels with their metric name as the key. Any errors encountered are not returned but
119-
// will be logged and will either fail the scrape or a partial metric result will be added to the registry.
117+
// UpdateMetrics is the entrypoint to scrape metrics from AWS on demand.
118+
//
119+
// Parameters are:
120+
// - `ctx`: a context for the request
121+
// - `config`: this is the struct representation of the configuration defined in top-level configuration
122+
// - `logger`: any implementation of the `Logger` interface
123+
// - `registry`: any prometheus compatible registry where scraped AWS metrics will be written
124+
// - `cache`: any implementation of the `SessionCache`
125+
// - `optFuncs`: (optional) any number of options funcs
126+
//
127+
// You can pre-register any of the default metrics with the provided `registry` if you want them
128+
// included in the AWS scrape results. If you are using multiple instances of `registry` it
129+
// might make more sense to register these metrics in the application using YACE as a library to better
130+
// track them over the lifetime of the application.
120131
func UpdateMetrics(
121132
ctx context.Context,
122133
logger logging.Logger,

0 commit comments

Comments
 (0)