Table of Contents

Class BaseTelemetryProvider

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

Unified base telemetry provider that consolidates common telemetry patterns across all backend implementations (Metal, CUDA, OpenCL, CPU, LINQ). Eliminates over 2,500 lines of duplicate telemetry code.

public abstract class BaseTelemetryProvider : ITelemetryProvider, IDisposable
Inheritance
BaseTelemetryProvider
Implements
Derived
Inherited Members
Extension Methods

Constructors

BaseTelemetryProvider(ILogger, TelemetryConfiguration, string, string)

protected BaseTelemetryProvider(ILogger logger, TelemetryConfiguration configuration, string serviceName, string serviceVersion)

Parameters

logger ILogger
configuration TelemetryConfiguration
serviceName string
serviceVersion string

Fields

ActivitySource

protected readonly ActivitySource ActivitySource

Field Value

ActivitySource

Configuration

protected readonly TelemetryConfiguration Configuration

Field Value

TelemetryConfiguration

Logger

protected readonly ILogger Logger

Field Value

ILogger

Meter

protected readonly Meter Meter

Field Value

Meter

Methods

AddBackendSpecificActivityContext(Activity)

Adds backend-specific context to activities.

protected virtual void AddBackendSpecificActivityContext(Activity activity)

Parameters

activity Activity

CalculateOverheadPercentage()

Calculates telemetry overhead percentage.

protected virtual double CalculateOverheadPercentage()

Returns

double

CreateTagList(IDictionary<string, object?>)

Creates a TagList from a dictionary for metrics.

protected static TagList CreateTagList(IDictionary<string, object?> tags)

Parameters

tags IDictionary<string, object>

Returns

TagList

Dispose()

Disposes the telemetry provider and releases all resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

ExtractKernelCategory(string)

Extracts kernel category from name for classification.

protected static string ExtractKernelCategory(string kernelName)

Parameters

kernelName string

Returns

string

GetAcceleratorCategory(string)

Gets accelerator category from type.

protected static string GetAcceleratorCategory(string acceleratorType)

Parameters

acceleratorType string

Returns

string

GetBackendType()

Gets the backend type identifier (e.g., "CUDA", "Metal", "OpenCL", "CPU").

protected abstract string GetBackendType()

Returns

string

GetGCType(int)

Gets garbage collection type from generation.

protected static string GetGCType(int generation)

Parameters

generation int

Returns

string

GetMeter(string, string?)

Gets a specific meter for advanced scenarios.

public virtual Meter GetMeter(string name, string? version = null)

Parameters

name string
version string

Returns

Meter

GetPerformanceMetrics()

Gets comprehensive telemetry performance metrics.

public virtual TelemetryPerformanceMetrics GetPerformanceMetrics()

Returns

TelemetryPerformanceMetrics

GetTransferType(string)

Gets transfer type from direction.

protected static string GetTransferType(string direction)

Parameters

direction string

Returns

string

HandleTelemetryError(Exception, string, string)

Handles telemetry errors consistently across all operations.

protected virtual void HandleTelemetryError(Exception ex, string operation, string context)

Parameters

ex Exception
operation string
context string

IncrementCounter(string, long, IDictionary<string, object?>?)

Increments a counter with optimized performance and error handling.

public virtual void IncrementCounter(string name, long increment = 1, IDictionary<string, object?>? tags = null)

Parameters

name string
increment long
tags IDictionary<string, object>

InitializeStandardMetrics()

Initializes standard metrics used across all backends.

protected void InitializeStandardMetrics()

OnAcceleratorUtilizationRecorded(string, double, long, Dictionary<string, object?>)

Called when accelerator utilization is recorded - override for backend-specific tracking.

protected virtual void OnAcceleratorUtilizationRecorded(string acceleratorType, double utilization, long memoryUsed, Dictionary<string, object?> tags)

Parameters

acceleratorType string
utilization double
memoryUsed long
tags Dictionary<string, object>

OnGarbageCollectionRecorded(int, TimeSpan, long, long, Dictionary<string, object?>)

Called when garbage collection is recorded - override for backend-specific tracking.

protected virtual void OnGarbageCollectionRecorded(int generation, TimeSpan duration, long memoryBefore, long memoryAfter, Dictionary<string, object?> tags)

Parameters

generation int
duration TimeSpan
memoryBefore long
memoryAfter long
tags Dictionary<string, object>

OnKernelExecuted(string, TimeSpan, long, Dictionary<string, object?>)

Called when kernel execution is recorded - override for backend-specific tracking.

protected virtual void OnKernelExecuted(string kernelName, TimeSpan duration, long operationCount, Dictionary<string, object?> tags)

Parameters

kernelName string
duration TimeSpan
operationCount long
tags Dictionary<string, object>

OnMemoryAllocated(long, string?, Dictionary<string, object?>)

Called when memory is allocated - override for backend-specific tracking.

protected virtual void OnMemoryAllocated(long bytes, string? allocationType, Dictionary<string, object?> tags)

Parameters

bytes long
allocationType string
tags Dictionary<string, object>

OnMemoryTransferRecorded(string, long, TimeSpan, Dictionary<string, object?>)

Called when memory transfer is recorded - override for backend-specific tracking.

protected virtual void OnMemoryTransferRecorded(string direction, long bytes, TimeSpan duration, Dictionary<string, object?> tags)

Parameters

direction string
bytes long
duration TimeSpan
tags Dictionary<string, object>

ProcessEventSync(TelemetryEvent)

Processes an event synchronously.

protected virtual void ProcessEventSync(TelemetryEvent telemetryEvent)

Parameters

telemetryEvent TelemetryEvent

RecordAcceleratorUtilization(string, double, long)

Records accelerator utilization with backend-specific context.

public virtual void RecordAcceleratorUtilization(string acceleratorType, double utilization, long memoryUsed)

Parameters

acceleratorType string
utilization double
memoryUsed long

RecordEvent(string, IDictionary<string, object?>?)

Records an event with structured data and performance tracking.

public virtual void RecordEvent(string name, IDictionary<string, object?>? attributes = null)

Parameters

name string
attributes IDictionary<string, object>

RecordGarbageCollection(int, TimeSpan, long, long)

Records garbage collection metrics with generation analysis.

public virtual void RecordGarbageCollection(int generation, TimeSpan duration, long memoryBefore, long memoryAfter)

Parameters

generation int
duration TimeSpan
memoryBefore long
memoryAfter long

RecordHistogram(string, double, IDictionary<string, object?>?)

Records a histogram value with performance optimization.

public virtual void RecordHistogram(string name, double value, IDictionary<string, object?>? tags = null)

Parameters

name string
value double
tags IDictionary<string, object>

RecordKernelExecution(string, TimeSpan, long)

Records kernel execution with comprehensive performance tracking.

public virtual void RecordKernelExecution(string kernelName, TimeSpan duration, long operationCount)

Parameters

kernelName string
duration TimeSpan
operationCount long

RecordMemoryAllocation(long, string?)

Records memory allocation with unified tracking across all backends.

public virtual void RecordMemoryAllocation(long bytes, string? allocationType = null)

Parameters

bytes long
allocationType string

RecordMemoryTransfer(string, long, TimeSpan)

Records memory transfer with bandwidth analysis.

public virtual void RecordMemoryTransfer(string direction, long bytes, TimeSpan duration)

Parameters

direction string
bytes long
duration TimeSpan

RecordMetric(string, double, IDictionary<string, object?>?)

Records a metric value with comprehensive error handling and performance tracking.

public virtual void RecordMetric(string name, double value, IDictionary<string, object?>? tags = null)

Parameters

name string
value double
tags IDictionary<string, object>

StartActivity(string, ActivityKind)

Starts an activity with comprehensive context and error handling.

public virtual Activity? StartActivity(string name, ActivityKind kind = ActivityKind.Internal)

Parameters

name string
kind ActivityKind

Returns

Activity

StartTimer(string, IDictionary<string, object?>?)

Starts a performance timer with comprehensive tracking.

public virtual IOperationTimer StartTimer(string operationName, IDictionary<string, object?>? tags = null)

Parameters

operationName string
tags IDictionary<string, object>

Returns

IOperationTimer

UpdateTelemetryOverhead(long)

Updates telemetry overhead tracking.

protected void UpdateTelemetryOverhead(long startTicks)

Parameters

startTicks long