コード例 #1
0
 public void Timer_method()
 {
     _dogStatsdService.Time(() => Thread.Sleep(100), "timer");
     // Make sure that the received timer is of the right order of magnitude.
     // The measured value will probably be a few ms longer than the sleep value.
     AssertWasReceivedMatches(@"timer:\d{3}\|ms");
 }
コード例 #2
0
        public async Task <T> StartTimerAsync <T>(Func <Task <T> > func, string metricName, string[] tags)
        {
            if (dogStatsdService == null)
            {
                return(await func.Invoke());
            }

            T result = default(T);

            try
            {
                result = await dogStatsdService.Time(func, metricName, 1, tags : TelemetryConfig.CoreTags.Concat(tags).ToArray());
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error sending telemetry to Datadog {ex.Message}");
            }
            return(result);
        }