-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[awsemfexporter] Implement metric filtering and dimension setting #1503
[awsemfexporter] Implement metric filtering and dimension setting #1503
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1503 +/- ##
==========================================
+ Coverage 89.24% 89.29% +0.04%
==========================================
Files 354 355 +1
Lines 17417 17501 +84
==========================================
+ Hits 15544 15627 +83
- Misses 1395 1397 +2
+ Partials 478 477 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
a736ad0
to
e6c1ff3
Compare
@anuraaga @james-bebbington could you help review this PR? Thanks :) |
func (m *MetricDeclaration) Init(logger *zap.Logger) (err error) { | ||
// Return error if no metric name selectors are defined | ||
if len(m.MetricNameSelectors) == 0 { | ||
return errors.New("invalid metric declaration: no metric name selectors defined") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user inputs an incorrect config, is this the log message they will see? Is it enough information to fix the config issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They would see the message "Dropped metric declaration. Error: invalid metric declaration: no metric name selectors defined."
. I think this is sufficient as it tells the user that a metric has been dropped due to no metric name selectors defined. I'm open to suggestions on how to make this better though
for _, dimSet := range m.Dimensions { | ||
concatenatedDims := strings.Join(dimSet, ",") | ||
if len(dimSet) > 10 { | ||
logger.Warn("Dropped dimension set: > 10 dimensions specified.", zap.String("dimensions", concatenatedDims)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, these warnings only happen on startup? Even so we might use debug logging, I think collector generally leans towards less logging messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, this only happens on startup. In this case, would it be ok to use Warn
since it's only once on startup? I feel that this information is useful for the user to fix in case they don't enable Debug
level logging.
Just some small comments, thanks |
@kohrapha I see that you need to make some small updates, ping me when things are done. |
* Implement dimension dedup logic when adding rolledup dimensions * Remove duplicated dimensions in metric declaration
…tCwMeasurementEqual for tests
32dbc0d
to
80a42c0
Compare
@bogdandrutu Made the changes as response to @anuraaga's comments and rebased off the new changes from |
…en-telemetry#1503) * Create MetricDeclaration struct * Implement dimension dedup logic when adding rolledup dimensions (open-telemetry#6) * Implement dimension dedup logic when adding rolledup dimensions * Remove duplicated dimensions in metric declaration * Create benchmark for filtering with metric declarations and use assertCwMeasurementEqual for tests * Move helper test code to the top of file * Update dimRollup test * Aggregate dimensions and perform dedup * Minor code change * Fix test failure from merging new changes
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.35.2 to 1.36.0. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](golangci/golangci-lint@v1.35.2...v1.36.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description
Problem
Currently, the EMF Exporter does not provide any configuration for defining the dimensions for exported metrics or which metrics should be exported. All incoming metrics are exported with their label set as the exported dimension. A few problems arise, including:
Solution
This PR solves both issues by defining a new
metric_declarations
(optional) attribute that allows the user to define the dimensions for exported metrics and filter by metric names. Specifically, themetric_declarations
is a list ofmetric_declaration
s with the following API spec:<metric_declaration>
Each metric declaration characterizes a rule to be used to set dimensions for certain incoming metrics, filtered by their metric names.
Example config
Note that the
metric_declarations
attribute is optional. If this section is left out of the config file, the exporter defaults to exporting all labels as a dimension set, as is done currently. Each incoming metric is matched against each metric declaration rule. If it matches at least one of themetric_name_selectors
, the corresponding rule is applied. Each dimension set specified by the rule is applied to the exported metric if and only if the metric has all the dimensions in that dimension set.All of the dimension sets across all metric declarations are aggregated together and applied to the metric. In other words, if a metric matches multiple rules, all valid dimensions specified by those rules will be put into a single list of dimension sets. Additionally, any rolled-up dimensions are also added to this set. De-duplication is applied across the final list of dimension sets.
De-duplication functionality
We also help the user perform de-duplication of dimensions. 2 dimension sets are considered duplicate if they contain the same set of unique dimensions (order is irrelevant). There are 3 cases for duplicated dimensions:
['dim1', 'dim2', 'dim1']
->['dim1', 'dim2']
[['dim1', 'dim2'], ['dim2', 'dim1']]
->[['dim1', 'dim2']]
Documentation
The documentation for the AWS EMF Exporter was updated to include the new
metric_declarations
attribute and its API spec.Testing
go_goroutines
:go_memstats_alloc_bytes
:go_memstats_alloc_bytes_total
:go_info
: