Skip to content

Commit f76d21a

Browse files
authored
[docs-metrics] Remove predicate-based View examples (#5554)
1 parent 84bdeb3 commit f76d21a

File tree

2 files changed

+3
-93
lines changed

2 files changed

+3
-93
lines changed

docs/metrics/customizing-the-sdk/Program.cs

-12
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,6 @@ public static void Main()
4040
// Drop the instrument "MyCounterDrop".
4141
.AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop)
4242

43-
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
44-
.AddView((instrument) =>
45-
{
46-
if (instrument.Meter.Name.Equals("CompanyA.ProductB.Library2") &&
47-
instrument.GetType().Name.Contains("Histogram"))
48-
{
49-
return new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } };
50-
}
51-
52-
return null;
53-
})
54-
5543
// An instrument which does not match any views
5644
// gets processed with default behavior. (SDK default)
5745
// Uncommenting the following line will

docs/metrics/customizing-the-sdk/README.md

+3-81
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,9 @@ name starts with "Abc.".
115115
A
116116
[View](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#view)
117117
provides the ability to customize the metrics that are output by the SDK.
118-
Following sections explains how to use this feature. Each section has two code
119-
snippets. The first one uses an overload of `AddView` method that takes in the
120-
name of the instrument as the first parameter. The `View` configuration is then
121-
applied to the matching instrument name. The second code snippet shows how to
122-
use an advanced selection criteria to achieve the same results. This requires
123-
the user to provide a `Func<Instrument, MetricStreamConfiguration>` which offers
124-
more flexibility in filtering the instruments to which the `View` should be
125-
applied.
118+
Following sections explains how to use `AddView` method that takes the
119+
instrument name as the first parameter, the `View` configuration is then applied
120+
to the matching instrument name.
126121

127122
#### Rename an instrument
128123

@@ -136,20 +131,6 @@ own the instrument to create it with a different name.
136131
.AddView(instrumentName: "MyCounter", name: "MyCounterRenamed")
137132
```
138133

139-
```csharp
140-
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
141-
.AddView((instrument) =>
142-
{
143-
if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" &&
144-
instrument.Name == "MyCounter")
145-
{
146-
return new MetricStreamConfiguration() { Name = "MyCounterRenamed" };
147-
}
148-
149-
return null;
150-
})
151-
```
152-
153134
#### Drop an instrument
154135

155136
When using `AddMeter` to add a Meter to the provider, all the instruments from
@@ -162,20 +143,6 @@ then it is recommended to simply not add that `Meter` using `AddMeter`.
162143
.AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop)
163144
```
164145

165-
```csharp
166-
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
167-
.AddView((instrument) =>
168-
{
169-
if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" &&
170-
instrument.Name == "MyCounterDrop")
171-
{
172-
return MetricStreamConfiguration.Drop;
173-
}
174-
175-
return null;
176-
})
177-
```
178-
179146
#### Select specific tags
180147

181148
When recording a measurement from an instrument, all the tags that were provided
@@ -219,23 +186,6 @@ with the metric are of interest to you.
219186
...
220187
```
221188

222-
```csharp
223-
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
224-
.AddView((instrument) =>
225-
{
226-
if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" &&
227-
instrument.Name == "MyFruitCounter")
228-
{
229-
return new MetricStreamConfiguration
230-
{
231-
TagKeys = new string[] { "name" },
232-
};
233-
}
234-
235-
return null;
236-
})
237-
```
238-
239189
#### Configuring the aggregation of a Histogram
240190

241191
There are two types of
@@ -274,24 +224,6 @@ default boundaries. This requires the use of
274224
new ExplicitBucketHistogramConfiguration { Boundaries = Array.Empty<double>() })
275225
```
276226

277-
```csharp
278-
// Advanced selection criteria and config via Func<Instrument, MetricStreamConfiguration>
279-
.AddView((instrument) =>
280-
{
281-
if (instrument.Meter.Name == "CompanyA.ProductB.LibraryC" &&
282-
instrument.Name == "MyHistogram")
283-
{
284-
// `ExplicitBucketHistogramConfiguration` is a child class of `MetricStreamConfiguration`
285-
return new ExplicitBucketHistogramConfiguration
286-
{
287-
Boundaries = new double[] { 10, 20 },
288-
};
289-
}
290-
291-
return null;
292-
})
293-
```
294-
295227
##### Base2 exponential bucket histogram aggregation
296228

297229
By default, a Histogram is configured to use the
@@ -313,16 +245,6 @@ within the maximum number of buckets defined by `MaxSize`. The default
313245
new Base2ExponentialBucketHistogramConfiguration { MaxSize = 40 })
314246
```
315247

316-
```csharp
317-
// Configure all histogram instruments to use the Base2 Exponential Histogram aggregation
318-
.AddView((instrument) =>
319-
{
320-
return instrument.GetType().GetGenericTypeDefinition() == typeof(Histogram<>)
321-
? new Base2ExponentialBucketHistogramConfiguration()
322-
: null;
323-
})
324-
```
325-
326248
> [!NOTE]
327249
> The SDK currently does not support any changes to `Aggregation` type
328250
by using Views.

0 commit comments

Comments
 (0)