From 7958763a1b4acd15edc867a26ea6d7daa7c17e91 Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Thu, 13 Apr 2023 13:48:43 -0700 Subject: [PATCH 1/5] Add ASP.NET example for metrics (#4381) --- OpenTelemetry.sln | 9 +- README.md | 3 +- docs/metrics/customizing-the-sdk/README.md | 3 +- .../getting-started-aspnetcore/Program.cs | 38 +++++++ .../getting-started-aspnetcore/README.md | 102 ++++++++++++++++++ .../appsettings.Development.json | 9 ++ .../appsettings.json | 9 ++ .../getting-started-aspnetcore.csproj | 15 +++ .../Program.cs | 0 .../README.md | 0 .../getting-started-console.csproj} | 0 .../README.md | 9 +- src/OpenTelemetry.Exporter.Console/README.md | 3 +- src/OpenTelemetry/README.md | 8 +- 14 files changed, 197 insertions(+), 11 deletions(-) create mode 100644 docs/metrics/getting-started-aspnetcore/Program.cs create mode 100644 docs/metrics/getting-started-aspnetcore/README.md create mode 100644 docs/metrics/getting-started-aspnetcore/appsettings.Development.json create mode 100644 docs/metrics/getting-started-aspnetcore/appsettings.json create mode 100644 docs/metrics/getting-started-aspnetcore/getting-started-aspnetcore.csproj rename docs/metrics/{getting-started => getting-started-console}/Program.cs (100%) rename docs/metrics/{getting-started => getting-started-console}/README.md (100%) rename docs/metrics/{getting-started/getting-started.csproj => getting-started-console/getting-started-console.csproj} (100%) diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index 2c0365ae3a9..0e694c421f1 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -193,7 +193,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "customizing-the-sdk", "docs EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "learning-more-instruments", "docs\metrics\learning-more-instruments\learning-more-instruments.csproj", "{E7F491CC-C37E-4A56-9CA7-8F77F59E0614}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started", "docs\metrics\getting-started\getting-started.csproj", "{EA60B549-F712-4ABE-8E44-FCA83B78C06E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started-console", "docs\metrics\getting-started-console\getting-started-console.csproj", "{EA60B549-F712-4ABE-8E44-FCA83B78C06E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started-aspnetcore", "docs\metrics\getting-started-aspnetcore\getting-started-aspnetcore.csproj", "{0C3E7D40-E0B3-4B77-8139-0E85C3600688}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\metrics\extending-the-sdk\extending-the-sdk.csproj", "{1F9D7748-D099-4E25-97F5-9C969D6FF969}" EndProject @@ -421,6 +423,10 @@ Global {EA60B549-F712-4ABE-8E44-FCA83B78C06E}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA60B549-F712-4ABE-8E44-FCA83B78C06E}.Release|Any CPU.ActiveCfg = Release|Any CPU {EA60B549-F712-4ABE-8E44-FCA83B78C06E}.Release|Any CPU.Build.0 = Release|Any CPU + {0C3E7D40-E0B3-4B77-8139-0E85C3600688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C3E7D40-E0B3-4B77-8139-0E85C3600688}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C3E7D40-E0B3-4B77-8139-0E85C3600688}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C3E7D40-E0B3-4B77-8139-0E85C3600688}.Release|Any CPU.Build.0 = Release|Any CPU {1F9D7748-D099-4E25-97F5-9C969D6FF969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1F9D7748-D099-4E25-97F5-9C969D6FF969}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F9D7748-D099-4E25-97F5-9C969D6FF969}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -569,6 +575,7 @@ Global {64E3D8BB-93AB-4571-93F7-ED8D64DFFD06} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818} {E7F491CC-C37E-4A56-9CA7-8F77F59E0614} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} {EA60B549-F712-4ABE-8E44-FCA83B78C06E} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} + {0C3E7D40-E0B3-4B77-8139-0E85C3600688} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} {1F9D7748-D099-4E25-97F5-9C969D6FF969} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} {81234AFA-B4E7-4D0D-AB97-FD559C78EDA2} = {3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} {1F6CC903-04C9-4E7C-B388-C215C467BFB9} = {3862190B-E2C5-418E-AFDC-DB281FB5C705} diff --git a/README.md b/README.md index 7de2546b19c..ad076d2124e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ repo. If you are new here, please read the getting started docs: * [logs](./docs/logs/getting-started/README.md) -* [metrics](./docs/metrics/getting-started/README.md) +* metrics: [ASP.NET Core](./docs/metrics/getting-started-aspnetcore/README.md) | + [Console](./docs/metrics/getting-started-console/README.md) * traces: [ASP.NET Core](./docs/trace/getting-started-aspnetcore/README.md) | [Console](./docs/trace/getting-started-console/README.md) diff --git a/docs/metrics/customizing-the-sdk/README.md b/docs/metrics/customizing-the-sdk/README.md index eb2227a20d1..00f2238381f 100644 --- a/docs/metrics/customizing-the-sdk/README.md +++ b/docs/metrics/customizing-the-sdk/README.md @@ -2,7 +2,8 @@ ## MeterProvider -As shown in the [getting-started](../getting-started/README.md) doc, a valid +As shown in the [getting-startedgetting started in 5 minutes - Console +Application](../getting-started-console/README.md) doc, a valid [`MeterProvider`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterprovider) must be configured and built to collect metrics with OpenTelemetry .NET Sdk. `MeterProvider` holds all the configuration for metrics like MetricReaders, diff --git a/docs/metrics/getting-started-aspnetcore/Program.cs b/docs/metrics/getting-started-aspnetcore/Program.cs new file mode 100644 index 00000000000..d5d6793c74e --- /dev/null +++ b/docs/metrics/getting-started-aspnetcore/Program.cs @@ -0,0 +1,38 @@ +// +// 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. +// + +using System.Diagnostics; +using OpenTelemetry.Metrics; +using OpenTelemetry.Resources; + +var appBuilder = WebApplication.CreateBuilder(args); + +// Configure OpenTelemetry with metrics and auto-start. +appBuilder.Services.AddOpenTelemetry() + .ConfigureResource(builder => builder + .AddService(serviceName: "OTel.NET Getting Started")) + .WithMetrics(builder => builder + .AddAspNetCoreInstrumentation() + .AddConsoleExporter((exporterOptions, metricReaderOptions) => + { + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; + })); + +var app = appBuilder.Build(); + +app.MapGet("/", () => $"Hello from OpenTelemetry Metrics!"); + +app.Run(); diff --git a/docs/metrics/getting-started-aspnetcore/README.md b/docs/metrics/getting-started-aspnetcore/README.md new file mode 100644 index 00000000000..821c640a89a --- /dev/null +++ b/docs/metrics/getting-started-aspnetcore/README.md @@ -0,0 +1,102 @@ +# Getting Started with OpenTelemetry .NET in 5 Minutes - ASP.NET Core Application + +First, download and install the [.NET +SDK](https://dotnet.microsoft.com/download) on your computer. + +Create a new web application: + +```sh +dotnet new web -o aspnetcoreapp +cd aspnetcoreapp +``` + +Install the +[OpenTelemetry.Exporter.Console](../../../src/OpenTelemetry.Exporter.Console/README.md), +[OpenTelemetry.Extensions.Hosting](../../../src/OpenTelemetry.Extensions.Hosting/README.md), +and +[OpenTelemetry.Instrumentation.AspNetCore](../../../src/OpenTelemetry.Exporter.Console/README.md) +packages: + +```sh +dotnet add package OpenTelemetry.Exporter.Console --prerelease +dotnet add package OpenTelemetry.Extensions.Hosting --prerelease +dotnet add package OpenTelemetry.Instrumentation.AspNetCore --prerelease +``` + +> **Note** This quickstart guide uses prerelease packages. For a quickstart +> which only relies on stable packages see: [Getting Started - Console +> Application](../getting-started-console/README.md). For more information about +> when instrumentation will be marked as stable see: [Instrumentation-1.0.0 +> milestone](https://github.com/open-telemetry/opentelemetry-dotnet/milestone/23). + +Update the `Program.cs` file with the code from [Program.cs](./Program.cs). + +Run the application again (using `dotnet run`) and then browse to the url shown +in the console for your application (ex `http://localhost:5154`). You should see +the trace output from the console. + +```text +Export http.server.duration, Measures the duration of inbound HTTP requests., Unit: ms, Meter: OpenTelemetry.Instrumentation.AspNetCore/1.0.0.0 +(2023-04-11T21:49:43.6915232Z, 2023-04-11T21:50:50.6564690Z] http.flavor: 1.1 http.method: GET http.route: / http.scheme: http http.status_code: 200 net.host.name: localhost net.host.port: 5000 Histogram +Value: Sum: 3.5967 Count: 11 Min: 0.073 Max: 2.5539 +(-Infinity,0]:0 +(0,5]:11 +(5,10]:0 +(10,25]:0 +(25,50]:0 +(50,75]:0 +(75,100]:0 +(100,250]:0 +(250,500]:0 +(500,750]:0 +(750,1000]:0 +(1000,2500]:0 +(2500,5000]:0 +(5000,7500]:0 +(7500,10000]:0 +(10000,+Infinity]:0 +``` + +Congratulations! You are now collecting metrics using OpenTelemetry. + +What does the above program do? + +The program uses the +[OpenTelemetry.Instrumentation.AspNetCore](../../../src/OpenTelemetry.Instrumentation.AspNetCore/README.md) +package to automatically create metrics for incoming ASP.NET Core requests, uses +the +[OpenTelemetry.Exporter.Console](../../../src/OpenTelemetry.Exporter.Console/README.md) +package to write metrics to the console every 1000 milliseconds. This is done by +configuring an OpenTelemetry +[MeterProvider](../customizing-the-sdk/README.MD#meterprovider) using extension +methods and setting it to auto-start when the host is started: + +```csharp +appBuilder.Services.AddOpenTelemetry() + .ConfigureResource(builder => builder + .AddService(serviceName: "OTel.NET Getting Started")) + .WithMetrics(builder => builder + .AddAspNetCoreInstrumentation() + .AddConsoleExporter((exporterOptions, metricReaderOptions) => + { + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; + }) + ); +``` + +> **Note** +> The `AddOpenTelemetry` extension is part of the +[OpenTelemetry.Extensions.Hosting](../../../src/OpenTelemetry.Extensions.Hosting/README.md) +package. + +The index route ("/") is set up to write out a greeting message on the response: + +```csharp +app.MapGet("/", () => $"Hello from OpenTelemetry Metrics!"); +``` + +## Learn more + +* [Getting Started with Prometheus and Grafana](../getting-started-prometheus-grafana/README.md) +* [Customizing OpenTelemetry .NET SDK](../customizing-the-sdk/README.md) +* [Extending the OpenTelemetry .NET SDK](../extending-the-sdk/README.md) diff --git a/docs/metrics/getting-started-aspnetcore/appsettings.Development.json b/docs/metrics/getting-started-aspnetcore/appsettings.Development.json new file mode 100644 index 00000000000..770d3e93146 --- /dev/null +++ b/docs/metrics/getting-started-aspnetcore/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/docs/metrics/getting-started-aspnetcore/appsettings.json b/docs/metrics/getting-started-aspnetcore/appsettings.json new file mode 100644 index 00000000000..10f68b8c8b4 --- /dev/null +++ b/docs/metrics/getting-started-aspnetcore/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/docs/metrics/getting-started-aspnetcore/getting-started-aspnetcore.csproj b/docs/metrics/getting-started-aspnetcore/getting-started-aspnetcore.csproj new file mode 100644 index 00000000000..1956f427004 --- /dev/null +++ b/docs/metrics/getting-started-aspnetcore/getting-started-aspnetcore.csproj @@ -0,0 +1,15 @@ + + + + net6.0;net7.0 + enable + enable + + + + + + + + + diff --git a/docs/metrics/getting-started/Program.cs b/docs/metrics/getting-started-console/Program.cs similarity index 100% rename from docs/metrics/getting-started/Program.cs rename to docs/metrics/getting-started-console/Program.cs diff --git a/docs/metrics/getting-started/README.md b/docs/metrics/getting-started-console/README.md similarity index 100% rename from docs/metrics/getting-started/README.md rename to docs/metrics/getting-started-console/README.md diff --git a/docs/metrics/getting-started/getting-started.csproj b/docs/metrics/getting-started-console/getting-started-console.csproj similarity index 100% rename from docs/metrics/getting-started/getting-started.csproj rename to docs/metrics/getting-started-console/getting-started-console.csproj diff --git a/docs/metrics/getting-started-prometheus-grafana/README.md b/docs/metrics/getting-started-prometheus-grafana/README.md index 8c57ed65853..ce4a4d4a8d0 100644 --- a/docs/metrics/getting-started-prometheus-grafana/README.md +++ b/docs/metrics/getting-started-prometheus-grafana/README.md @@ -11,8 +11,9 @@ ## Export metrics from the application -It is highly recommended to go over the [getting-started](../getting-started/README.md) -doc before following along this document. +It is highly recommended to go over the [getting started in 5 minutes - Console +Application](../getting-started-console/README.md) doc before following along +this document. Create a new console application and run it: @@ -33,8 +34,8 @@ Now, we are going to make some small tweaks to the example in the getting-started metrics `Program.cs` to make the metrics available via OpenTelemetry Prometheus Exporter. -First, copy and paste everything from getting-started -metrics [example](../getting-started/Program.cs) to the Program.cs file of the +First, copy and paste everything from getting-started metrics +[example](../getting-started-console/Program.cs) to the Program.cs file of the new console application (getting-started-prometheus) we've created. And replace the below line: diff --git a/src/OpenTelemetry.Exporter.Console/README.md b/src/OpenTelemetry.Exporter.Console/README.md index 35b90fed0f2..1394cb255a7 100644 --- a/src/OpenTelemetry.Exporter.Console/README.md +++ b/src/OpenTelemetry.Exporter.Console/README.md @@ -21,7 +21,8 @@ See the individual "getting started" examples depending on the signal being used: * [Logs](../../docs/logs/getting-started/Program.cs) -* [Metrics](../../docs/metrics/getting-started/Program.cs) +* Metrics: [ASP.NET Core](../../docs/metrics/getting-started-aspnetcore/README.md) + | [Console](../../docs/metrics/getting-started-console/README.md) * Traces: [ASP.NET Core](../../docs/trace/getting-started-aspnetcore/README.md) | [Console](../../docs/trace/getting-started-console/README.md) diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index 3353fb6e6d4..e9582acc9f7 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -53,9 +53,11 @@ OpenTelemetry logging. If you are new to [metrics](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md), -it is first recommended to follow the [getting started in 5 -minutes](../../docs/metrics/getting-started/README.md) guide to get up and -running. +it is recommended to first follow the [getting started in 5 minutes - ASP.NET +Core Application](../../docs/metrics/getting-started-aspnetcore/README.md) guide +or the [getting started in 5 minutes - Console +Application](../../docs/metrics/getting-started-console/README.md) guide to get up +and running. For a more detailed explanation of SDK metric features see [Customizing OpenTelemetry .NET SDK for From eaaf10ab00064ed83e010c5020ce17bf22e19c8a Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Thu, 13 Apr 2023 16:29:28 -0700 Subject: [PATCH 2/5] Editorial: remove --prerelease for packages that already shipped stable version (#4389) --- docs/metrics/getting-started-aspnetcore/README.md | 4 ++-- docs/metrics/getting-started-prometheus-grafana/README.md | 2 +- docs/trace/getting-started-aspnetcore/README.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/metrics/getting-started-aspnetcore/README.md b/docs/metrics/getting-started-aspnetcore/README.md index 821c640a89a..75cd858e084 100644 --- a/docs/metrics/getting-started-aspnetcore/README.md +++ b/docs/metrics/getting-started-aspnetcore/README.md @@ -18,8 +18,8 @@ and packages: ```sh -dotnet add package OpenTelemetry.Exporter.Console --prerelease -dotnet add package OpenTelemetry.Extensions.Hosting --prerelease +dotnet add package OpenTelemetry.Exporter.Console +dotnet add package OpenTelemetry.Extensions.Hosting dotnet add package OpenTelemetry.Instrumentation.AspNetCore --prerelease ``` diff --git a/docs/metrics/getting-started-prometheus-grafana/README.md b/docs/metrics/getting-started-prometheus-grafana/README.md index ce4a4d4a8d0..69e87c9f793 100644 --- a/docs/metrics/getting-started-prometheus-grafana/README.md +++ b/docs/metrics/getting-started-prometheus-grafana/README.md @@ -27,7 +27,7 @@ Add a reference to [Prometheus Exporter Http Listener](../../../src/OpenTelemetry.Exporter.Prometheus.HttpListener/README.md): ```sh -dotnet add package --prerelease OpenTelemetry.Exporter.Prometheus.HttpListener +dotnet add package OpenTelemetry.Exporter.Prometheus.HttpListener --prerelease ``` Now, we are going to make some small tweaks to the example in the diff --git a/docs/trace/getting-started-aspnetcore/README.md b/docs/trace/getting-started-aspnetcore/README.md index c9c7393f7f4..e21c5b7301f 100644 --- a/docs/trace/getting-started-aspnetcore/README.md +++ b/docs/trace/getting-started-aspnetcore/README.md @@ -18,8 +18,8 @@ and packages: ```sh -dotnet add package OpenTelemetry.Exporter.Console --prerelease -dotnet add package OpenTelemetry.Extensions.Hosting --prerelease +dotnet add package OpenTelemetry.Exporter.Console +dotnet add package OpenTelemetry.Extensions.Hosting dotnet add package OpenTelemetry.Instrumentation.AspNetCore --prerelease ``` From 30b7b79e9c170e3dd58f3b80a458dcb47cc0bde0 Mon Sep 17 00:00:00 2001 From: Yun-Ting Lin Date: Fri, 14 Apr 2023 13:06:00 -0700 Subject: [PATCH 3/5] added a test for Histogram `Update` and `TakeSnapshot` methods (#4340) --- .../Metrics/AggregatorTest.cs | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs b/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs index ef76b879a7c..bbf9af4cc9f 100644 --- a/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs +++ b/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs @@ -188,6 +188,42 @@ public void HistogramWithOnlySumCount() Assert.False(enumerator.MoveNext()); } + [Fact] + public void MultiThreadedHistogramUpdateAndSnapShotTest() + { + var boundaries = Array.Empty(); + var histogramPoint = new MetricPoint(this.aggregatorStore, AggregationType.Histogram, null, boundaries, Metric.DefaultExponentialHistogramMaxBuckets, Metric.DefaultExponentialHistogramMaxScale); + var argsToThread = new ThreadArguments + { + HistogramPoint = histogramPoint, + MreToEnsureAllThreadsStart = new ManualResetEvent(false), + }; + + var numberOfThreads = 2; + var snapshotThread = new Thread(HistogramSnapshotThread); + Thread[] updateThreads = new Thread[numberOfThreads]; + for (int i = 0; i < numberOfThreads; ++i) + { + updateThreads[i] = new Thread(HistogramUpdateThread); + updateThreads[i].Start(argsToThread); + } + + snapshotThread.Start(argsToThread); + + for (int i = 0; i < numberOfThreads; ++i) + { + updateThreads[i].Join(); + } + + snapshotThread.Join(); + + // last snapshot + histogramPoint.TakeSnapshot(outputDelta: true); + + var lastDelta = histogramPoint.GetHistogramSum(); + Assert.Equal(200, argsToThread.SumOfDelta + lastDelta); + } + internal static void AssertExponentialBucketsAreCorrect(Base2ExponentialBucketHistogram expectedHistogram, ExponentialHistogramData data) { Assert.Equal(expectedHistogram.Scale, data.Scale); @@ -372,5 +408,55 @@ internal void ExponentialMaxScaleConfigWorks(int? maxScale) var expectedScale = maxScale.HasValue ? maxScale : Metric.DefaultExponentialHistogramMaxScale; Assert.Equal(expectedScale, metricPoint.GetExponentialHistogramData().Scale); } + + private static void HistogramSnapshotThread(object obj) + { + var args = obj as ThreadArguments; + var mreToEnsureAllThreadsStart = args.MreToEnsureAllThreadsStart; + + if (Interlocked.Increment(ref args.ThreadStartedCount) == 3) + { + mreToEnsureAllThreadsStart.Set(); + } + + mreToEnsureAllThreadsStart.WaitOne(); + + double curSnapshotDelta; + while (Interlocked.Read(ref args.ThreadsFinishedAllUpdatesCount) != 2) + { + args.HistogramPoint.TakeSnapshot(outputDelta: true); + curSnapshotDelta = args.HistogramPoint.GetHistogramSum(); + args.SumOfDelta += curSnapshotDelta; + } + } + + private static void HistogramUpdateThread(object obj) + { + var args = obj as ThreadArguments; + var mreToEnsureAllThreadsStart = args.MreToEnsureAllThreadsStart; + + if (Interlocked.Increment(ref args.ThreadStartedCount) == 3) + { + mreToEnsureAllThreadsStart.Set(); + } + + mreToEnsureAllThreadsStart.WaitOne(); + + for (int i = 0; i < 10; ++i) + { + args.HistogramPoint.Update(10); + } + + Interlocked.Increment(ref args.ThreadsFinishedAllUpdatesCount); + } + + private class ThreadArguments + { + public MetricPoint HistogramPoint; + public ManualResetEvent MreToEnsureAllThreadsStart; + public int ThreadStartedCount; + public long ThreadsFinishedAllUpdatesCount; + public double SumOfDelta; + } } } From 457a9e95a4a72edd6cb51ed0ac734316e7ced565 Mon Sep 17 00:00:00 2001 From: Javier Rebagliatti Date: Mon, 17 Apr 2023 20:27:29 +0200 Subject: [PATCH 4/5] Add direct reference to System.Text.Encodings.Web version 4.7.2 due to CVE-2021-26701 (#4390) --- build/Common.props | 1 + src/OpenTelemetry.Exporter.Console/CHANGELOG.md | 3 +++ .../OpenTelemetry.Exporter.Console.csproj | 1 + src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md | 3 +++ .../OpenTelemetry.Exporter.Jaeger.csproj | 1 + src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 3 +++ .../OpenTelemetry.Exporter.Zipkin.csproj | 1 + 7 files changed, 13 insertions(+) diff --git a/build/Common.props b/build/Common.props index 7179ee4e35a..a3c3e048d32 100644 --- a/build/Common.props +++ b/build/Common.props @@ -49,6 +49,7 @@ [1.2.0-beta.435,2.0) 1.4.0 7.0.0 + 4.7.2 4.7.2 4.5.4 diff --git a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md index 6d239cc9140..a19d0a8052a 100644 --- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Added direct reference to `System.Text.Encodings.Web` with minimum version of +`4.7.2` in response to [CVE-2021-26701](https://github.com/dotnet/runtime/issues/49377). + ## 1.5.0-alpha.2 Released 2023-Mar-31 diff --git a/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj b/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj index f67383e6b18..792ce7152df 100644 --- a/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj +++ b/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj @@ -16,6 +16,7 @@ + diff --git a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md index ef0f3ecad89..785130c3f29 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Added direct reference to `System.Text.Encodings.Web` with minimum version of +`4.7.2` in response to [CVE-2021-26701](https://github.com/dotnet/runtime/issues/49377). + ## 1.5.0-alpha.2 Released 2023-Mar-31 diff --git a/src/OpenTelemetry.Exporter.Jaeger/OpenTelemetry.Exporter.Jaeger.csproj b/src/OpenTelemetry.Exporter.Jaeger/OpenTelemetry.Exporter.Jaeger.csproj index 8744f50528a..179b1b2f84f 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/OpenTelemetry.Exporter.Jaeger.csproj +++ b/src/OpenTelemetry.Exporter.Jaeger/OpenTelemetry.Exporter.Jaeger.csproj @@ -33,6 +33,7 @@ + diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index cacfedf8b04..52363af47cd 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Added direct reference to `System.Text.Encodings.Web` with minimum version of +`4.7.2` in response to [CVE-2021-26701](https://github.com/dotnet/runtime/issues/49377). + ## 1.5.0-alpha.2 Released 2023-Mar-31 diff --git a/src/OpenTelemetry.Exporter.Zipkin/OpenTelemetry.Exporter.Zipkin.csproj b/src/OpenTelemetry.Exporter.Zipkin/OpenTelemetry.Exporter.Zipkin.csproj index f5d9deea5a7..b8232e7c153 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/OpenTelemetry.Exporter.Zipkin.csproj +++ b/src/OpenTelemetry.Exporter.Zipkin/OpenTelemetry.Exporter.Zipkin.csproj @@ -28,6 +28,7 @@ + From 085cdd4f6f79fa64e065f057c9b2599f3f2c1e91 Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Mon, 17 Apr 2023 14:42:15 -0700 Subject: [PATCH 5/5] Minor doc fixes (#4397) --- README.md | 2 +- docs/metrics/getting-started-aspnetcore/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad076d2124e..51b3389b196 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,8 @@ libraries](https://github.com/open-telemetry/opentelemetry-specification/blob/ma * [Jaeger](./src/OpenTelemetry.Exporter.Jaeger/README.md) * [OTLP](./src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md) (OpenTelemetry Protocol) -* [Prometheus HttpListener](./src/OpenTelemetry.Exporter.Prometheus.HttpListener/README.md) * [Prometheus AspNetCore](./src/OpenTelemetry.Exporter.Prometheus.AspNetCore/README.md) +* [Prometheus HttpListener](./src/OpenTelemetry.Exporter.Prometheus.HttpListener/README.md) * [Zipkin](./src/OpenTelemetry.Exporter.Zipkin/README.md) See the [OpenTelemetry registry](https://opentelemetry.io/registry/?s=net) and diff --git a/docs/metrics/getting-started-aspnetcore/README.md b/docs/metrics/getting-started-aspnetcore/README.md index 75cd858e084..6d63911a374 100644 --- a/docs/metrics/getting-started-aspnetcore/README.md +++ b/docs/metrics/getting-started-aspnetcore/README.md @@ -33,7 +33,7 @@ Update the `Program.cs` file with the code from [Program.cs](./Program.cs). Run the application again (using `dotnet run`) and then browse to the url shown in the console for your application (ex `http://localhost:5154`). You should see -the trace output from the console. +the metrics output from the console. ```text Export http.server.duration, Measures the duration of inbound HTTP requests., Unit: ms, Meter: OpenTelemetry.Instrumentation.AspNetCore/1.0.0.0