Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Nov 9, 2022
1 parent 727af29 commit d8ffb92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## 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.
([#740](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/740))

## 1.0.0-alpha.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ private static string GetInstrumentName(string sourceName, string eventName)
return string.Concat(Prefix, ".", sourceName, ".", eventName);
}

int maxEventSourceNameLength = MaxInstrumentNameLength - Prefix.Length - 2 - eventName.Length;
var abbreviation = new StringBuilder(maxEventSourceNameLength);
var abbreviation = new StringBuilder(sourceName.Length);
int ind = 0;
while (ind >= 0 && ind < sourceName.Length)
{
Expand Down Expand Up @@ -192,10 +191,9 @@ private void UpdateInstrumentWithEvent(bool isGauge, string eventSourceName, str
ValueTuple<string, string> metricKey = new(eventSourceName, name);
_ = this.values.AddOrUpdate(metricKey, value, isGauge ? (_, _) => value : (_, existing) => existing + value);

var instrumentName = GetInstrumentName(eventSourceName, name);

if (!this.instruments.ContainsKey(metricKey))
{
var instrumentName = GetInstrumentName(eventSourceName, name);
Instrument instrument = isGauge
? MeterInstance.CreateObservableGauge(instrumentName, () => this.values[metricKey])
: MeterInstance.CreateObservableCounter(instrumentName, () => this.values[metricKey]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public async Task InstrumentNameTooLong()
EventSource source = new("source");

// ec.s. + event name is 63;
string veryLongEventName = new string('e', 59);
string veryLongEventName = new string('e', 100);
IncrementingEventCounter connections = new(veryLongEventName, source);

var meterProvider = Sdk.CreateMeterProviderBuilder()
Expand Down

0 comments on commit d8ffb92

Please sign in to comment.