Round #862

11 May 2026, 09:49· csharp· Meta-Llama-3.3-70B-Instruct· r15-firing-v3
Complexity
band 0
ZP / UO / OBS
3 / 6 / 1
Journey weight
605
Lightshift ΔL
+0.00

Prompt

Add OpenTelemetry tracing to an existing service. Show creating an ActivitySource, starting a child Activity around a database call, and tagging it with the query name.

Zero-point index (what the engine surfaced)

ZPI-ZPI-0019 | 2026-05-11T09:49:54Z Add OpenTelemetry tracing to an existing service. Show creating an ActivitySource, starting a child Activity around a database call, and tagging it with the query name. ZERO POINT — 3 entries (structural invariants) ● hsl(257.53, 100%, 32%) ActivitySource [contract] ● hsl(329.94, 100%, 32%) Meter [contract] ● hsl(22.09, 100%, 32%) TracerProvider [contract] UNOBSERVED — 6 entries (implied truths) ○ hsl(348.72, 100%, 36%) IDisposable [feature] ○ hsl(27.69, 100%, 50%) async [feature] ○ hsl(9.23, 100%, 50%) interface [feature] ○ hsl(180.92, 100%, 28%) Database health check [function] ○ hsl(144.00, 100%, 42%) Connection resilience [function] ○ hsl(83.08, 100%, 42%) ILogger of T injection [function] OBSERVED — 1 entries (explicit in request) ◉ hsl(98.46, 100%, 50%) with [feature] COMPLEXITY │ 10 entries │ spread: 339° │ band: LOW

Baseline response (no ZPI)

**Adding OpenTelemetry Tracing to an Existing Service** ====================================================== In this example, we will demonstrate how to add OpenTelemetry tracing to an existing service. We will create an `ActivitySource`, start a child `Activity` around a database call, and tag it with the query name. **Prerequisites** --------------- * .NET 6 or later * OpenTelemetry NuGet packages: + `OpenTelemetry` + `OpenTelemetry.Api` + `OpenTelemetry.Sdk` **Code Example** --------------- ```csharp using OpenTelemetry; using OpenTelemetry.Api; using OpenTelemetry.Sdk; using System; using System.Data.SqlClient; public class DatabaseService { private readonly ActivitySource _activitySource; public DatabaseService() { _activitySource = new ActivitySource("DatabaseService"); } public void ExecuteQuery(string queryName, string query) { // Start a child Activity around the database call using var activity = _activitySource.StartActivity("ExecuteQuery", ActivityKind.Client); // Tag the Activity with the query name activity?.SetTag("query.name", queryName); try { // Simulate a database call using var connection = new SqlConnection("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"); connection.Open(); using var command = new SqlCommand(query, connection); command.ExecuteNonQuery(); } catch (Exception ex) { // Set the Activity status to failed if an exception occurs activity?.SetStatus(Status.Error.WithDescription(ex.Message)); throw; } } } class Program { static void Main(string[] args) { var databaseService = new DatabaseService(); databaseService.ExecuteQuery("GetUsers", "SELECT * FROM Users"); } } ``` **Explanation** -------------- 1. We create an `ActivitySource` instance with the name "DatabaseService". 2. In the `ExecuteQuery` method, we start a child `Activity` using the `StartActivity` method of the `ActivitySource`. We pass the name "ExecuteQuery" and `ActivityKind.Client` as arguments. 3. We tag the `Activity` with the query name using the `SetTag` method. 4. We simulate a database call using ADO.NET. 5. If an exception occurs during the database call, we set the `Activity` status to failed using the `SetStatus` method. **Configuring OpenTelemetry** --------------------------- To configure OpenTelemetry, you need to add the following NuGet packages to your project: * `OpenTelemetry` * `OpenTelemetry.Api` * `OpenTelemetry.Sdk` You also need to configure the OpenTelemetry pipeline. This can be done in the `Program.cs` file: ```csharp using OpenTelemetry; using OpenTelemetry.Sdk; class Program { static void Main(string[] args) { // Configure the OpenTelemetry pipeline using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("DatabaseService") .Build(); // Use the tracer provider var databaseService = new DatabaseService(); databaseService.ExecuteQuery("GetUsers", "SELECT * FROM Users"); } } ``` Note that this is a basic example, and you may need to configure additional components, such as exporters, to send the tracing data to a backend system.

Enhanced response (with ZPI)

```csharp using OpenTelemetry; using OpenTelemetry.Trace; using Microsoft.Extensions.Logging; public class MyService { private readonly ActivitySource _activitySource; private readonly ILogger<MyService> _logger; public MyService(ActivitySource activitySource, ILogger<MyService> logger) { _activitySource = activitySource; _logger = logger; } public void PerformDatabaseCall(string queryName) { using var activity = _activitySource.StartActivity("DatabaseCall", ActivityKind.Client); activity?.SetTag("query.name", queryName); try { // Simulate a database call _logger.LogInformation("Executing query: {QueryName}", queryName); // Database call code here } catch (Exception ex) { _logger.LogError(ex, "Error executing query: {QueryName}", queryName); activity?.SetStatus(ActivityStatusCode.Error); } } } public class Program { public static void Main() { using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("MyService") .Build(); var activitySource = new ActivitySource("MyService"); var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); var logger = loggerFactory.CreateLogger<MyService>(); var myService = new MyService(activitySource, logger); myService.PerformDatabaseCall("SELECT * FROM users"); } } ``` This implementation creates an `ActivitySource` named "MyService" and uses it to start a child activity around a database call. The activity is tagged with the query name. The `PerformDatabaseCall` method simulates a database call and logs information and error messages using the `ILogger` instance. The activity status is set to error if an exception occurs during the database call. The `Main` method demonstrates how to create a `TracerProvider` and register the `ActivitySource` with it.

Grader chain

Each grader reads the same baseline + enhanced pair and casts an independent verdict. Disagreement is the framework's own signal — not noise to be averaged away.

V1samba/Meta-Llama-3.3-70B-Instruct
Better
V4qwen2.5-coder-3b-instruct
Better
V5cerebras/qwen-3-235b-a22b-instruct-2507
Better
V7qwen2.5-coder-7b-instruct
Better
V8openai/gpt-4.1
Better
V9anthropic/claude-opus-4-7
Worse
V12openai/gpt-4o
Better

Comments

Our grader said what it said. What do you say? Comment as a guest below.

No comments yet. Be the first to say what you make of this round.

← back to all rounds