Skip to content

chore: Metrics PushSingleMetric default dimensions #780

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

Merged

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Feb 24, 2025

Please provide the issue number

Issue number: #779

Summary

Changes

Add support for Metrics.DefaultDimensions property in static Metrics. This makes it easier to reuse DefaultDimensions in PushSingleMetric. Options.DefaultDimensions for intances of Metrics when using the Builder or Configuration patterns.

User experience

Empty Default dimensions

Metrics.PushSingleMetric("SingleMetric", 1, MetricUnit.Count);

with new Dictionary<string, string>

Metrics.PushSingleMetric("SingleMetric", 1, MetricUnit.Count, resolution: MetricResolution.High,
            dimensions: new Dictionary<string, string> {
                { "Default", "SingleMetric" }
            });

Use existing Default Dimensions

Use Metrics.DefaultDimensions static property

 Metrics.SetDefaultDimensions(new Dictionary<string, string> 
        {
            { "Default", "SingleMetric" }
        });
        Metrics.PushSingleMetric("SingleMetric", 1, MetricUnit.Count, dimensions: Metrics.DefaultDimensions );

Options or Builder patterns

Use Options.DefaultDimensions

    _metrics = new MetricsBuilder()
        .WithDefaultDimensions(new Dictionary<string, string>
        {
            { "Environment", "Prod1" },
            { "Another", "One" }
        }).Build();

_metrics.PushSingleMetric("SuccessfulBooking", 1, MetricUnit.Count, dimensions: _metrics.Options.DefaultDimensions);

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@auto-assign auto-assign bot requested review from amirkaws and sliedig February 24, 2025 12:44
@boring-cyborg boring-cyborg bot added area/metrics Core metrics utility documentation Improvements or additions to documentation github-actions Changes in GitHub workflows internal Maintenance changes tests labels Feb 24, 2025
@hjgraca hjgraca self-assigned this Feb 24, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 24, 2025
@hjgraca hjgraca linked an issue Feb 24, 2025 that may be closed by this pull request
2 tasks
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.96%. Comparing base (367d990) to head (ce9bf85).
Report is 12 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #780   +/-   ##
========================================
  Coverage    73.95%   73.96%           
========================================
  Files          210      210           
  Lines         8378     8381    +3     
  Branches       904      904           
========================================
+ Hits          6196     6199    +3     
  Misses        1884     1884           
  Partials       298      298           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 27, 2025
Copy link

@hjgraca hjgraca merged commit 807bead into aws-powertools:develop Feb 27, 2025
9 checks passed
@hjgraca hjgraca deleted the feature/metrics-single-default-dimensions branch February 27, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics Core metrics utility documentation Improvements or additions to documentation github-actions Changes in GitHub workflows internal Maintenance changes size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Metrics - push single metric with and without default dimensions
2 participants