File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 9595> [ !NOTE]
9696> Activities which are not yet finished/stopped will not be exported.
9797
98+ :stop_sign : You should avoid calling
99+ [ Activity.AddEvent] ( https://learn.microsoft.com/dotnet/api/system.diagnostics.activity.addevent )
100+ in a loop. Activities are not designed to handle hundreds or thousands of
101+ events, a better model is to use [ correlated
102+ logs] ( ../logs/README.md#log-correlation ) or
103+ [ Activity.Links] ( https://learn.microsoft.com/dotnet/api/system.diagnostics.activity.links ) .
104+
105+ > [ !WARNING]
106+ > The following code is not modeling ` Activity.Events ` correctly, and is very
107+ likely to have usability and performance problems.
108+
109+ ``` csharp
110+ private static async Task Test ()
111+ {
112+ Activity activity = Activity .Current ;
113+
114+ while (true )
115+ {
116+ activity .AddEvent (new ActivityEvent (" Processing background task." ));
117+ await Task .Delay (1000 );
118+ }
119+ }
120+ ```
121+
98122## TracerProvider Management
99123
100124:stop_sign : You should avoid creating ` TracerProvider ` instances too frequently,
You can’t perform that action at this time.
0 commit comments