-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSessionTelemetry.cs
More file actions
40 lines (32 loc) · 1.41 KB
/
SessionTelemetry.cs
File metadata and controls
40 lines (32 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// -----------------------------------------------------------------------
// <copyright file="SessionTelemetry.cs" company="Petabridge, LLC">
// Copyright (C) 2026 - 2026 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------
using System.Diagnostics.Metrics;
namespace Netclaw.Channels.Telemetry;
/// <summary>
/// OpenTelemetry counter instrumentation for session-level metrics.
/// Pushes deltas into OTel <see cref="Counter{T}"/> instruments only —
/// accumulation and snapshots are owned by the DailyStatsActor.
/// </summary>
public static class SessionTelemetry
{
public const string MeterName = "Netclaw.Sessions";
private static readonly Meter Meter = new(MeterName);
private static readonly Counter<long> InputTokensConsumed =
Meter.CreateCounter<long>("netclaw.session.tokens.input");
private static readonly Counter<long> OutputTokensConsumed =
Meter.CreateCounter<long>("netclaw.session.tokens.output");
private static readonly Counter<long> TurnsCompleted =
Meter.CreateCounter<long>("netclaw.session.turns.completed");
public static void RecordUsage(long inputTokens, long outputTokens)
{
InputTokensConsumed.Add(inputTokens);
OutputTokensConsumed.Add(outputTokens);
}
public static void RecordTurnCompleted()
{
TurnsCompleted.Add(1);
}
}