From c1214c4f0143922f19fd378bd35d1014e10eeb02 Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Thu, 18 Apr 2024 20:12:53 -0700 Subject: [PATCH] Remove predicate based View examples --- docs/metrics/customizing-the-sdk/Program.cs | 12 ---- docs/metrics/customizing-the-sdk/README.md | 73 --------------------- 2 files changed, 85 deletions(-) diff --git a/docs/metrics/customizing-the-sdk/Program.cs b/docs/metrics/customizing-the-sdk/Program.cs index 48c9a975311..c88a295fdd7 100644 --- a/docs/metrics/customizing-the-sdk/Program.cs +++ b/docs/metrics/customizing-the-sdk/Program.cs @@ -40,18 +40,6 @@ public static void Main() // Drop the instrument "MyCounterDrop". .AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop) - // Advanced selection criteria and config via Func - .AddView((instrument) => - { - if (instrument.Meter.Name.Equals("CompanyA.ProductB.Library2") && - instrument.GetType().Name.Contains("Histogram")) - { - return new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } }; - } - - return null; - }) - // An instrument which does not match any views // gets processed with default behavior. (SDK default) // Uncommenting the following line will diff --git a/docs/metrics/customizing-the-sdk/README.md b/docs/metrics/customizing-the-sdk/README.md index 4541e1a4ccc..aceff88d8fb 100644 --- a/docs/metrics/customizing-the-sdk/README.md +++ b/docs/metrics/customizing-the-sdk/README.md @@ -136,20 +136,6 @@ own the instrument to create it with a different name. .AddView(instrumentName: "MyCounter", name: "MyCounterRenamed") ``` -```csharp - // Advanced selection criteria and config via Func - .AddView((instrument) => - { - if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" && - instrument.Name == "MyCounter") - { - return new MetricStreamConfiguration() { Name = "MyCounterRenamed" }; - } - - return null; - }) -``` - #### Drop an instrument When using `AddMeter` to add a Meter to the provider, all the instruments from @@ -162,20 +148,6 @@ then it is recommended to simply not add that `Meter` using `AddMeter`. .AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop) ``` -```csharp - // Advanced selection criteria and config via Func - .AddView((instrument) => - { - if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" && - instrument.Name == "MyCounterDrop") - { - return MetricStreamConfiguration.Drop; - } - - return null; - }) -``` - #### Select specific tags When recording a measurement from an instrument, all the tags that were provided @@ -219,23 +191,6 @@ with the metric are of interest to you. ... ``` -```csharp - // Advanced selection criteria and config via Func - .AddView((instrument) => - { - if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" && - instrument.Name == "MyFruitCounter") - { - return new MetricStreamConfiguration - { - TagKeys = new string[] { "name" }, - }; - } - - return null; - }) -``` - #### Configuring the aggregation of a Histogram There are two types of @@ -274,24 +229,6 @@ default boundaries. This requires the use of new ExplicitBucketHistogramConfiguration { Boundaries = Array.Empty() }) ``` -```csharp - // Advanced selection criteria and config via Func - .AddView((instrument) => - { - if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" && - instrument.Name == "MyHistogram") - { - // `ExplicitBucketHistogramConfiguration` is a child class of `MetricStreamConfiguration` - return new ExplicitBucketHistogramConfiguration - { - Boundaries = new double[] { 10, 20 }, - }; - } - - return null; - }) -``` - ##### Base2 exponential bucket histogram aggregation By default, a Histogram is configured to use the @@ -313,16 +250,6 @@ within the maximum number of buckets defined by `MaxSize`. The default new Base2ExponentialBucketHistogramConfiguration { MaxSize = 40 }) ``` -```csharp - // Configure all histogram instruments to use the Base2 Exponential Histogram aggregation - .AddView((instrument) => - { - return instrument.GetType().GetGenericTypeDefinition() == typeof(Histogram<>) - ? new Base2ExponentialBucketHistogramConfiguration() - : null; - }) -``` - > [!NOTE] > The SDK currently does not support any changes to `Aggregation` type by using Views.