Skip to content

Commit 2e9baef

Browse files
authored
Merge pull request #103196 from lzchen/patch-1
Add fixed rate sampling for OpenCensus Python SDK for log exporter
2 parents a3bd760 + 39a80fb commit 2e9baef

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

articles/azure-monitor/app/sampling.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,13 @@ The telemetry types that can be included or excluded from sampling are: `Depende
342342

343343
### Configuring fixed-rate sampling for OpenCensus Python applications
344344

345-
1. Instrument your application with the latest [OpenCensus Azure Monitor exporters](../../azure-monitor/app/opencensus-python.md).
345+
Instrument your application with the latest [OpenCensus Azure Monitor exporters](../../azure-monitor/app/opencensus-python.md).
346346

347347
> [!NOTE]
348-
> Fixed-rate sampling is only available using the trace exporter. This means incoming and outgoing requests are the only types of telemetry where sampling can be configured.
348+
> Fixed-rate sampling is not available for the metrics exporter. This means custom metrics are the only types of telemetry where sampling can NOT be configured. The metrics exporter will send all telemetry that it tracks.
349349

350-
2. You may specify a `sampler` as part of your `Tracer` configuration. If no explicit sampler is provided, the `ProbabilitySampler` will be used by default. The `ProbabilitySampler` would use a rate of 1/10000 by default, meaning one out of every 10000 requests will be sent to Application Insights. If you want to specify a sampling rate, see below.
350+
#### Fixed-rate sampling for tracing ####
351+
You may specify a `sampler` as part of your `Tracer` configuration. If no explicit sampler is provided, the `ProbabilitySampler` will be used by default. The `ProbabilitySampler` would use a rate of 1/10000 by default, meaning one out of every 10000 requests will be sent to Application Insights. If you want to specify a sampling rate, see below.
351352

352353
To specify the sampling rate, make sure your `Tracer` specifies a sampler with a sampling rate between 0.0 and 1.0 inclusive. A sampling rate of 1.0 represents 100%, meaning all of your requests will be sent as telemetry to Application Insights.
353354

@@ -360,6 +361,16 @@ tracer = Tracer(
360361
)
361362
```
362363

364+
#### Fixed-rate sampling for logs ####
365+
You can configure fixed-rate sampling for `AzureLogHandler` by modifying the `logging_sampling_rate` optional argument. If no argument is supplied, a sampling rate of 1.0 will be used. A sampling rate of 1.0 represents 100%, meaning all of your requests will be sent as telemetry to Application Insights.
366+
367+
```python
368+
exporter = metrics_exporter.new_metrics_exporter(
369+
instrumentation_key='00000000-0000-0000-0000-000000000000',
370+
logging_sampling_rate=0.5,
371+
)
372+
```
373+
363374
### Configuring fixed-rate sampling for web pages with JavaScript
364375

365376
JavaScript-based web pages can be configured to use Application Insights. Telemetry is sent from the client application running within the user's browser, and the pages can be hosted from any server.

0 commit comments

Comments
 (0)