new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Temporal · all subjects

observability

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Configure Prometheus metrics endpoint in .NET SDK

Metrics in .NET are configured on the Metrics property of the Telemetry property on the TemporalRuntime. The TemporalRuntime object should be created globally and used for all clients, configured before any other Temporal code. To set a Prometheus endpoint, create a TemporalRuntime with Telemetry configured with Prometheus pointing to an address like "0.0.0.0:9000".

.NET SDK Prometheus endpoint example

```csharp using Temporalio.Client; using Temporalio.Runtime; var runtime = new TemporalRuntime(new() { Telemetry = new() { Metrics = new() { Prometheus = new("0.0.0.0:9000") } }, }); var client = await Temporalio.ConnectAsync(new("localhost:7233") { Runtime = runtime }); ``` This example exposes a Prometheus endpoint on port 9000.

Custom metric meter in .NET SDK using Temporalio.Extensions.DiagnosticSource

A custom metric meter can be set on the telemetry options to handle metrics programmatically. The Temporalio.Extensions.DiagnosticSource extension provides a CustomMetricMeter implementation that sends all metrics to a System.Diagnostics.Metrics.Meter instance.

.NET SDK custom metric meter example

```csharp using System.Diagnostics.Metrics; using Temporalio.Client; using Temporalio.Extensions.DiagnosticSource; using Temporalio.Runtime; // Create .NET meter using var meter = new Meter("My.Meter"); // Can create MeterListener or OTel meter provider here... // Create Temporal runtime with a custom metric meter for that meter var runtime = new TemporalRuntime(new() { Telemetry = new() { Metrics = new() { CustomMetricMeter = new CustomMetricMeter(meter) }, }, }); var client = await Temporalio.ConnectAsync(new("localhost:7233") { Runtime = runtime }); ``` This example shows how to use a custom metric meter with the DiagnosticSource extension.

Configure OpenTelemetry tracing in .NET SDK

To configure OpenTelemetry tracing in .NET, use the Temporalio.Extensions.OpenTelemetry extension. The TracingInterceptor class can be set as an interceptor in the client options or provided through a Plugin. When the Client is connected, spans are created for all Client calls, Activities, and Workflow invocations on the Worker. Spans are created and serialized through the server to give one trace for a Workflow Execution.

Logging configuration in .NET SDK client

The LoggerFactory can be set in the client using the standard .NET logging APIs. The Temporal SDK core normally uses WARN as its default logging level. Log levels supported include Information, Warning, Error, Critical, Debug, and Trace.

.NET SDK console logging example

```csharp var client = await TemporalClient.ConnectAsync(new("localhost:7233") { LoggerFactory = LoggerFactory.Create(builder => builder. AddSimpleConsole(options => options.TimestampFormat = "[HH:mm:ss] "). SetMinimumLevel(LogLevel.Information)), }); ``` This example shows logging on the console with the level set to Information.

Log from a Workflow in .NET SDK

You can log from a Workflow using Workflow.Logger which is an instance of .NET's ILogger.

.NET SDK Workflow logging example

```csharp Workflow.Logger.LogInformation("Given name: {Name}", name); ``` This example shows how to log information from a Workflow.

Give your agent this brain

observability — Temporal