Chapter 6 – Tracing Your Code
- When setting up OpenTelemetry, you can enable
ActivitySource
by calling into theTracerProviderBuilder.AddSource
method and passing the source name. OpenTelemetry will then create anActivityListener
– a low-level .NET API that listens toActivitySource
instances. The listener samples activities using the callback provided by OpenTelemetry and notifies OpenTelemetry when activities start or end. - Activity (or span) events can be used to represent something that happens at a point in time or is too short to be a span and does not need individual context. At the same time, events must happen in the scope of some activity and are recorded along with it. Activity events stay in memory until the activity is garbage-collected and their number is limited on the exporter side.
Logs are usually a better alternative to Activity
events as they are not necessarily tied to specific activity, sampling, or exporter limitations. OpenTelemetry...