internal bool IsApplicationInsightsUrl(Uri uri) { if (SdkInternalOperationsMonitor.IsEntered()) { return(true); } bool result = false; string url = uri?.ToString(); if (!string.IsNullOrEmpty(url)) { result = url.StartsWith(TelemetryServiceEndpoint, StringComparison.OrdinalIgnoreCase) || url.StartsWith(QuickPulseServiceEndpoint, StringComparison.OrdinalIgnoreCase); if (!result) { string endpointUrl = EndpointLeftPart; if (!string.IsNullOrEmpty(endpointUrl)) { result = url.StartsWith(endpointUrl, StringComparison.OrdinalIgnoreCase); } } } return(result); }
private void TrackStatistics(string type, string operation, string method, bool wasTracked) { var dimensions = new Dictionary <string, string>(); dimensions.Add("type", this.GetDimCappedString(type, this.typeValues)); dimensions.Add("method", this.GetDimCappedString(method, this.methodValues)); if (SdkInternalOperationsMonitor.IsEntered()) { dimensions.Add("operation", "AI (Internal)"); } else if (!string.IsNullOrEmpty(operation)) { dimensions.Add("operation", this.GetDimCappedString(operation, this.operationValues)); } var metric = this.metricManager.CreateMetric("Exceptions Thrown", dimensions); if (wasTracked) { metric.Track(0); } else { metric.Track(1); } }
/// <summary> /// Determines whether an URL is application insights URL. /// </summary> /// <param name="url">HTTP URL.</param> /// <returns>True if URL is application insights url, otherwise false.</returns> internal bool IsApplicationInsightsUrl(string url) { // first check that it's not active internal SDK operation if (SdkInternalOperationsMonitor.IsEntered()) { return(true); } return(this.IsApplicationInsightsUrlImpl(url)); }
public override IEnumerable <ITelemetry> Dequeue() { Assert.IsTrue(SdkInternalOperationsMonitor.IsEntered()); HttpClient client = new HttpClient(); var task = client.GetStringAsync("http://bing.com").ContinueWith((result) => { Assert.IsTrue(SdkInternalOperationsMonitor.IsEntered()); }); task.Wait(); WasCalled = true; return(base.Dequeue()); }
private void TrackStatistics(bool getOperationName, string problemId, Exception exception) { ExceptionTelemetry exceptionTelemetry = null; var dimensions = new Dictionary <string, string>(); string operationName = null; string refinedOperationName = null; string refinedProblemId = null; if (this.DimCapTimeout < DateTime.UtcNow.Ticks) { this.ResetDimCapCaches(this.operationNameValues, this.problemIdValues, this.exceptionKeyValues); } refinedProblemId = this.GetDimCappedString(problemId, this.problemIdValues, ProblemIdCacheSize); if (string.IsNullOrEmpty(refinedProblemId) == true) { refinedProblemId = "MaxProblemIdValues"; } dimensions.Add("problemId", refinedProblemId); if (SdkInternalOperationsMonitor.IsEntered()) { refinedOperationName = "AI (Internal)"; dimensions.Add(OperationNameTag, refinedOperationName); } else { if (getOperationName == true) { exceptionTelemetry = new ExceptionTelemetry(exception); this.telemetryClient.Initialize(exceptionTelemetry); operationName = exceptionTelemetry.Context.Operation.Name; } if (string.IsNullOrEmpty(operationName) == false) { refinedOperationName = this.GetDimCappedString(operationName, this.operationNameValues, OperationNameCacheSize); dimensions.Add(OperationNameTag, refinedOperationName); } } this.SendException(refinedOperationName, refinedProblemId, exceptionTelemetry, exception); var metric = this.MetricManager.CreateMetric("Exceptions thrown", dimensions); metric.Track(1); }
public void InitializeIsMarkesAsInternalSdkOperation() { bool isInternalOperation = false; StubConfigurableWithStaticCallback.OnInitialize = (item) => { isInternalOperation = SdkInternalOperationsMonitor.IsEntered(); }; Assert.Equal(false, SdkInternalOperationsMonitor.IsEntered()); string configFileContents = Configuration( @"<TelemetryModules> <Add Type = """ + typeof(StubConfigurableWithStaticCallback).AssemblyQualifiedName + @""" /> </TelemetryModules>" ); var modules = new TestableTelemetryModules(); new TestableTelemetryConfigurationFactory().Initialize(new TelemetryConfiguration(), modules, configFileContents); Assert.Equal(true, isInternalOperation); Assert.Equal(false, SdkInternalOperationsMonitor.IsEntered()); }
public override Task <HttpWebResponseWrapper> SendAsync() { Assert.IsTrue(SdkInternalOperationsMonitor.IsEntered()); this.WasCalled(true); return(base.SendAsync()); }