當前位置: 首頁>>代碼示例>>C#>>正文


C# Extensibility.TelemetryConfiguration類代碼示例

本文整理匯總了C#中Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration的典型用法代碼示例。如果您正苦於以下問題:C# TelemetryConfiguration類的具體用法?C# TelemetryConfiguration怎麽用?C# TelemetryConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TelemetryConfiguration類屬於Microsoft.ApplicationInsights.Extensibility命名空間,在下文中一共展示了TelemetryConfiguration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Get

        public static TelemetryClient Get()
        {
            lock (_instanceLock)
            {
                if (_activeConfig == null)
                {
                    TelemetryConfiguration config = TelemetryConfiguration.Active;
                    config.InstrumentationKey = "1b3b7cd2-f058-4eb3-b153-a4425e95e20e";
#if DEBUG
                config.TelemetryChannel.DeveloperMode = true;
#endif
                    config.ContextInitializers.Add(new ComponentContextInitializer());
                    config.ContextInitializers.Add(new DeviceContextInitializer());
                    config.ContextInitializers.Add(new UserSessionInitializer());

                    _activeConfig = config;
                }

                if (_instance == null)
                {

                    var ret = new TelemetryClient(_activeConfig);
                    PopulateContext(ret);
                    _instance = ret;
                }

                return _instance;
            }
        }
開發者ID:XewTurquish,項目名稱:vsminecraft,代碼行數:29,代碼來源:Telemetry.cs

示例2: ProfilerHttpProcessing

        /// <summary>
        /// Initializes a new instance of the <see cref="ProfilerHttpProcessing"/> class.
        /// </summary>
        public ProfilerHttpProcessing(TelemetryConfiguration configuration, string agentVersion, ObjectInstanceBasedOperationHolder telemetryTupleHolder, bool setCorrelationHeaders, ICollection<string> correlationDomainExclusionList)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (telemetryTupleHolder == null)
            {
                throw new ArgumentNullException("telemetryTupleHolder");
            }

            if (correlationDomainExclusionList == null)
            {
                throw new ArgumentNullException("correlationDomainExclusionList");
            }

            this.applicationInsightsUrlFilter = new ApplicationInsightsUrlFilter(configuration);
            this.TelemetryTable = telemetryTupleHolder;
            this.telemetryClient = new TelemetryClient(configuration);
            this.correlationDomainExclusionList = correlationDomainExclusionList;
            this.setCorrelationHeaders = setCorrelationHeaders;

            // Since dependencySource is no longer set, sdk version is prepended with information which can identify whether RDD was collected by profiler/framework
            // For directly using TrackDependency(), version will be simply what is set by core
            string prefix = "rdd" + RddSource.Profiler + ":";
            this.telemetryClient.Context.GetInternalContext().SdkVersion = SdkVersionUtils.GetSdkVersion(prefix);
            if (!string.IsNullOrEmpty(agentVersion))
            {
                this.telemetryClient.Context.GetInternalContext().AgentVersion = agentVersion;
            }
        }
開發者ID:Microsoft,項目名稱:ApplicationInsights-dotnet-server,代碼行數:35,代碼來源:ProfilerHttpProcessing.cs

示例3: SnippetWillIncludeInstrumentationKeyAsSubstring

 public static void SnippetWillIncludeInstrumentationKeyAsSubstring()
 {
     string unittestkey = "unittestkey";
     var telemetryConfiguration = new TelemetryConfiguration { InstrumentationKey = unittestkey };
     var snippet = new JavaScriptSnippet(telemetryConfiguration);
     Assert.Contains("'" + unittestkey + "'", snippet.FullScript.ToString());
 }
開發者ID:jango2015,項目名稱:ApplicationInsights-aspnet5,代碼行數:7,代碼來源:ApplicationInsightsJavaScriptTest.cs

示例4: Initialize

        /// <summary>
        /// Initialize method is called after all configuration properties have been loaded from the configuration.
        /// </summary>
        public void Initialize(TelemetryConfiguration configuration)
        {
            // Temporary fix to make sure that we initialize module once.
            // It should be removed when configuration reading logic is moved to Web SDK.
            if (!this.isInitialized)
            {
                lock (this.lockObject)
                {
                    if (!this.isInitialized)
                    {
                        try
                        {                            
                            this.telemetryConfiguration = configuration;

                            // Net40 only supports runtime instrumentation
                            // Net45 supports either but not both to avoid duplication
                            this.InitializeForRuntimeInstrumentationOrFramework();
                        }
                        catch (Exception exc)
                        {
                            DependencyCollectorEventSource.Log.RemoteDependencyModuleError(exc.ToInvariantString(), Environment.Version.ToString());
                        }

                        this.isInitialized = true;
                    }
                }
            }
        }
開發者ID:gregjhogan,項目名稱:ApplicationInsights-server-dotnet,代碼行數:31,代碼來源:DependencyTrackingTelemetryModule.cs

示例5: TestHttpRequestsWithQueryStringAreCollected

        public void TestHttpRequestsWithQueryStringAreCollected()
        {
            ITelemetry sentTelemetry = null;
            var channel = new StubTelemetryChannel { OnSend = telemetry => sentTelemetry = telemetry };
            var config = new TelemetryConfiguration
            {
                InstrumentationKey = IKey,
                TelemetryChannel = channel
            };

            using (var module = new DependencyTrackingTelemetryModule())
            {
                module.Initialize(config);
                const string Url = "http://www.bing.com/search?q=1";
                new HttpWebRequestUtils().ExecuteAsyncHttpRequest(Url, HttpMethod.Get);

                while (sentTelemetry == null)
                {
                    Thread.Sleep(100);
                }

                Assert.IsNotNull(sentTelemetry, "Get requests are not monitored with RDD Event Source.");
                var item = (DependencyTelemetry)sentTelemetry;
                Assert.AreEqual(Url, item.Name, "Reported Url must be " + Url);
                Assert.IsTrue(item.Duration > TimeSpan.FromMilliseconds(0), "Duration has to be positive");
                Assert.AreEqual("Http", item.DependencyKind, "HttpAny has to be dependency kind as it includes http and azure calls");
                Assert.IsTrue(
                    DateTime.UtcNow.Subtract(item.Timestamp.UtcDateTime).TotalMilliseconds < TimeSpan.FromMinutes(1).TotalMilliseconds, "timestamp < now");
                Assert.IsTrue(
                    item.Timestamp.Subtract(DateTime.UtcNow).TotalMilliseconds > -TimeSpan.FromMinutes(1).TotalMilliseconds, "now - 1 min < timestamp");
            }
        }
開發者ID:gregjhogan,項目名稱:ApplicationInsights-server-dotnet,代碼行數:32,代碼來源:DependencyTrackingTelemetryModuleTest.cs

示例6: ProfilerSqlProcessing

        /// <summary>
        /// Initializes a new instance of the <see cref="ProfilerSqlProcessing"/> class.
        /// </summary>
        internal ProfilerSqlProcessing(TelemetryConfiguration configuration, string agentVersion, ObjectInstanceBasedOperationHolder telemetryTupleHolder)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (telemetryTupleHolder == null)
            {
                throw new ArgumentNullException("telemetryHolder");
            }

            this.TelemetryTable = telemetryTupleHolder;
            this.telemetryClient = new TelemetryClient(configuration);

            // Since dependencySource is no longer set, sdk version is prepended with information which can identify whether RDD was collected by profiler/framework

            // For directly using TrackDependency(), version will be simply what is set by core
            string prefix = "rdd" + RddSource.Profiler + ":";
            this.telemetryClient.Context.GetInternalContext().SdkVersion = SdkVersionUtils.GetSdkVersion(prefix);
            if (!string.IsNullOrEmpty(agentVersion))
            {
                this.telemetryClient.Context.GetInternalContext().AgentVersion = agentVersion;
            }
        }
開發者ID:Microsoft,項目名稱:ApplicationInsights-dotnet-server,代碼行數:28,代碼來源:ProfilerSqlProcessing.cs

示例7: CreateStubTelemetryConfiguration

 private TelemetryConfiguration CreateStubTelemetryConfiguration()
 {
     TelemetryConfiguration configuration = new TelemetryConfiguration();
     configuration.TelemetryChannel = new StubTelemetryChannel { EndpointAddress = "https://endpointaddress" };
     configuration.InstrumentationKey = Guid.NewGuid().ToString();
     return configuration;
 }
開發者ID:gregjhogan,項目名稱:ApplicationInsights-server-dotnet,代碼行數:7,代碼來源:ApplicationInsightsUrlFilterTests.cs

示例8: RequestTrackingMiddleware

 public RequestTrackingMiddleware(OwinMiddleware next, TelemetryConfiguration telemetryConfiguration) 
     : base(next)
 {
     _telemetryClient = telemetryConfiguration == null 
         ? new TelemetryClient()
         : new TelemetryClient(telemetryConfiguration);
 }
開發者ID:NuGet,項目名稱:NuGet.Services.Metadata,代碼行數:7,代碼來源:RequestTrackingMiddleware.cs

示例9: IsEnabledReturnsTrueIfTelemetryTrackingIsEnabledInConfiguration

        public void IsEnabledReturnsTrueIfTelemetryTrackingIsEnabledInConfiguration()
        {
            var configuration = new TelemetryConfiguration { DisableTelemetry = false };
            var client = new TelemetryClient(configuration);

            Assert.True(client.IsEnabled());
        }
開發者ID:ZeoAlliance,項目名稱:ApplicationInsights-dotnet,代碼行數:7,代碼來源:TelemetryClientTest.cs

示例10: WcfInterceptor

        public WcfInterceptor(TelemetryConfiguration configuration, ContractFilter filter)
        {
            if ( configuration == null )
                throw new ArgumentNullException("configuration");

            this.configuration = configuration;
            this.contractFilter = filter;
        }
開發者ID:xornand,項目名稱:ApplicationInsights-SDK-Labs,代碼行數:8,代碼來源:WcfInterceptor.cs

示例11: InitializingEmptyConfigurationAddsCoreSdkDefaultComponents

        public void InitializingEmptyConfigurationAddsCoreSdkDefaultComponents()
        {
            var configuration = new TelemetryConfiguration();
            TelemetryConfigurationFactory.Instance.Initialize(configuration);

            Assert.AreEqual(2, configuration.TelemetryInitializers.Count);
            Assert.IsInstanceOfType(configuration.TelemetryChannel, typeof(InMemoryChannel));
        }
開發者ID:iusafaro,項目名稱:ApplicationInsights-dotnet,代碼行數:8,代碼來源:TelemetryConfigurationFactoryTest.cs

示例12: Initialize

 /// <summary>
 /// Gives the opportunity for this telemetry module to initialize configuration object that is passed to it.
 /// </summary>
 /// <param name="configuration">Configuration object.</param>
 public void Initialize(TelemetryConfiguration configuration)
 {
     if (!configuration.TelemetryChannel.DeveloperMode.HasValue && IsDebuggerAttached())
     {
         // Note that when debugger is not attached we are preserving default null value
         configuration.TelemetryChannel.DeveloperMode = true;
     }
 }
開發者ID:gregjhogan,項目名稱:ApplicationInsights-server-dotnet,代碼行數:12,代碼來源:DeveloperModeWithDebuggerAttachedTelemetryModule.cs

示例13: TestInitialize

 public void TestInitialize()
 {
     this.configuration = new TelemetryConfiguration();
     this.sendItems = new List<ITelemetry>(); 
     this.configuration.TelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) };
     this.configuration.InstrumentationKey = Guid.NewGuid().ToString();
     this.httpProcessingFramework = new FrameworkHttpProcessing(this.configuration, new CacheBasedOperationHolder());
 }
開發者ID:gregjhogan,項目名稱:ApplicationInsights-server-dotnet,代碼行數:8,代碼來源:FrameworkHttpProcessingTest.cs

示例14: AddConfiguration

 public void AddConfiguration(string deploymentId, string hostName, string clientId, IPAddress address)
 {
     //throw new NotImplementedException();
     TelemetryConfiguration.Active.ContextInitializers.Add(new AppInInitializer(DeploymentId));
     var tc = new TelemetryConfiguration();
     Telemetry = new TelemetryClient();
     Telemetry.InstrumentationKey = InstrumentationKey;
     Initialized = true;
 }
開發者ID:kowalot,項目名稱:Pk.OrleansUtils,代碼行數:9,代碼來源:AppInStatisticsPublisher.cs

示例15: CopyConfiguration

        private static void CopyConfiguration(TelemetryConfiguration source, TelemetryConfiguration target)
        {
            target.InstrumentationKey = source.InstrumentationKey;

            foreach (var telemetryInitializer in source.TelemetryInitializers)
            {
                target.TelemetryInitializers.Add(telemetryInitializer);
            }
        }
開發者ID:Microsoft,項目名稱:ApplicationInsights-dotnet-server,代碼行數:9,代碼來源:UnhandledExceptionTelemetryModule.cs


注:本文中的Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。