namespace IronTelemetry.Client;
///
/// Telemetry level for messages.
///
public enum TelemetryLevel
{
Debug,
Info,
Warning,
Error,
Fatal
}
///
/// Breadcrumb level.
///
public enum BreadcrumbLevel
{
Debug,
Info,
Warning,
Error
}
///
/// A breadcrumb represents an event that happened before an error.
///
public class Breadcrumb
{
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string Category { get; set; } = "default";
public string Message { get; set; } = string.Empty;
public BreadcrumbLevel Level { get; set; } = BreadcrumbLevel.Info;
public Dictionary? Data { get; set; }
}
///
/// Additional context for exception capture.
///
public class ExceptionContext
{
public string? UserId { get; set; }
public string? UserEmail { get; set; }
public string? TraceId { get; set; }
public string? SpanId { get; set; }
public Dictionary Extras { get; set; } = new();
public ExceptionContext WithUser(string? id, string? email = null)
{
UserId = id;
UserEmail = email;
return this;
}
public ExceptionContext WithTrace(string traceId, string? spanId = null)
{
TraceId = traceId;
SpanId = spanId;
return this;
}
public ExceptionContext WithExtra(string key, object value)
{
Extras[key] = value;
return this;
}
}