Class WorkflowForgeOpenTelemetryService
- Assembly
- WorkflowForge.Extensions.Observability.OpenTelemetry.dll
Comprehensive OpenTelemetry service providing both distributed tracing and metrics for WorkflowForge applications using industry-standard OpenTelemetry APIs.
public sealed class WorkflowForgeOpenTelemetryService : IDisposable
- Inheritance
-
WorkflowForgeOpenTelemetryService
- Implements
- Inherited Members
Constructors
WorkflowForgeOpenTelemetryService(string, string, IWorkflowForgeLogger?)
Initializes a new instance of the WorkflowForgeOpenTelemetryService.
public WorkflowForgeOpenTelemetryService(string serviceName, string serviceVersion = "1.0.0", IWorkflowForgeLogger? logger = null)
Parameters
serviceNamestringThe service name for OpenTelemetry identification.
serviceVersionstringThe service version.
loggerIWorkflowForgeLoggerThe logger instance.
WorkflowForgeOpenTelemetryService(WorkflowForgeOpenTelemetryOptions, IWorkflowForgeLogger?)
Initializes a new instance of the WorkflowForgeOpenTelemetryService from options.
public WorkflowForgeOpenTelemetryService(WorkflowForgeOpenTelemetryOptions options, IWorkflowForgeLogger? logger = null)
Parameters
optionsWorkflowForgeOpenTelemetryOptionsThe telemetry options.
loggerIWorkflowForgeLoggerThe logger instance.
Exceptions
- ArgumentNullException
Thrown when options or its service name is null.
Properties
ActivitySource
Gets the ActivitySource for creating spans and traces.
public ActivitySource ActivitySource { get; }
Property Value
Meter
Gets the Meter for creating metrics instruments.
public Meter Meter { get; }
Property Value
Options
Gets the options this service was created with.
public WorkflowForgeOpenTelemetryOptions Options { get; }
Property Value
ServiceName
Gets the service name used for OpenTelemetry resource identification.
public string ServiceName { get; }
Property Value
SystemMetricsRegistered
Gets whether system metric gauges were registered for this service.
public bool SystemMetricsRegistered { get; }
Property Value
Methods
CreateCounter<T>(string, string?, string?)
Creates a custom counter metric.
public Counter<T> CreateCounter<T>(string name, string? unit = null, string? description = null) where T : struct
Parameters
namestringThe counter name.
unitstringThe unit of measurement.
descriptionstringThe counter description.
Returns
- Counter<T>
The counter instrument.
Type Parameters
TThe counter value type.
CreateHistogram<T>(string, string?, string?)
Creates a custom histogram metric.
public Histogram<T> CreateHistogram<T>(string name, string? unit = null, string? description = null) where T : struct
Parameters
namestringThe histogram name.
unitstringThe unit of measurement.
descriptionstringThe histogram description.
Returns
- Histogram<T>
The histogram instrument.
Type Parameters
TThe histogram value type.
CreateObservableGauge<T>(string, Func<T>, string?, string?)
Creates a custom observable gauge metric.
public ObservableGauge<T> CreateObservableGauge<T>(string name, Func<T> observeValue, string? unit = null, string? description = null) where T : struct
Parameters
namestringThe gauge name.
observeValueFunc<T>The function to observe the value.
unitstringThe unit of measurement.
descriptionstringThe gauge description.
Returns
- ObservableGauge<T>
The observable gauge instrument.
Type Parameters
TThe gauge value type.
CreateUpDownCounter<T>(string, string?, string?)
Creates a custom up-down counter metric.
public UpDownCounter<T> CreateUpDownCounter<T>(string name, string? unit = null, string? description = null) where T : struct
Parameters
namestringThe counter name.
unitstringThe unit of measurement.
descriptionstringThe counter description.
Returns
- UpDownCounter<T>
The up-down counter instrument.
Type Parameters
TThe counter value type.
DecrementActiveOperations(string, KeyValuePair<string, object?>[]?)
Decrements the active operations counter.
public void DecrementActiveOperations(string operationName, KeyValuePair<string, object?>[]? tags = null)
Parameters
operationNamestringThe name of the operation.
tagsKeyValuePair<string, object>[]Additional tags for the metric.
Dispose()
Disposes the OpenTelemetry service and releases resources.
public void Dispose()
IncrementActiveOperations(string, KeyValuePair<string, object?>[]?)
Increments the active operations counter.
public void IncrementActiveOperations(string operationName, KeyValuePair<string, object?>[]? tags = null)
Parameters
operationNamestringThe name of the operation.
tagsKeyValuePair<string, object>[]Additional tags for the metric.
RecordOperation(string, TimeSpan, bool, long, KeyValuePair<string, object?>[]?)
Records metrics for an operation execution.
public void RecordOperation(string operationName, TimeSpan duration, bool success, long memoryAllocated = 0, KeyValuePair<string, object?>[]? tags = null)
Parameters
operationNamestringThe name of the operation.
durationTimeSpanThe operation duration.
successboolWhether the operation was successful.
memoryAllocatedlongMemory allocated during the operation.
tagsKeyValuePair<string, object>[]Additional tags for the metrics.
StartActivity(string, ActivityKind)
Starts a new activity (span) for distributed tracing.
public Activity? StartActivity(string operationName, ActivityKind kind = ActivityKind.Internal)
Parameters
operationNamestringThe name of the operation.
kindActivityKindThe activity kind.
Returns
- Activity
The started activity or null if not sampled.