-
Notifications
You must be signed in to change notification settings - Fork 26
chore: Feature/metrics default dimensions coldstart #771
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
hjgraca
merged 14 commits into
aws-powertools:develop
from
hjgraca:feature/metrics-default-dimensions-coldstart
Feb 26, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a1417ea
feat(metrics): enhance default dimensions handling and refactor metri…
hjgraca 450a2da
feat(metrics): introduce MetricsOptions for configurable metrics setu…
hjgraca df9d4fa
feat(metrics): add MetricsBuilder for fluent configuration of metrics…
hjgraca e8ef8dd
feat(metrics): enhance MetricsBuilder with detailed configuration opt…
hjgraca 3532ea3
Merge branch 'develop' into feature/metrics-default-dimensions-coldstart
hjgraca 7aed1ca
Merge branch 'develop' into feature/metrics-default-dimensions-coldstart
hjgraca 4efda59
Merge branch 'develop' of https://github.com/hjgraca/powertools-lambd…
hjgraca 5c4d199
refactor(metrics): standardize parameter names for clarity in metric …
hjgraca c99d76b
Merge remote-tracking branch 'origin/feature/metrics-default-dimensio…
hjgraca 5b35699
Merge branch 'develop' into feature/metrics-default-dimensions-coldstart
hjgraca 7f7b115
feat(metrics): add HandlerRaiseOnEmptyMetrics method and correspondin…
hjgraca 3c80a2d
feat(metrics): add HandlerEmpty method and test for empty metrics exc…
hjgraca b9ba2ce
feat(metrics): enhance cold start handling with default dimensions an…
hjgraca 518b874
feat(metrics): add unit tests for Metrics constructor and validation …
hjgraca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
107 changes: 56 additions & 51 deletions
107
libraries/src/AWS.Lambda.Powertools.Metrics/IMetrics.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,109 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* | ||
* or in the "license" file accompanying this file. This file 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. | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace AWS.Lambda.Powertools.Metrics; | ||
|
||
/// <summary> | ||
/// Interface IMetrics | ||
/// Implements the <see cref="System.IDisposable" /> | ||
/// Interface for metrics operations. | ||
/// </summary> | ||
/// <seealso cref="System.IDisposable" /> | ||
public interface IMetrics | ||
public interface IMetrics | ||
{ | ||
/// <summary> | ||
/// Adds metric | ||
/// Adds a metric to the collection. | ||
/// </summary> | ||
/// <param name="key">Metric key</param> | ||
/// <param name="value">Metric value</param> | ||
/// <param name="unit">Metric unit</param> | ||
/// <param name="metricResolution"></param> | ||
void AddMetric(string key, double value, MetricUnit unit, MetricResolution metricResolution); | ||
/// <param name="key">The metric key.</param> | ||
/// <param name="value">The metric value.</param> | ||
/// <param name="unit">The metric unit.</param> | ||
/// <param name="resolution">The metric resolution.</param> | ||
void AddMetric(string key, double value, MetricUnit unit = MetricUnit.None, | ||
MetricResolution resolution = MetricResolution.Default); | ||
|
||
/// <summary> | ||
/// Adds a dimension | ||
/// Adds a dimension to the collection. | ||
/// </summary> | ||
/// <param name="key">Dimension key</param> | ||
/// <param name="value">Dimension value</param> | ||
/// <param name="key">The dimension key.</param> | ||
/// <param name="value">The dimension value.</param> | ||
void AddDimension(string key, string value); | ||
|
||
/// <summary> | ||
/// Sets the default dimensions | ||
/// Adds metadata to the collection. | ||
/// </summary> | ||
/// <param name="defaultDimension">Default dimensions</param> | ||
void SetDefaultDimensions(Dictionary<string, string> defaultDimension); | ||
/// <param name="key">The metadata key.</param> | ||
/// <param name="value">The metadata value.</param> | ||
void AddMetadata(string key, object value); | ||
|
||
/// <summary> | ||
/// Adds metadata | ||
/// Sets the default dimensions. | ||
/// </summary> | ||
/// <param name="key">Metadata key</param> | ||
/// <param name="value">Metadata value</param> | ||
void AddMetadata(string key, object value); | ||
/// <param name="defaultDimensions">The default dimensions.</param> | ||
void SetDefaultDimensions(Dictionary<string, string> defaultDimensions); | ||
|
||
/// <summary> | ||
/// Pushes a single metric with custom namespace, service and dimensions. | ||
/// Sets the namespace for the metrics. | ||
/// </summary> | ||
/// <param name="metricName">Name of the metric</param> | ||
/// <param name="value">Metric value</param> | ||
/// <param name="unit">Metric unit</param> | ||
/// <param name="nameSpace">Metric namespace</param> | ||
/// <param name="service">Metric service</param> | ||
/// <param name="defaultDimensions">Metric default dimensions</param> | ||
/// <param name="metricResolution">Metrics resolution</param> | ||
void PushSingleMetric(string metricName, double value, MetricUnit unit, string nameSpace = null, | ||
string service = null, Dictionary<string, string> defaultDimensions = null, MetricResolution metricResolution = MetricResolution.Default); | ||
/// <param name="nameSpace">The namespace.</param> | ||
void SetNamespace(string nameSpace); | ||
|
||
/// <summary> | ||
/// Sets the namespace | ||
/// Sets the service name for the metrics. | ||
/// </summary> | ||
/// <param name="nameSpace">Metrics namespace</param> | ||
void SetNamespace(string nameSpace); | ||
/// <param name="service">The service name.</param> | ||
void SetService(string service); | ||
|
||
/// <summary> | ||
/// Sets whether to raise an event on empty metrics. | ||
/// </summary> | ||
/// <param name="raiseOnEmptyMetrics">If set to <c>true</c>, raises an event on empty metrics.</param> | ||
void SetRaiseOnEmptyMetrics(bool raiseOnEmptyMetrics); | ||
|
||
/// <summary> | ||
/// Gets the namespace | ||
/// Sets whether to capture cold start metrics. | ||
/// </summary> | ||
/// <returns>System.String.</returns> | ||
string GetNamespace(); | ||
/// <param name="captureColdStart">If set to <c>true</c>, captures cold start metrics.</param> | ||
void SetCaptureColdStart(bool captureColdStart); | ||
|
||
/// <summary> | ||
/// Gets the service | ||
/// Pushes a single metric to the collection. | ||
/// </summary> | ||
/// <returns>System.String.</returns> | ||
string GetService(); | ||
/// <param name="name">The metric name.</param> | ||
/// <param name="value">The metric value.</param> | ||
/// <param name="unit">The metric unit.</param> | ||
/// <param name="nameSpace">The namespace.</param> | ||
/// <param name="service">The service name.</param> | ||
/// <param name="defaultDimensions">The default dimensions.</param> | ||
/// <param name="resolution">The metric resolution.</param> | ||
void PushSingleMetric(string name, double value, MetricUnit unit, string nameSpace = null, string service = null, | ||
Dictionary<string, string> defaultDimensions = null, MetricResolution resolution = MetricResolution.Default); | ||
|
||
/// <summary> | ||
/// Serializes metrics instance | ||
/// Clears the default dimensions. | ||
/// </summary> | ||
/// <returns>System.String.</returns> | ||
string Serialize(); | ||
void ClearDefaultDimensions(); | ||
|
||
/// <summary> | ||
/// Flushes metrics to CloudWatch | ||
/// Flushes the metrics. | ||
/// </summary> | ||
/// <param name="metricsOverflow">if set to <c>true</c> [metrics overflow].</param> | ||
/// <param name="metricsOverflow">If set to <c>true</c>, indicates a metrics overflow.</param> | ||
void Flush(bool metricsOverflow = false); | ||
|
||
/// <summary> | ||
/// Clears both default dimensions and dimensions lists | ||
/// Gets the metrics options. | ||
/// </summary> | ||
void ClearDefaultDimensions(); | ||
} | ||
/// <value>The metrics options.</value> | ||
public MetricsOptions Options { get; } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.