Class Observe
Inherited Members
Namespace: LaunchDarkly.Observability
Assembly: LaunchDarkly.Observability.dll
Syntax
public static class Observe
Methods
| Edit this page View SourceRecordCount(string, long, IDictionary<string, object>)
Record a counter value.
Records a count value for a counter metric with the specified name and optional attributes. Counter values should be monotonically increasing.
Declaration
public static void RecordCount(string name, long value, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the counter |
long | value | the value to add to the counter |
IDictionary<string, object> | attributes | any additional attributes to add to the counter |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | thrown when name is null |
RecordException(Exception, IDictionary<string, object>)
Record an error in the active activity.
If there is not an active activity, then a new activity will be started and the error will be recorded into the activity.
Declaration
public static void RecordException(Exception exception, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | the exception to record |
IDictionary<string, object> | attributes | any additional attributes to add to the exception event |
RecordHistogram(string, double, IDictionary<string, object>)
Record a histogram value.
Records a measurement value for a histogram metric with the specified name and optional attributes. Histograms are used to record distributions of values.
Declaration
public static void RecordHistogram(string name, double value, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the histogram |
double | value | the value to record |
IDictionary<string, object> | attributes | any additional attributes to add to the histogram |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | thrown when name is null |
RecordIncr(string, IDictionary<string, object>)
Increment a counter by 1.
This is a convenience method equivalent to calling RecordCount with a value of 1.
Declaration
public static void RecordIncr(string name, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the counter |
IDictionary<string, object> | attributes | any additional attributes to add to the counter |
RecordLog(string, LogLevel, IDictionary<string, object>)
Record a log message.
Records a log message with the specified level and optional attributes using the configured logger. If no logger is configured, the log message will be ignored.
Declaration
public static void RecordLog(string message, LogLevel level, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | message | the log message |
LogLevel | level | the log level |
IDictionary<string, object> | attributes | any additional attributes to add to the log entry |
RecordMetric(string, double, IDictionary<string, object>)
Record a metric gauge value.
Records a measurement value for a gauge metric with the specified name and optional attributes.
Declaration
public static void RecordMetric(string name, double value, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the metric |
double | value | the value to record |
IDictionary<string, object> | attributes | any additional attributes to add to the metric |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | thrown when name is null |
RecordUpDownCounter(string, long, IDictionary<string, object>)
Record an up-down counter value.
Records a delta value for an up-down counter metric with the specified name and optional attributes. Up-down counters can increase or decrease and are useful for tracking values like queue size.
Declaration
public static void RecordUpDownCounter(string name, long delta, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the up-down counter |
long | delta | the delta value to add (can be positive or negative) |
IDictionary<string, object> | attributes | any additional attributes to add to the counter |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | thrown when name is null |
StartActivity(string, ActivityKind, IDictionary<string, object>)
Start a new activity (span) with the specified name and kind.
Creates and starts a new activity using the configured ActivitySource. The activity should be disposed when the operation is complete to properly end the span.
Declaration
public static Activity StartActivity(string name, ActivityKind kind = ActivityKind.Internal, IDictionary<string, object> attributes = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the activity |
ActivityKind | kind | the kind of activity (defaults to Internal) |
IDictionary<string, object> | attributes | any initial attributes to add to the activity |
Returns
Type | Description |
---|---|
Activity | the started activity, or null if the observability system is not initialized |