Table of Contents

Class DistributedTracer

Namespace
DotCompute.Core.Telemetry
Assembly
DotCompute.Core.dll

Production-grade distributed tracing system for cross-device operations and performance bottleneck identification. Provides OpenTelemetry-compatible tracing with correlation ID propagation and performance analysis.

public sealed class DistributedTracer : IDisposable
Inheritance
DistributedTracer
Implements
Inherited Members
Extension Methods

Constructors

DistributedTracer(ILogger<DistributedTracer>, IOptions<DistributedTracingOptions>)

Initializes a new instance of the DistributedTracer class.

public DistributedTracer(ILogger<DistributedTracer> logger, IOptions<DistributedTracingOptions> options)

Parameters

logger ILogger<DistributedTracer>

The logger.

options IOptions<DistributedTracingOptions>

The options.

Methods

AnalyzeTraceAsync(TraceData)

Analyzes a completed trace to identify performance bottlenecks and optimization opportunities.

public Task<TraceAnalysis> AnalyzeTraceAsync(TraceData traceData)

Parameters

traceData TraceData

The completed trace data to analyze

Returns

Task<TraceAnalysis>

Detailed trace analysis results

Dispose()

Performs dispose.

public void Dispose()

ExportTracesAsync(TraceExportFormat, IEnumerable<string>?, CancellationToken)

Exports trace data to external monitoring systems.

public Task ExportTracesAsync(TraceExportFormat format, IEnumerable<string>? correlationIds = null, CancellationToken cancellationToken = default)

Parameters

format TraceExportFormat

Export format (OpenTelemetry, Jaeger, Zipkin)

correlationIds IEnumerable<string>

Specific traces to export, or null for all recent traces

cancellationToken CancellationToken

Cancellation token

Returns

Task

FinishSpan(SpanContext, SpanStatus, string?)

Finishes a span and records its completion metrics.

public void FinishSpan(SpanContext spanContext, SpanStatus status = SpanStatus.Ok, string? statusMessage = null)

Parameters

spanContext SpanContext

The span context to finish

status SpanStatus

Final status of the operation

statusMessage string

Optional status message

FinishTraceAsync(string, TraceStatus)

Finishes a distributed trace and prepares it for export.

public Task<TraceData?> FinishTraceAsync(string correlationId, TraceStatus status = TraceStatus.Ok)

Parameters

correlationId string

Correlation ID of the trace to finish

status TraceStatus

Final status of the entire operation

Returns

Task<TraceData>

Completed trace data for analysis

RecordEvent(SpanContext, string, Dictionary<string, object?>)

Records a performance event within a span with detailed metrics.

public void RecordEvent(SpanContext spanContext, string eventName, Dictionary<string, object?> attributes)

Parameters

spanContext SpanContext

The span context to record the event in

eventName string

Name of the event

attributes Dictionary<string, object>

Event attributes including performance metrics

RecordKernelExecution(SpanContext, string, TimeSpan, long, KernelPerformanceData)

Records kernel execution metrics within a span for performance analysis.

public void RecordKernelExecution(SpanContext spanContext, string kernelName, TimeSpan executionTime, long memoryUsage, KernelPerformanceData performanceMetrics)

Parameters

spanContext SpanContext

The span context for the kernel execution

kernelName string

Name of the executed kernel

executionTime TimeSpan

Kernel execution duration

memoryUsage long

Memory usage during execution

performanceMetrics KernelPerformanceData

Detailed performance metrics

StartSpan(string, string, string, SpanKind, Dictionary<string, object?>?)

Starts a new span within an existing trace for device-specific operations.

public SpanContext? StartSpan(string correlationId, string spanName, string deviceId, SpanKind spanKind = SpanKind.Internal, Dictionary<string, object?>? attributes = null)

Parameters

correlationId string

Correlation ID of the parent trace

spanName string

Name of the span

deviceId string

ID of the device executing the operation

spanKind SpanKind

Type of span (client, server, internal, etc.)

attributes Dictionary<string, object>

Additional attributes for the span

Returns

SpanContext

Span context for the operation

StartTrace(string, string?, SpanContext?, Dictionary<string, object?>?)

Starts a new distributed trace for a cross-device operation.

public TraceContext StartTrace(string operationName, string? correlationId = null, SpanContext? parentSpanContext = null, Dictionary<string, object?>? tags = null)

Parameters

operationName string

Name of the operation being traced

correlationId string

Unique correlation ID for request tracing

parentSpanContext SpanContext

Parent span context for nested operations

tags Dictionary<string, object>

Additional tags for the trace

Returns

TraceContext

Trace context for the operation