Replies: 1 comment 3 replies
-
If it's just timings you're after, you could easily cache these and do something like: MyTiming timing = new MyTiming("some-task");
// Do some maintenance stuff
timing.Finish();
app.Run();
...
SentrySdk.Metrics.Timing(
timing.Key,
timing.Stopwatch.Elapsed.TotalMilliseconds,
MeasurementUnit.Duration.Millisecond,
tags: timing.Tags,
timestamp: timing.StartTime
);
public class MyTiming
{
public string Key { get; }
public readonly DateTime StartTime;
public readonly Stopwatch Stopwatch = new();
public IDictionary<string, string>? Tags;
public MyTiming(string key, params KeyValuePair<string, string>[] tags)
{
Key = key;
Tags = tags.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
StartTime = DateTime.UtcNow;
Stopwatch.Start();
}
public void Finish()
{
Stopwatch.Stop();
}
} By passing in a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Well we currently have a service framework implemented which allows us to run maintenance procedures before the service goes live (hosting is started with
app.Run(Async)
and accepts requests.We want to trace these procedures as they can be quite long-running to measure how much time they usually take and if timing gets worse over time (likely due to more data in the system) or better (due to performance improvements).
Problem: Sentry seems to start with the
app.Run
call when the Host actually starts and seemingly allSentrySdk.Metrics.*
calls are lost that happen before that.Is there either a way to start Sentry earlier or is there some kind of caching feature that can track these events and send them once Sentry is up and running?
It would be a bummer if that wasn't possible. Moving the maintenance routines after hosting started would be bad as they are required before any requests are accepted.
Thanks for the help :)
Beta Was this translation helpful? Give feedback.
All reactions