@@ -168,13 +168,44 @@ using var tracerProvider = Sdk.CreateMeterProviderBuilder()
168
168
169
169
Alternatively, instrumentation libraries can be disabled by the environment
170
170
variable ` GRAFANA_DOTNET_DISABLE_INSTRUMENTATIONS ` . This variable can be
171
- populated with a comma-separated list of instrumentation library identifiers
172
- from the table above :
171
+ populated with a comma-separated list of
172
+ [ instrumentation library identifiers ] ( ./supported-instrumentations.md ) :
173
173
174
174
``` sh
175
175
export GRAFANA_DOTNET_DISABLE_INSTRUMENTATIONS=" Process,NetRuntime"
176
176
```
177
177
178
+ ### Adding instrumentations not supported by the distribution
179
+
180
+ Instrumentations not included in the distribution can easily be added by
181
+ extension methods on the tracer and meter provider.
182
+
183
+ For example, if it is desired to use the ` EventCounters ` instrumentation, which is
184
+ not included in the [ full package] ( ./installation.md#install-the-full-package-with-all-available-instrumentations ) ,
185
+ one install the ` EventCounters ` instrumentation library along with the base
186
+ package.
187
+
188
+ ``` sh
189
+ dotnet add package --prerelease Grafana.OpenTelemetry.Base
190
+ dotnet add package OpenTelemetry.Instrumentation.EventCounters --prerelease
191
+ ```
192
+
193
+ Then, the ` EventCounters ` instrumentation can be enabled via the [ ` AddEventCountersInstrumentation ` ] ( https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.Instrumentation.EventCounters#step-2-enable-eventcounters-instrumentation )
194
+ extension method, alongside the ` UseGrafana ` method.
195
+
196
+ ``` csharp
197
+ using var tracerProvider = Sdk .CreateTracerProviderBuilder ()
198
+ .UseGrafana ()
199
+ .AddEventCountersInstrumentation (options => {
200
+ options .RefreshIntervalSecs = 1 ;
201
+ options .AddEventSources (" MyEventSource" );
202
+ })
203
+ .Build ();
204
+ ```
205
+
206
+ This way, any other instrumentation library [ not supported by the distribution] ( ./supported-instrumentations.md )
207
+ can be added according to the documentation provided with it.
208
+
178
209
## Resource detector configuration
179
210
180
211
### Specifying resource detectors
@@ -193,11 +224,12 @@ using var tracerProvider = Sdk.CreateMeterProviderBuilder()
193
224
```
194
225
195
226
Alternatively, resource detectors can be specified by the environment
196
- variable ` GRAFANA_DOTNET_RESOURCEDETECTORS ` . This variable can be
197
- populated with a comma-separated list of resource detector identifiers:
227
+ variable ` GRAFANA_DOTNET_RESOURCE_DETECTORS ` . This variable can be
228
+ populated with a comma-separated list of
229
+ [ resource detector identifiers] ( ./supported-resource-detectors.md ) :
198
230
199
231
``` sh
200
- export GRAFANA_DOTNET_RESOURCEDETECTORS =" Process"
232
+ export GRAFANA_DOTNET_RESOURCE_DETECTORS =" Process"
201
233
```
202
234
203
235
### Disabling resource detectors
@@ -217,42 +249,31 @@ using var tracerProvider = Sdk.CreateMeterProviderBuilder()
217
249
```
218
250
219
251
Alternatively, resource detectors can be disabled by the environment
220
- variable ` GRAFANA_DOTNET_DISABLE_RESOURCEDETECTORS ` . This variable can be
252
+ variable ` GRAFANA_DOTNET_DISABLE_RESOURCE_DETECTORS ` . This variable can be
221
253
populated with a comma-separated list of resource detector identifiers:
222
254
223
255
``` sh
224
- export GRAFANA_DOTNET_DISABLE_RESOURCEDETECTORS =" Host,Process"
256
+ export GRAFANA_DOTNET_DISABLE_RESOURCE_DETECTORS =" Host,Process"
225
257
```
226
258
227
- ### Adding instrumentations not supported by the distribution
259
+ ### Adding resource detectors not supported by the distribution
228
260
229
- Instrumentations not included in the distribution can easily be added by
261
+ Resource detectors not included in the distribution can easily be added by
230
262
extension methods on the tracer and meter provider.
231
263
232
- For example, if it is desired to use the ` EventCounters ` instrumentation, which is
233
- not included in the [ full package] ( ./installation.md#install-the-full-package-with-all-available-instrumentations ) ,
234
- one install the ` EventCounters ` instrumentation library along with the base
235
- package.
236
-
237
- ``` sh
238
- dotnet add package --prerelease Grafana.OpenTelemetry.Base
239
- dotnet add package OpenTelemetry.Instrumentation.EventCounters --prerelease
240
- ```
241
-
242
- Then, the ` EventCounters ` instrumentation can be enabled via the [ ` AddEventCountersInstrumentation ` ] ( https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.Instrumentation.EventCounters#step-2-enable-eventcounters-instrumentation )
264
+ To enable an unsupported resource detector, call the ` ConfigureResource `
243
265
extension method, alongside the ` UseGrafana ` method.
244
266
245
267
``` csharp
246
268
using var tracerProvider = Sdk .CreateTracerProviderBuilder ()
247
269
.UseGrafana ()
248
- .AddEventCountersInstrumentation (options => {
249
- options .RefreshIntervalSecs = 1 ;
250
- options .AddEventSources (" MyEventSource" );
270
+ .ConfigureResource (config => {
271
+ config .AddCustomResourceDetector ();
251
272
})
252
273
.Build ();
253
274
```
254
275
255
- This way, any other instrumentation library [ not supported by the distribution] ( ./supported-instrumentations .md )
276
+ This way, any other resource detector library [ not supported by the distribution] ( ./supported-resource-detectors .md )
256
277
can be added according to the documentation provided with it.
257
278
258
279
### Extra steps to activate specific instrumentations
@@ -361,4 +382,4 @@ are not contained in the distribution.
361
382
| Variable | Example value | Description |
362
383
| ----------------------------------------- | ------------------ | ----------- |
363
384
| ` GRAFANA_DOTNET_DISABLE_INSTRUMENTATIONS ` | "Process,NetRuntime" | A comma-separated list of instrumentations to disable. |
364
- | ` GRAFANA_DOTNET_DISABLE_RESOURCEDETECTORS ` | "Host" | A comma-separated list of resource detectors to disable. |
385
+ | ` GRAFANA_DOTNET_DISABLE_RESOURCE_DETECTORS ` | "Host" | A comma-separated list of resource detectors to disable. |
0 commit comments