Recording events
Spans describe operations that have a duration and a result, but sometimes, creating a span could be too verbose and expensive – for example, for busy socket-level communication. Common use cases for events include recording exceptions or individual messages in gRPC streaming calls.
To represent something that happened at a certain point in time, we should use events or logs. In OpenTelemetry, the difference between logs and events is semantical – it’s the same data structure with the same over-the-wire format but different attributes. For example, logs have mandatory severity, which does not apply to events. Events, on the other hand, have mandatory names.
They are also different in terms of their API and implementation (at least with .NET 7.0 and prior versions). In this section, we will explore Activity’s events API; we will look at logs in Chapter 8, Writing Structured and Correlated Logs.
When to use events
To create an...