You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instrument events when they are enqueued in the buffered producer (Azure#38273)
* Instrument events when they are enqueued in the buffered producer
* Fix tests
* Fix tests
* Set W3C format on net462
* updated wrong test
* PR fb
* Fix spacing
Copy file name to clipboardExpand all lines: sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@
8
8
9
9
### Bugs Fixed
10
10
11
+
- When using the `EventHubBufferedProducerClient`, events are now instrumented when `EnqueueEventAsync` or `EnqueueEventsAsync` is called, rather than when the event is published. This ensures that the instrumentation is accurate when the event is published, regardless of whether the event is published immediately or buffered for a period of time.
// Stop the activity before flushing so that we verify that the events are instrumented at time of enqueueing
244
+
activity.Stop();
245
+
246
+
awaitbufferedProducer.FlushAsync();
247
+
Assert.That(writtenEventsData.Count,Is.EqualTo(2),"All events should have been instrumented.");
248
+
249
+
foreach(EventDataeventDatainwrittenEventsData)
250
+
{
251
+
Assert.That(eventData.Properties.TryGetValue(MessagingClientDiagnostics.DiagnosticIdAttribute,outobjectvalue),Is.True,"The events should have a diagnostic identifier property.");
Assert.That(context.TraceId,Is.EqualTo(activity.TraceId),"The trace identifier should match the activity in the active scope when the events were enqueued.");
254
+
}
255
+
}
256
+
257
+
/// <summary>
258
+
/// Verifies diagnostics functionality of the <see cref="EventHubBufferedProducerClient" />
// Stop the activity before flushing so that we verify that the events are instrumented at time of enqueueing
307
+
activity.Stop();
308
+
309
+
awaitbufferedProducer.FlushAsync();
310
+
Assert.That(writtenEventsData.Count,Is.EqualTo(1),"All events should have been instrumented.");
311
+
312
+
foreach(EventDataeventDatainwrittenEventsData)
313
+
{
314
+
Assert.That(eventData.Properties.TryGetValue(MessagingClientDiagnostics.DiagnosticIdAttribute,outobjectvalue),Is.True,"The events should have a diagnostic identifier property.");
Assert.That(context.TraceId,Is.EqualTo(activity.TraceId),"The trace identifier should match the activity in the active scope when the events were enqueued.");
317
+
}
318
+
}
319
+
190
320
/// <summary>
191
321
/// Verifies diagnostics functionality of the <see cref="EventHubProducerClient" />
0 commit comments