Skip to content

Commit 89eb564

Browse files
authored
Update api-custom-events-metrics.md
Update flush guidance as discussed in the email thread.
1 parent 9f8501f commit 89eb564

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

articles/azure-monitor/app/api-custom-events-metrics.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,24 @@ dependencies
630630

631631
Normally, the SDK sends data at fixed intervals (typically 30 secs) or whenever buffer is full (typically 500 items). However, in some cases, you might want to flush the buffer--for example, if you are using the SDK in an application that shuts down.
632632

633-
*?.NET*
633+
*.NET*
634+
635+
When using Flush(), we recommend this [pattern](./console#full-example):
634636

635637
```csharp
636638
telemetry.Flush();
637639
// Allow some time for flushing before shutdown.
638640
System.Threading.Thread.Sleep(5000);
639641
```
640642

643+
When using FlushAsync(), we recommend this pattern:
644+
645+
```csharp
646+
await telemetryClient.FlushAsync()
647+
```
648+
649+
We recommend always flushing as part of the application shutdown to guarantee that telemetry is not lost.
650+
641651
*Java*
642652

643653
```java
@@ -654,7 +664,8 @@ telemetry.flush();
654664

655665
The function is asynchronous for the [server telemetry channel](https://www.nuget.org/packages/Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel/).
656666

657-
We recommend using the flush() or flushAsync() methods in the shutdown activity of the Application when using the .NET SDK.
667+
> [!NOTE]
668+
> The Java and Javascript SDKs automatically flush on application shutdown.
658669
659670
## Authenticated users
660671

0 commit comments

Comments
 (0)