-
Notifications
You must be signed in to change notification settings - Fork 773
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
Metrics to Main #2174
Merged
Merged
Metrics to Main #2174
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
7d5faf9
Revert "Remove metrics from 1.0.0 release (#1743)"
cijothomas 92d1950
conflict in changelog resolved
cijothomas 9b61fe2
Merge branch 'main' into metrics
cijothomas b438d5c
Merge branch 'main' into metrics
cijothomas b894c4f
Merge branch 'main' into metrics
cijothomas b406a42
Merge branch 'main' into metrics
cijothomas b5851a3
merge conflict
cijothomas b28db93
conflict resolved for public apis
cijothomas 646bb10
Merge branch 'main' into metrics
cijothomas ab278ce
Remove public api analyzer for metrics (#1830)
cijothomas 2660c74
Remove obsolete from Metrics - one file to test #1750 (#1751)
cijothomas ab83a45
Remove public API entries for metric (#1920)
cijothomas 56afcea
conflict resolved in sdk and changelog
cijothomas 6d6a045
Merge branch 'main' into metrics
cijothomas b1df9db
Merge branch 'main' into metrics
cijothomas 9d415bf
Remove existing Metrics code (#2030)
cijothomas c5a8535
Add a temp project with Metric API (which will come eventually from r…
cijothomas c8d8b8c
Initial Metric API/SDK framing (#2034)
victlu 4faf1d4
Metric config modified to look similar to Tracing (#2037)
cijothomas 4190b6b
Initial structure for running Processors (#2038)
victlu b5f8873
Initial framework for Aggregators (#2053)
victlu 23987a4
Swap to using .NET Preview for Metrics API (#2067)
victlu 88b732e
Refactor for new [Gauge|Sum|Summary|Histogram]Metric types and aggreg…
victlu d18fa52
Merge branch 'main' into metrics
cijothomas 9071827
conflict resolved for nuget conifg
cijothomas 8492de6
Metric console exporter modified to deal with all known types (#2087)
cijothomas ed3322c
Merge branch 'main' into metrics
cijothomas 95a1367
Refactor for DataValue (#2093)
victlu 8a89dbd
Use ActivityTraceId/ActivitySpanId for exemplars (#2125)
alanwest 1f2075a
Merge branch 'main' into metrics
cijothomas be1d13f
Add a getting started doc for metric (#2132)
cijothomas 8f525df
Modify MeterProvider to no longer maintain instrument state as it is …
cijothomas 4814924
Measurement type conversion done at the MeterProvider. (#2136)
cijothomas 9a5d9fd
Remove timestamp read per metric update (#2137)
cijothomas 63c28f0
Refactor MeterProvider to be similar to TracerProvider (#2141)
cijothomas a572ad8
Make Delta vs Cumulative based purely on Exporter (#2142)
cijothomas 8577221
Add a very basic prometheus exporter (#2143)
cijothomas a1f6f42
Add reference to Instrument on IMetric (#2124)
alanwest 5d6d400
Add OTLP metrics exporter (#2092)
alanwest a4d8b35
Add Resource support for MetricProvider (#2150)
cijothomas d05b8d2
Simple ASP.NET Core instrumentation capturing request count metric (#…
alanwest 3d95e7d
conflict resolve
cijothomas 4f8eb89
Merge branch 'main' into metrics
cijothomas 94c6e56
Update DS version (#2169)
cijothomas 49f3c18
Small cleanup on MeterProvider (#2172)
cijothomas ea84510
Merge branch 'main' into metrics
cijothomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// <copyright file="Program.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Metrics; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using OpenTelemetry; | ||
using OpenTelemetry.Metrics; | ||
|
||
public class Program | ||
{ | ||
private static readonly Meter MyMeter = new Meter("TestMeter", "0.0.1"); | ||
private static readonly Counter<long> Counter = MyMeter.CreateCounter<long>("counter"); | ||
|
||
public static async Task Main(string[] args) | ||
{ | ||
using var meterProvider = Sdk.CreateMeterProviderBuilder() | ||
.AddSource("TestMeter") | ||
.AddConsoleExporter() | ||
.Build(); | ||
|
||
using var token = new CancellationTokenSource(); | ||
Task writeMetricTask = new Task(() => | ||
{ | ||
while (!token.IsCancellationRequested) | ||
{ | ||
Counter.Add( | ||
10, | ||
new KeyValuePair<string, object>("tag1", "value1"), | ||
new KeyValuePair<string, object>("tag2", "value2")); | ||
Task.Delay(10).Wait(); | ||
} | ||
}); | ||
writeMetricTask.Start(); | ||
|
||
token.CancelAfter(10000); | ||
await writeMetricTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Getting Started with OpenTelemetry .NET in 5 Minutes | ||
|
||
First, download and install the [.NET Core | ||
SDK](https://dotnet.microsoft.com/download) on your computer. | ||
|
||
Create a new console application and run it: | ||
|
||
```sh | ||
dotnet new console --output getting-started | ||
cd getting-started | ||
dotnet run | ||
``` | ||
|
||
You should see the following output: | ||
|
||
```text | ||
Hello World! | ||
``` | ||
|
||
Install the | ||
[OpenTelemetry.Exporter.Console](../../../src/OpenTelemetry.Exporter.Console/README.md) | ||
package: | ||
|
||
```sh | ||
dotnet add package OpenTelemetry.Exporter.Console | ||
``` | ||
|
||
Update the `Program.cs` file with the code from [Program.cs](./Program.cs): | ||
|
||
Run the application again (using `dotnet run`) and you should see the metric | ||
output from the console, similar to shown below: | ||
|
||
<!-- markdownlint-disable MD013 --> | ||
```text | ||
Export[] 16:38:36.241 16:38:37.233 TestMeter:counter [tag1=value1;tag2=value2] SumMetricAggregator Value: 590, Details: Delta=True,Mon=True,Count=59,Sum=590 | ||
Export[] 16:38:37.233 16:38:38.258 TestMeter:counter [tag1=value1;tag2=value2] SumMetricAggregator Value: 640, Details: Delta=True,Mon=True,Count=64,Sum=640 | ||
Export[] 16:38:38.258 16:38:39.261 TestMeter:counter [tag1=value1;tag2=value2] SumMetricAggregator Value: 640, Details: Delta=True,Mon=True,Count=64,Sum=640 | ||
Export[] 16:38:39.261 16:38:40.266 TestMeter:counter [tag1=value1;tag2=value2] SumMetricAggregator Value: 630, Details: Delta=True,Mon=True,Count=63,Sum=630 | ||
Export[] 16:38:40.266 16:38:41.271 TestMeter:counter [tag1=value1;tag2=value2] SumMetricAggregator Value: 640, Details: Delta=True,Mon=True,Count=64,Sum=640 | ||
``` | ||
<!-- markdownlint-enable MD013 --> | ||
|
||
Congratulations! You are now collecting metrics using OpenTelemetry. | ||
|
||
What does the above program do? | ||
|
||
The program creates a | ||
[Meter](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#meter) | ||
instance named "TestMeter" and then creates a | ||
[Counter](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#counter) | ||
instrument from it. This counter is used to repeatedly report metric | ||
measurements until exited after 10 seconds. | ||
|
||
An OpenTelemetry | ||
[MeterProvider](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#meterprovider) | ||
is configured to subscribe to instruments from the Meter `TestMeter`, and | ||
aggregate the measurements in-memory. The pre-aggregated metrics are exported | ||
every 1 second to a `ConsoleExporter`. `ConsoleExporter` simply displays it on | ||
the console. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" /> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will continue to leave this disabled on main for now?