diff --git a/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md index aecb87cb95..0bc56cdbaf 100644 --- a/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md @@ -3,8 +3,8 @@ ## Unreleased * Update OpenTelemetry.Api to 1.3.1. -* Changed `EventCounter` prefix to `ec` and started abbreviating event source name - when instrument name is longer that 63 characters. +* Change `EventCounter` prefix to `ec` and abbreviate event source name + when instrument name is longer than 63 characters. ([#740](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/740)) ## 1.0.0-alpha.1 diff --git a/src/OpenTelemetry.Instrumentation.EventCounters/EventCountersMetrics.cs b/src/OpenTelemetry.Instrumentation.EventCounters/EventCountersMetrics.cs index 18ed7441da..7fa32ee95d 100644 --- a/src/OpenTelemetry.Instrumentation.EventCounters/EventCountersMetrics.cs +++ b/src/OpenTelemetry.Instrumentation.EventCounters/EventCountersMetrics.cs @@ -141,10 +141,10 @@ private static string GetInstrumentName(string sourceName, string eventName) } var maxEventSourceLength = MaxInstrumentNameLength - Prefix.Length - 1 - eventName.Length; - if (maxEventSourceLength < 2) + if (maxEventSourceLength < 2) { // event name is too long, there is not enough space for sourceName. - // let ec. flow to metrics SDK and filter if needed. + // let ec. flow to metrics SDK and it will suppress it if needed. return string.Concat(Prefix, ".", eventName); } @@ -159,12 +159,12 @@ private static string GetInstrumentName(string sourceName, string eventName) if (ind < sourceName.Length) { + abbreviation.Append(char.ToLowerInvariant(sourceName[ind])).Append('.'); if (abbreviation.Length + 2 >= maxEventSourceLength) { + // stop if there is no room to add another letter and a dot after break; } - - abbreviation.Append(char.ToLowerInvariant(sourceName[ind])).Append('.'); } int nextDot = sourceName.IndexOf('.', ind);