File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,14 @@ evt_status_t mat_upload(evt_context_t *ctx)
329
329
return result;
330
330
}
331
331
332
+ evt_status_t mat_flushAndTeardown (evt_context_t *ctx)
333
+ {
334
+ VERIFY_CLIENT_HANDLE (client, ctx);
335
+ client->logmanager ->FlushAndTeardown ();
336
+ ctx->result = STATUS_SUCCESS;
337
+ return STATUS_SUCCESS;
338
+ }
339
+
332
340
evt_status_t mat_flush (evt_context_t *ctx)
333
341
{
334
342
VERIFY_CLIENT_HANDLE (client, ctx);
@@ -411,6 +419,9 @@ extern "C" {
411
419
result = STATUS_SUCCESS;
412
420
break ;
413
421
422
+ case EVT_OP_FLUSHANDTEARDOWN:
423
+ result = mat_flushAndTeardown (ctx);
424
+ break ;
414
425
// Add more OPs here
415
426
416
427
default :
Original file line number Diff line number Diff line change @@ -74,6 +74,11 @@ namespace MAT_NS_BEGIN
74
74
return evt_upload (handle);
75
75
}
76
76
77
+ evt_status_t flushAndTeardown ()
78
+ {
79
+ return evt_flushAndTeardown (handle);
80
+ }
81
+
77
82
evt_status_t flush ()
78
83
{
79
84
return evt_flush (handle);
Original file line number Diff line number Diff line change @@ -59,7 +59,8 @@ extern "C" {
59
59
EVT_OP_FLUSH = 0x0000000A ,
60
60
EVT_OP_VERSION = 0x0000000B ,
61
61
EVT_OP_OPEN_WITH_PARAMS = 0x0000000C ,
62
- EVT_OP_MAX = EVT_OP_OPEN_WITH_PARAMS + 1
62
+ EVT_OP_FLUSHANDTEARDOWN = 0x0000000D ,
63
+ EVT_OP_MAX = EVT_OP_OPEN_WITH_PARAMS + 1 ,
63
64
} evt_call_t ;
64
65
65
66
typedef enum evt_prop_t
@@ -576,6 +577,22 @@ extern "C" {
576
577
ctx .handle = handle ;
577
578
return evt_api_call (& ctx );
578
579
}
580
+
581
+ /** <summary>
582
+ * Flush any pending telemetry events in memory to disk,
583
+ * attempt upload of events if tear down interval is configured,
584
+ * and eventually tear down the telemetry logging system.
585
+ * </summary>
586
+ * <param name="handle">SDK handle.</param>
587
+ * <returns>Status code.</returns>
588
+ */
589
+ static inline evt_status_t evt_flushAndTeardown (evt_handle_t handle )
590
+ {
591
+ evt_context_t ctx ;
592
+ ctx .call = EVT_OP_FLUSHANDTEARDOWN ;
593
+ ctx .handle = handle ;
594
+ return evt_api_call (& ctx );
595
+ }
579
596
580
597
/** <summary>
581
598
* Save pending telemetry events to offline storage on disk.
Original file line number Diff line number Diff line change @@ -725,6 +725,7 @@ TEST(APITest, C_API_Test)
725
725
726
726
// Must remove event listener befor closing the handle!
727
727
client->logmanager ->RemoveEventListener (EVT_LOG_EVENT, debugListener);
728
+ evt_flushAndTeardown (handle);
728
729
evt_close (handle);
729
730
ASSERT_EQ (capi_get_client (handle), nullptr );
730
731
You can’t perform that action at this time.
0 commit comments