Skip to content

Commit

Permalink
Remove predicate based View examples
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang committed Apr 19, 2024
1 parent 84bdeb3 commit c1214c4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 85 deletions.
12 changes: 0 additions & 12 deletions docs/metrics/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ public static void Main()
// Drop the instrument "MyCounterDrop".
.AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop)

// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
.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
Expand Down
73 changes: 0 additions & 73 deletions docs/metrics/customizing-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Instrument, MetricStreamConfiguration>
.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
Expand All @@ -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<Instrument, MetricStreamConfiguration>
.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
Expand Down Expand Up @@ -219,23 +191,6 @@ with the metric are of interest to you.
...
```

```csharp
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
.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
Expand Down Expand Up @@ -274,24 +229,6 @@ default boundaries. This requires the use of
new ExplicitBucketHistogramConfiguration { Boundaries = Array.Empty<double>() })
```

```csharp
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
.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
Expand All @@ -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.
Expand Down

0 comments on commit c1214c4

Please sign in to comment.