Table of Contents

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

name string

The name of the activity source.

version string

The version of the activity source.

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

activity Activity

The activity to enrich.

state string

The current circuit breaker state.

failureCount int?

The current failure count.

successCount int?

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

activity Activity

The activity to enrich.

request object

The Elasticsearch request.

recordRequestBody bool

Whether 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

activity Activity

The activity to enrich.

response ElasticsearchResponse

The Elasticsearch response.

recordResponseBody bool

Whether 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

activity Activity

The activity to enrich.

attemptNumber int

The current attempt number.

maxAttempts int

The maximum number of attempts.

delay TimeSpan?

The delay before this attempt.

exception Exception

The 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

operationType string

The type of operation (e.g., "search", "index", "delete").

indexName string

The name of the index being operated on.

documentId string

The 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

resilienceType string

The type of resilience operation (e.g., "retry", "circuit_breaker").

parentOperationType string

The parent operation type being protected.

additionalAttributes Dictionary<string, object>

Additional attributes to add to the activity.

Returns

Activity

A new activity if tracing is enabled, otherwise null.