当前位置: 首页>>代码示例>>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;未经允许,请勿转载。