Skip to content
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

Design experiment #3

Open
wants to merge 141 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
fcb0110
Example of a new API/SDK
victlu Feb 1, 2021
83bbd75
API/SDK using abstract class
victlu Feb 1, 2021
df91948
Merge pull request #2 from victlu/new-api-sdk
noahfalk Feb 1, 2021
19f30de
Setup more concurrent counters
victlu Feb 1, 2021
1c9c547
experimenting...
victlu Feb 2, 2021
257ce4a
Introduce LabelSet
victlu Feb 2, 2021
f4a2944
Try wrapping int/double into MetricValue struct
victlu Feb 3, 2021
c2b3c7b
Add Batch Record example. Add LabelHistogram example
victlu Feb 3, 2021
3fec820
Refactor based on discussion with Noah
victlu Feb 4, 2021
f3ed245
Create a MetricProvider as a top level.
victlu Feb 4, 2021
8e2826c
Refactoring...
victlu Feb 5, 2021
b48dd2f
Churning...
victlu Feb 5, 2021
e94e258
Add Hints to Meter
victlu Feb 5, 2021
41d468f
Introduce a Queue for buffering incoming recordings
victlu Feb 5, 2021
0e822ca
Use Span<> for MetricValue
victlu Feb 6, 2021
ace68f8
Added Benchmark tests.
victlu Feb 6, 2021
4b82ff2
Adding more design Q&A
noahfalk Feb 6, 2021
16d3683
Example for Async callbacks
victlu Feb 8, 2021
b976385
add code examples from other apis
victlu Feb 9, 2021
ca5d787
Benchmark for Field vs Generic
victlu Feb 9, 2021
11c595a
Use generics for passing metric value
victlu Feb 9, 2021
5a6e5cf
Use generics for passing metric value
victlu Feb 9, 2021
df872c4
Rename MetricProvider to MetricSource
victlu Feb 9, 2021
aa3e1d1
Add benchmarks for LabelSet
victlu Feb 10, 2021
f69b91d
Add GroceryStore example
victlu Feb 10, 2021
4ff76d9
Fix minor bug
victlu Feb 10, 2021
5f699bc
Add a way to configure Label dimensions for aggregation
victlu Feb 10, 2021
4e1f034
Update output of Grocery example
victlu Feb 10, 2021
f5384d9
Add Exporters
victlu Feb 10, 2021
ca2a5e1
More design discussion
noahfalk Feb 18, 2021
6dec659
Refactor out DotNet runtime portion
victlu Feb 18, 2021
912c4df
Refactor into csproj and sln files
victlu Feb 18, 2021
0ac8034
Adding potentially controversial principle statement.
victlu Feb 19, 2021
5c68a45
Refactor for SumCountMinMax and Value Tuple
victlu Feb 19, 2021
d7ed309
Add benchmark
victlu Feb 20, 2021
2cf35f5
Refactor to allow configuration of Aggregators
victlu Feb 20, 2021
d4104a9
Try a RateCounter from .NET portion
victlu Feb 20, 2021
eb42549
Q&A cleanup
noahfalk Feb 21, 2021
f218929
commenting on the principles
noahfalk Feb 21, 2021
d80100f
Use MetricLabel in SDK
victlu Feb 22, 2021
d762b51
update readme after talking to Noah
victlu Feb 23, 2021
7759d2c
Add local-agg type .NET Counters
victlu Feb 23, 2021
17fd09a
Clarify naming of class
victlu Feb 23, 2021
c3144a7
Experiment with LastValueGauge
victlu Feb 23, 2021
5d88f0d
Move Hints to MetricBase
victlu Feb 25, 2021
b2830ea
Tinkering...
victlu Feb 25, 2021
bd0b694
Tinkering
victlu Feb 25, 2021
0086c7a
Refactor Export pipeline
victlu Feb 26, 2021
74a8575
Try using Protobuf for Exporter
victlu Feb 26, 2021
50901c7
Encode/Decode ExportMetricsServiceRequest
victlu Feb 27, 2021
f154a02
Lots of changes
noahfalk Mar 1, 2021
3d19e36
Turn on exporter
victlu Mar 1, 2021
18bd3da
Get OTLPExporter working
victlu Mar 1, 2021
e254d10
Add LibraryName and LibraryVersion
victlu Mar 1, 2021
2bcb9e4
Add more examples
victlu Mar 2, 2021
06b3996
OTel API wrapper around .NET API
victlu Mar 2, 2021
7273801
Try out new Metric protocol
victlu Mar 2, 2021
b41189a
Add Benchmarks for metric proto
victlu Mar 2, 2021
cf47f4a
Update Bench results
victlu Mar 2, 2021
c453d02
tinkering with OTel API
victlu Mar 3, 2021
7b2ff07
Add DI example unittest
victlu Mar 4, 2021
b54b2f0
Tinkering
victlu Mar 4, 2021
05d60bb
Simple DI example
victlu Mar 4, 2021
4176e4d
Update from meeting
victlu Mar 6, 2021
a14b334
Replaced required lib+version with MetricSource
noahfalk Mar 7, 2021
71ed6ed
Updating readme Q&A
noahfalk Mar 8, 2021
12cede0
refactoring
victlu Mar 8, 2021
a2d34fd
Add more discussion items
victlu Mar 8, 2021
830eaee
Benchmark for ScalarDataPoint
victlu Mar 17, 2021
b7324b8
Add Benchmark for how we pass labels
victlu Mar 17, 2021
a05bda4
Add additional Bench for passing labels
victlu Mar 17, 2021
48704b0
update results for Labelpassing bench
victlu Mar 18, 2021
a5ec715
Update result from LabelPassing bench
victlu Mar 18, 2021
3ec4ea4
Aligning on OTel's current naming
noahfalk Mar 21, 2021
6b7d47d
WIP
noahfalk Mar 22, 2021
3d69a2f
tests passing and perf benchmarks recorded
noahfalk Mar 22, 2021
a887138
Wrap up the dynamic label tuple experiment for now
noahfalk Mar 22, 2021
7305d5f
Update readme.md
noahfalk Mar 25, 2021
2247f0f
Fix variable naming
noahfalk Mar 29, 2021
65016f7
Refactor MeterInstrument -> UnboundMeterInstrument
noahfalk Mar 29, 2021
8ee461f
MeterInstrumentBase -> MeterInstrument
noahfalk Mar 29, 2021
bf31747
Eliminate bound instruments
noahfalk Mar 29, 2021
a619420
Create instrument via Meter factory
noahfalk Mar 29, 2021
6cee8ba
Add IDisposable on Meter and listener
noahfalk Mar 29, 2021
47e50ac
switch from listener delegates to virtual methods
noahfalk Mar 29, 2021
bf52a89
Readme updates
noahfalk Mar 29, 2021
65b5bd6
Update readme.md
noahfalk Apr 5, 2021
3c105d8
Interpretation of current API spec
victlu Apr 7, 2021
b17d767
Add example implementation of current API spec
victlu Apr 9, 2021
b00a98d
Fixup stuff
victlu Apr 9, 2021
5b1ef87
Removed static labels
noahfalk Apr 7, 2021
84113c7
Rename ObservableCounter -> CounterFunc
noahfalk Apr 7, 2021
31f8b9f
Fix broken HappyPath test
noahfalk Apr 9, 2021
6c4052f
Eliminated the hint API (for now)
noahfalk Apr 9, 2021
8270e5a
Refactor Api2
victlu Apr 9, 2021
0fee27b
Refactoring...
victlu Apr 9, 2021
86f9635
cleanup
victlu Apr 10, 2021
129cb13
Add IDisposable
victlu Apr 10, 2021
1ad6e43
Cleaner implementation of AggregationStore
noahfalk Apr 9, 2021
4f6352f
Add SDK instrument configuration
noahfalk Apr 11, 2021
6171838
Get rid of the 5X in the benchmarks
noahfalk Apr 11, 2021
69eb97f
Add a simple Prometheus exporter
noahfalk Apr 12, 2021
2c8703c
Add Distribution instrument
noahfalk Apr 12, 2021
520cb44
dotnet-format fixes
victlu Apr 13, 2021
cd4d8c0
misspell
victlu Apr 13, 2021
3687520
wrapping
victlu Apr 13, 2021
3302efa
Merge branch 'main' into design_experiment
victlu Apr 13, 2021
23da73e
dotnet-format
victlu Apr 13, 2021
a70a042
remove old code
victlu Apr 13, 2021
d56ed16
allow CRLF for .NET/C# files
victlu Apr 13, 2021
f45bfb3
Change to LF
victlu Apr 13, 2021
6dbd22b
Get example working again
victlu Apr 15, 2021
372c236
Hook up Api2 to our sdk
victlu Apr 15, 2021
ae43b05
Add notification to API2
victlu Apr 16, 2021
a09e8c0
Add <T> to all instruments
victlu Apr 16, 2021
1a4de09
Removing the tagging interfaces
noahfalk Apr 17, 2021
9490661
Fix perf regressions
noahfalk Apr 17, 2021
3f6f14e
Target multiple frameworks
victlu Apr 22, 2021
6631b93
Instroduce Metric API into OpenTelemetry
victlu Apr 22, 2021
dc4c103
Hook up MDM to see how it feels.
victlu Apr 23, 2021
3469d7e
Use object type for label values
noahfalk Apr 26, 2021
375aec5
Get rid of UnboundMeterInstrument
noahfalk Apr 26, 2021
5be6d5c
Remove MeasurementObserver and create ObservableMeterInstrument base …
noahfalk Apr 26, 2021
4673bba
Add description and unit
noahfalk Apr 26, 2021
e647004
Eliminate unneeded protected members
noahfalk Apr 26, 2021
f53e597
Eliminate build warnings
noahfalk Apr 26, 2021
3356527
Update MeterInstrumentListener API
noahfalk Apr 26, 2021
1bc6bcd
Add Bench to compare cost of API/SDK vs IFx
victlu Apr 27, 2021
b133580
Merge branch 'design_experiment' of https://github.com/noahfalk/opent…
victlu Apr 27, 2021
a0f3304
Update bench results
victlu Apr 27, 2021
61d4860
Fix bad checkin
victlu Apr 27, 2021
80ad09c
Remove strong name signing
victlu Apr 27, 2021
c785586
Remove reference
victlu Apr 27, 2021
e5ea7e0
Make it build!
victlu Apr 27, 2021
47ef1e3
Update to new Listener hookup
victlu Apr 28, 2021
90a4e87
Use IFxExtension to handle multi-dim labels
victlu Apr 28, 2021
727dbf9
Setup Example to send to GenevaAgent
victlu Apr 29, 2021
6b3f2c2
Try out passing KVP in bench
victlu Apr 30, 2021
c26e099
Not sure why CreateReadOnlySpan doesn't work!
victlu May 1, 2021
b0d08a7
Get bench working for CreateReadOnlySpan
victlu May 3, 2021
80e6ff7
Bench for CreateReadOnlySpan of 5 KVP
victlu May 3, 2021
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
56 changes: 56 additions & 0 deletions example3/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Example/bin/Debug/net5.0/Example.dll",
"args": [],
"cwd": "${workspaceFolder}/Example",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Grocery Store Example",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceRoot}/GroceryStoreExample/bin/Debug/net5.0/GroceryStoreExample.dll",
"args": [],
"cwd": "${workspaceRoot}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": "Example",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceRoot}/Example/bin/Debug/net5.0/Example.dll",
"args": [],
"cwd": "${workspaceRoot}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
42 changes: 42 additions & 0 deletions example3/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Example/Example.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Example/Example.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/Example/Example.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
19 changes: 19 additions & 0 deletions example3/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\Microsoft.Diagnostics.Metric\Microsoft.Diagnostics.Metric.csproj" />
<ProjectReference Include="..\OpenTelemetry.Metric.Api\OpenTelemetry.Metric.Api.csproj" />
<ProjectReference Include="..\OpenTelemetry.Metric.Sdk\OpenTelemetry.Metric.Sdk.csproj" />
<ProjectReference Include="..\Microsoft.OpenTelemetry.Exporter\Microsoft.OpenTelemetry.Exporter.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
155 changes: 155 additions & 0 deletions example3/Benchmarks/LabelSetBench.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Engines;

using Microsoft.Diagnostics.Metric;
using OpenTelemetry.Metric.Sdk;

namespace MyBenchmark
{
[SimpleJob(launchCount: 2, warmupCount: 2, targetCount: 10)]
[MemoryDiagnoser]
public class LabelSetBench
{
/*
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=5.0.102
[Host] : .NET Core 5.0.2 (CoreCLR 5.0.220.61120, CoreFX 5.0.220.61120), X64 RyuJIT
Job-UEMYAQ : .NET Core 5.0.2 (CoreCLR 5.0.220.61120, CoreFX 5.0.220.61120), X64 RyuJIT

IterationCount=10 LaunchCount=2 WarmupCount=2

| Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------------- |------------:|-----------:|-----------:|-------:|------:|------:|----------:|
| Dict_new | 248.0862 ns | 18.6159 ns | 19.9188 ns | 0.2370 | - | - | 992 B |
| Dict_enum | 261.0479 ns | 10.1366 ns | 10.8461 ns | 0.1602 | - | - | 672 B |
| ValueTuple_enum | 256.9502 ns | 21.3555 ns | 24.5930 ns | 0.1450 | - | - | 608 B |
| LabelSet_new | 52.0137 ns | 2.9141 ns | 3.2390 ns | 0.0516 | - | - | 216 B |
| LabelSet_enum | 128.5064 ns | 4.7004 ns | 5.0294 ns | 0.1318 | - | - | 552 B |
| LabelSet_enumArray | 0.5445 ns | 0.0719 ns | 0.0828 ns | - | - | - | - |
*/

MetricLabelSet ls;

IDictionary<string,string> dict;

[GlobalSetup]
public void Setup()
{
ls = new MetricLabelSet(
("Key1", "Value1"),
("Key2", "Value2"),
("Key3", "Value3"),
("Key4", "Value4"),
("Key5", "Value5"),
("Key6", "Value6"),
("Key7", "Value7"),
("Key8", "Value8"),
("Key9", "Value9")
);

dict = new Dictionary<string,string> {
{ "Key1", "Value1" },
{ "Key2", "Value2" },
{ "Key3", "Value3" },
{ "Key4", "Value4" },
{ "Key5", "Value5" },
{ "Key6", "Value6" },
{ "Key7", "Value7" },
{ "Key8", "Value8" },
{ "Key9", "Value9" },
};
}

//****************

[Benchmark]
public IDictionary<string,string> Dict_new()
{
return new Dictionary<string,string> {
{ "Key1", "Value1" },
{ "Key2", "Value2" },
{ "Key3", "Value3" },
{ "Key4", "Value4" },
{ "Key5", "Value5" },
{ "Key6", "Value6" },
{ "Key7", "Value7" },
{ "Key8", "Value8" },
{ "Key9", "Value9" },
};
}

[Benchmark]
public List<Tuple<string,string>> Dict_enum()
{
List<Tuple<string,string>> ret = new();

foreach(var kv in dict)
{
var key = kv.Key;
var val = kv.Value;

ret.Add(Tuple.Create(key,val));
}

return ret;
}

[Benchmark]
public List<(string,string)> ValueTuple_enum()
{
List<(string,string)> ret = new();

foreach(var kv in dict)
{
var key = kv.Key;
var val = kv.Value;

ret.Add((key,val));
}

return ret;
}

//****************

[Benchmark]
public MetricLabelSet MetricLabelSet_new()
{
return new MetricLabelSet(
("Key1", "Value1"),
("Key2", "Value2"),
("Key3", "Value3"),
("Key4", "Value4"),
("Key5", "Value5"),
("Key6", "Value6"),
("Key7", "Value7"),
("Key8", "Value8"),
("Key9", "Value9")
);
}

[Benchmark]
public List<(string,string)> MetricLabelSet_enum()
{
List<(string,string)> ret = new();

var ls = this.ls.GetLabels();
foreach (var label in ls)
{
ret.Add((label.name, label.value));
}

return ret;
}

[Benchmark]
public (string name, string value)[] MetricLabelSet_enumArray()
{
return ls.GetLabels();
}
}
}
95 changes: 95 additions & 0 deletions example3/Benchmarks/MetricProtoBench.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Engines;

using Microsoft.Diagnostics.Metric;
using Microsoft.OpenTelemetry.Export;
using OpenTelemetry.Metric.Api;
using OpenTelemetry.Metric.Sdk;

/*
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-1065G7 CPU 1.30GHz, 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=5.0.103
[Host] : .NET Core 5.0.3 (CoreCLR 5.0.321.7212, CoreFX 5.0.321.7212), X64 RyuJIT
Job-GMTSFC : .NET Core 5.0.3 (CoreCLR 5.0.321.7212, CoreFX 5.0.321.7212), X64 RyuJIT

IterationCount=15 LaunchCount=3 WarmupCount=3

| Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|--------------- |---------:|---------:|---------:|--------:|-------:|------:|----------:|
| SendMetric | 40.98 us | 0.601 us | 1.113 us | 7.6294 | - | - | 31.23 KB |
| SendMetric2 | 40.14 us | 0.328 us | 0.592 us | 7.9956 | 0.0610 | - | 32.8 KB |
| ReceiveMetric | 49.04 us | 0.623 us | 1.185 us | 14.2822 | 0.0610 | - | 58.52 KB |
| ReceiveMetric2 | 48.42 us | 0.846 us | 1.547 us | 14.6484 | - | - | 60.09 KB |
*/

namespace MyBenchmark
{
[SimpleJob(launchCount: 3, warmupCount: 3, targetCount: 15)]
[MemoryDiagnoser]
public class MetricProtoBench
{
private ProtoBufClient client;
ExportItem[] items;
byte[] bytes1;
byte[] bytes2;

[GlobalSetup]
public void Setup()
{
var items = new List<ExportItem>();

for (int i = 0; i < 10; i++)
{
var item = new ExportItem();
item.dt = DateTimeOffset.Parse("2020-01-01T10:12:13Z");
item.LibName = "Test";
item.LibVersion = "0.0.1";
item.MeterName = $"MyTest.request_{i}";
item.Labels = new MetricLabelSet(("Host", "Test"), ("Mode", "Test"));
item.AggregationConfig = new SumAggregation();
item.AggData = new (string,string)[] {
("sum","100.5"),
("count","100"),
("min","10.2"),
("max","100")
};
items.Add(item);
}

this.items = items.ToArray();

client = new ProtoBufClient();

bytes1 = client.Send(items.ToArray(), true);
bytes2 = client.Send(items.ToArray(), false);
}

[Benchmark]
public byte[] SendMetric()
{
return client.Send(items, true);
}

[Benchmark]
public byte[] SendMetric2()
{
return client.Send(items, false);
}

[Benchmark]
public ProtoBufClient.ParseRecord[] ReceiveMetric()
{
return client.ParsePayload(bytes1);
}

[Benchmark]
public ProtoBufClient.ParseRecord[] ReceiveMetric2()
{
return client.ParsePayload(bytes2);
}
}
}
Loading