• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ImmediatePlatform / Immediate.Jobs / 30300691995

27 Jul 2026 08:00PM UTC coverage: 64.845%. First build
30300691995

Pull #20

github

web-flow
Merge a73d5f4ed into e8a73c280
Pull Request #20: Initial draft

1300 of 1892 new or added lines in 29 files covered. (68.71%)

1649 of 2543 relevant lines covered (64.84%)

2.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.87
/src/Immediate.Jobs.Shared/JobTelemetry.cs
1
using System.Diagnostics;
2
using System.Diagnostics.Metrics;
3

4
namespace Immediate.Jobs.Shared;
5

6
/// <summary>OpenTelemetry-compatible instrumentation emitted by Immediate.Jobs.</summary>
7
public static class JobTelemetry
8
{
9
        /// <summary>The activity source used for enqueue and execution traces.</summary>
10
        public static readonly ActivitySource ActivitySource = new("Immediate.Jobs");
4✔
11

12
        /// <summary>The meter used for scheduler metrics.</summary>
13
        public static readonly Meter Meter = new("Immediate.Jobs");
4✔
14

15
        private static readonly Counter<long> EnqueuedCounter = Meter.CreateCounter<long>("jobs.enqueued");
4✔
16
        private static readonly Counter<long> SucceededCounter = Meter.CreateCounter<long>("jobs.succeeded");
4✔
17
        private static readonly Counter<long> FailedCounter = Meter.CreateCounter<long>("jobs.failed");
4✔
18
        private static readonly Counter<long> RetriedCounter = Meter.CreateCounter<long>("jobs.retried");
4✔
19
        private static readonly Histogram<double> DurationHistogram = Meter.CreateHistogram<double>("job.duration", "s");
4✔
20
        private static long QueueDepth;
21
        private static long ActiveWorkers;
22

23
        static JobTelemetry()
24
        {
NEW
25
                _ = Meter.CreateObservableGauge("queue.depth", () => Interlocked.Read(ref QueueDepth));
×
NEW
26
                _ = Meter.CreateObservableGauge("workers.active", () => Interlocked.Read(ref ActiveWorkers));
×
27
        }
4✔
28

29
        internal static void Enqueued(string jobName, string queueName)
30
        {
31
                TagList tags = default;
4✔
32
                tags.Add("job.name", jobName);
4✔
33
                tags.Add("job.queue", queueName);
4✔
34
                EnqueuedCounter.Add(1, tags);
4✔
35
                _ = Interlocked.Increment(ref QueueDepth);
4✔
36
        }
4✔
37

38
        internal static void Acquired() => _ = Interlocked.Decrement(ref QueueDepth);
4✔
39
        internal static void ExecutionStarted() => _ = Interlocked.Increment(ref ActiveWorkers);
4✔
40
        internal static void ExecutionFinished() => _ = Interlocked.Decrement(ref ActiveWorkers);
4✔
41
        internal static void Succeeded(string jobName, string queueName, TimeSpan duration)
42
        {
43
                TagList tags = default;
4✔
44
                tags.Add("job.name", jobName);
4✔
45
                tags.Add("job.queue", queueName);
4✔
46
                SucceededCounter.Add(1, tags);
4✔
47
                tags.Add("outcome", "succeeded");
4✔
48
                DurationHistogram.Record(duration.TotalSeconds, tags);
4✔
49
        }
4✔
50

51
        internal static void Failed(string jobName, string queueName, TimeSpan duration)
52
        {
53
                TagList tags = default;
4✔
54
                tags.Add("job.name", jobName);
4✔
55
                tags.Add("job.queue", queueName);
4✔
56
                FailedCounter.Add(1, tags);
4✔
57
                tags.Add("outcome", "failed");
4✔
58
                DurationHistogram.Record(duration.TotalSeconds, tags);
4✔
59
        }
4✔
60

61
        internal static void Retried(string jobName, string queueName)
62
        {
63
                TagList tags = default;
4✔
64
                tags.Add("job.name", jobName);
4✔
65
                tags.Add("job.queue", queueName);
4✔
66
                RetriedCounter.Add(1, tags);
4✔
67
                _ = Interlocked.Increment(ref QueueDepth);
4✔
68
        }
4✔
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc