Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
### Breaking Changes

### Bugs Fixed
- Add custom metric mapping for customer sdkstats metric names to preserve casing
([#44855](https://github.com/Azure/azure-sdk-for-python/pull/44855))
- Fix customer SDK stats metrics to display drop code and retry code enum values without the prefix
([#44852](https://github.com/Azure/azure-sdk-for-python/pull/44852))

Expand Down Expand Up @@ -771,4 +773,4 @@

- Initial alpha release

# cSpell:enable
# cSpell:enable
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,24 @@ class RetryCode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
RetryCodeType = Union[RetryCode, int]


# Customer SDK Stats metric names: (lowercase_otel_name, pascal_case_display_name)
_ITEM_SUCCESS_COUNT_NAME = ("item_success_count", "Item_Success_Count")
_ITEM_DROP_COUNT_NAME = ("item_dropped_count", "Item_Dropped_Count")
_ITEM_RETRY_COUNT_NAME = ("item_retry_count", "Item_Retry_Count")

_CUSTOMER_SDKSTATS_METRIC_NAME_MAPPINGS = dict(
[
_ITEM_SUCCESS_COUNT_NAME,
_ITEM_DROP_COUNT_NAME,
_ITEM_RETRY_COUNT_NAME,
]
)


class CustomerSdkStatsMetricName(str, Enum, metaclass=CaseInsensitiveEnumMeta):
ITEM_SUCCESS_COUNT = "Item_Success_Count"
ITEM_DROP_COUNT = "Item_Dropped_Count"
ITEM_RETRY_COUNT = "Item_Retry_Count"
ITEM_SUCCESS_COUNT = _ITEM_SUCCESS_COUNT_NAME[0]
ITEM_DROP_COUNT = _ITEM_DROP_COUNT_NAME[0]
ITEM_RETRY_COUNT = _ITEM_RETRY_COUNT_NAME[0]


## Map from Azure Monitor envelope base_types to TelemetryType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
_APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED,
_APPLICATIONINSIGHTS_METRIC_NAMESPACE_OPT_IN,
_AUTOCOLLECTED_INSTRUMENT_NAMES,
_CUSTOMER_SDKSTATS_METRIC_NAME_MAPPINGS,
_METRIC_ENVELOPE_NAME,
_STATSBEAT_METRIC_NAME_MAPPINGS,
)
Expand Down Expand Up @@ -167,6 +168,9 @@ def _point_to_envelope(
final_metric_name = name
if self._is_sdkstats and name in _STATSBEAT_METRIC_NAME_MAPPINGS:
final_metric_name = _STATSBEAT_METRIC_NAME_MAPPINGS[name]
# Apply customer sdkstats metric name mapping if this is a customer sdkstats exporter
if self._is_customer_sdkstats and name in _CUSTOMER_SDKSTATS_METRIC_NAME_MAPPINGS:
final_metric_name = _CUSTOMER_SDKSTATS_METRIC_NAME_MAPPINGS[name]

envelope = _convert_point_to_envelope(point, final_metric_name, resource, scope)
# Note that Performance Counters are not counted as "Autocollected standard metrics"
Expand Down