Class ElasticsearchActivitySource
- Namespace
- Excalibur.Data.ElasticSearch.Monitoring
- Assembly
- Excalibur.Data.ElasticSearch.dll
Provides distributed tracing capabilities for Elasticsearch operations following OpenTelemetry semantic conventions.
public sealed class ElasticsearchActivitySource : IDisposable
- Inheritance
-
ElasticsearchActivitySource
- Implements
- Inherited Members
Remarks
Initializes a new instance of the ElasticsearchActivitySource class.
Constructors
ElasticsearchActivitySource(string, string?)
Provides distributed tracing capabilities for Elasticsearch operations following OpenTelemetry semantic conventions.
public ElasticsearchActivitySource(string name = "Excalibur.Data.ElasticSearch", string? version = null)
Parameters
Remarks
Initializes a new instance of the ElasticsearchActivitySource class.
Properties
Source
Gets the underlying ActivitySource instance.
public ActivitySource Source { get; }
Property Value
- ActivitySource
The underlying ActivitySource instance.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
EnrichWithCircuitBreakerDetails(Activity?, string, int?, int?)
Enriches an activity with circuit breaker details.
public static void EnrichWithCircuitBreakerDetails(Activity? activity, string state, int? failureCount = null, int? successCount = null)
Parameters
activityActivityThe activity to enrich.
statestringThe current circuit breaker state.
failureCountint?The current failure count.
successCountint?The current success count.
EnrichWithRequestDetails(Activity?, object, bool)
Enriches an activity with request details.
[RequiresUnreferencedCode("Reflection and JSON serialization may require unreferenced types for dynamic type inspection and serialization")]
[RequiresDynamicCode("Reflection and JSON serialization use dynamic code to inspect types and serialize objects")]
public static void EnrichWithRequestDetails(Activity? activity, object request, bool recordRequestBody = false)
Parameters
activityActivityThe activity to enrich.
requestobjectThe Elasticsearch request.
recordRequestBodyboolWhether to record the request body.
EnrichWithResponseDetails(Activity?, ElasticsearchResponse, bool)
Enriches an activity with response details.
[RequiresUnreferencedCode("Reflection and JSON serialization may require unreferenced types for dynamic type inspection and serialization")]
[RequiresDynamicCode("Reflection and JSON serialization use dynamic code to inspect types and serialize objects")]
public static void EnrichWithResponseDetails(Activity? activity, ElasticsearchResponse response, bool recordResponseBody = false)
Parameters
activityActivityThe activity to enrich.
responseElasticsearchResponseThe Elasticsearch response.
recordResponseBodyboolWhether to record the response body.
EnrichWithRetryDetails(Activity?, int, int, TimeSpan?, Exception?)
Enriches an activity with retry attempt details.
public static void EnrichWithRetryDetails(Activity? activity, int attemptNumber, int maxAttempts, TimeSpan? delay = null, Exception? exception = null)
Parameters
activityActivityThe activity to enrich.
attemptNumberintThe current attempt number.
maxAttemptsintThe maximum number of attempts.
delayTimeSpan?The delay before this attempt.
exceptionExceptionThe exception that triggered the retry.
StartOperation(string, string?, string?)
Starts a new activity for an Elasticsearch operation.
public Activity? StartOperation(string operationType, string? indexName = null, string? documentId = null)
Parameters
operationTypestringThe type of operation (e.g., "search", "index", "delete").
indexNamestringThe name of the index being operated on.
documentIdstringThe document ID for single-document operations.
Returns
- Activity
A new activity if tracing is enabled, otherwise null.
StartResilienceOperation(string, string?, Dictionary<string, object>?)
Starts a new activity for a resilience operation (retry, circuit breaker).
public Activity? StartResilienceOperation(string resilienceType, string? parentOperationType = null, Dictionary<string, object>? additionalAttributes = null)
Parameters
resilienceTypestringThe type of resilience operation (e.g., "retry", "circuit_breaker").
parentOperationTypestringThe parent operation type being protected.
additionalAttributesDictionary<string, object>Additional attributes to add to the activity.
Returns
- Activity
A new activity if tracing is enabled, otherwise null.