Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 @@ -55,7 +55,7 @@ public Meter Create(MeterOptions options)

object? scope = options.Scope;
options.Scope = this;
FactoryMeter m = new FactoryMeter(options.Name, options.Version, options.Tags, scope: this);
FactoryMeter m = new FactoryMeter(options);
options.Scope = scope;

meterList.Add(m);
Expand Down Expand Up @@ -89,8 +89,7 @@ public void Dispose()

internal sealed class FactoryMeter : Meter
{
public FactoryMeter(string name, string? version, IEnumerable<KeyValuePair<string, object?>>? tags, object? scope)
: base(name, version, tags, scope)
public FactoryMeter(MeterOptions options) : base(options)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void RecordMeasurement(T measurement, in TagList tagList)
case 3: tags[2] = tagList.Tag3; goto case 2;
case 2: tags[1] = tagList.Tag2; goto case 1;
case 1: tags[0] = tagList.Tag1; break;
case 0: return; // no need to report anything
case 0: break;
default:
Debug.Assert(false);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,29 @@ public void TestHistogramCreationWithAdvice()
}).Dispose();
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void TestRecordingWithEmptyTagList()
{
RemoteExecutor.Invoke(() =>
{
using MeterListener meterListener = new MeterListener();
using Meter meter = new Meter("demo");

int count = 0;

Counter<int> counter = meter.CreateCounter<int>("counter");
meterListener.SetMeasurementEventCallback<int>((instrument, measurement, tags,state) => count += measurement);
meterListener.EnableMeasurementEvents(counter);

counter.Add(1);
counter.Add(1, new TagList());
counter.Add(1, Array.Empty<KeyValuePair<string, object>>());
counter.Add(1, new TagList(Array.Empty<KeyValuePair<string, object>>()));

Assert.Equal(4, count);
}).Dispose();
}

private void PublishCounterMeasurement<T>(Counter<T> counter, T value, KeyValuePair<string, object?>[] tags) where T : struct
{
switch (tags.Length)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.