Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation.QuickPulse.QuickPulseServiceClient.Ping C# (CSharp) Method

Ping() public method

public Ping ( string instrumentationKey, DateTimeOffset timestamp ) : bool?
instrumentationKey string
timestamp DateTimeOffset
return bool?
        public bool? Ping(string instrumentationKey, DateTimeOffset timestamp)
        {
            var path = string.Format(CultureInfo.InvariantCulture, "ping?ikey={0}", Uri.EscapeUriString(instrumentationKey));
            HttpWebResponse response = this.SendRequest(WebRequestMethods.Http.Post, path, stream => this.WritePingData(timestamp, stream));

            if (response == null)
            {
                return null;
            }

            return ProcessResponse(response);
        }

Usage Example

        public void QuickPulseServiceClientDoesNotRetryPing()
        {
            // ARRANGE
            var serviceClient = new QuickPulseServiceClient(
                this.serviceEndpoint,
                string.Empty,
                string.Empty,
                new Clock(),
                TimeSpan.FromMilliseconds(50));

            this.emulateTimeout = true;

            // ACT
            serviceClient.Ping(string.Empty, DateTimeOffset.UtcNow);

            // ASSERT
            this.listener.Stop();

            Assert.AreEqual(1, this.pingCount);
        }
All Usage Examples Of Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation.QuickPulse.QuickPulseServiceClient::Ping