METHOD
Activity.AddEvent
Adds a timestamped event to an activity. Use bounded event counts and allowlisted names and attributes. It does not itself send a log or export a trace.
Formal Syntax & Structure
csharp syntaxcsharp
activity.AddEvent(new ActivityEvent("validated"))Working Example
Example Snippetcsharp
using System;using System.Linq;using System.Diagnostics;using System.Diagnostics.Metrics;using var a = new Activity("demo").Start(); a.AddEvent(new ActivityEvent("validated")); Console.WriteLine(a.Events.Count()); // 1