@@ -115,14 +115,9 @@ name starts with "Abc.".
115
115
A
116
116
[ View] ( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#view )
117
117
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.
126
121
127
122
#### Rename an instrument
128
123
@@ -136,20 +131,6 @@ own the instrument to create it with a different name.
136
131
.AddView (instrumentName : " MyCounter" , name : " MyCounterRenamed" )
137
132
```
138
133
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
-
153
134
#### Drop an instrument
154
135
155
136
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`.
162
143
.AddView (instrumentName : " MyCounterDrop" , MetricStreamConfiguration .Drop )
163
144
```
164
145
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
-
179
146
#### Select specific tags
180
147
181
148
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.
219
186
.. .
220
187
```
221
188
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
-
239
189
#### Configuring the aggregation of a Histogram
240
190
241
191
There are two types of
@@ -274,24 +224,6 @@ default boundaries. This requires the use of
274
224
new ExplicitBucketHistogramConfiguration { Boundaries = Array .Empty <double >() })
275
225
```
276
226
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
-
295
227
##### Base2 exponential bucket histogram aggregation
296
228
297
229
By default, a Histogram is configured to use the
@@ -313,16 +245,6 @@ within the maximum number of buckets defined by `MaxSize`. The default
313
245
new Base2ExponentialBucketHistogramConfiguration { MaxSize = 40 })
314
246
```
315
247
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
-
326
248
> [ !NOTE]
327
249
> The SDK currently does not support any changes to ` Aggregation ` type
328
250
by using Views.
0 commit comments