This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c07702a
commit 2661ae2
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Imagine.Students.Api.Models; | ||
using Prometheus; | ||
|
||
namespace Imagine.Students.Api.Services | ||
{ | ||
public class TrackedStudentsStore : IStudentsStore | ||
{ | ||
private const string MetricName = "student_api_operation_duration_seconds"; | ||
|
||
private const string MetricDescrption = "student_api_operation_duration_seconds"; | ||
|
||
private static readonly HistogramConfiguration Config = new HistogramConfiguration | ||
{ | ||
StaticLabels = new() | ||
{ | ||
{ "class", nameof(TrackedStudentsStore) }, | ||
{ "method", nameof(GetStudents) } | ||
} | ||
}; | ||
|
||
private static readonly Histogram Histogram = Metrics.CreateHistogram(MetricName, MetricDescrption, Config); | ||
|
||
private readonly IStudentsStore _store; | ||
|
||
public TrackedStudentsStore(IStudentsStore store) | ||
{ | ||
_store = store; | ||
} | ||
|
||
public async Task<IEnumerable<Student>> GetStudents(Guid classroomId) | ||
{ | ||
using (Histogram.NewTimer()) | ||
{ | ||
return await _store.GetStudents(classroomId); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters