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
loggerILogger<DistributedTracer>The logger.
optionsIOptions<DistributedTracingOptions>The options.
Methods
AnalyzeTraceAsync(TraceData)
Analyzes a completed trace to identify performance bottlenecks and optimization opportunities.
public Task<TraceAnalysis> AnalyzeTraceAsync(TraceData traceData)
Parameters
traceDataTraceDataThe 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
formatTraceExportFormatExport format (OpenTelemetry, Jaeger, Zipkin)
correlationIdsIEnumerable<string>Specific traces to export, or null for all recent traces
cancellationTokenCancellationTokenCancellation token
Returns
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
spanContextSpanContextThe span context to finish
statusSpanStatusFinal status of the operation
statusMessagestringOptional 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
correlationIdstringCorrelation ID of the trace to finish
statusTraceStatusFinal status of the entire operation
Returns
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
spanContextSpanContextThe span context to record the event in
eventNamestringName of the event
attributesDictionary<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
spanContextSpanContextThe span context for the kernel execution
kernelNamestringName of the executed kernel
executionTimeTimeSpanKernel execution duration
memoryUsagelongMemory usage during execution
performanceMetricsKernelPerformanceDataDetailed 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
correlationIdstringCorrelation ID of the parent trace
spanNamestringName of the span
deviceIdstringID of the device executing the operation
spanKindSpanKindType of span (client, server, internal, etc.)
attributesDictionary<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
operationNamestringName of the operation being traced
correlationIdstringUnique correlation ID for request tracing
parentSpanContextSpanContextParent span context for nested operations
tagsDictionary<string, object>Additional tags for the trace
Returns
- TraceContext
Trace context for the operation