Ejemplo n.º 1
0
        private static void Initialize()
        {
            lock (clientsSyncRoot)
            {
                if (aggregationSets == null)
                {
                    AggregateMetricsEventSource.Log.ModuleInitializationBegin();

                    sdkVersion = SdkVersionUtils.VersionPrefix + SdkVersionUtils.GetAssemblyVersion();

                    aggregationSets = new ConcurrentDictionary <int, AggregationSet>();

                    if (AggregateMetricsTelemetryModule.IsTimerFlushEnabled)
                    {
                        TimeSpan aggregationWindow = AggregateMetricsTelemetryModule.FlushInterval;

                        AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

                        aggregationTimer = new System.Threading.Timer(new System.Threading.TimerCallback(TimerFlushCallback), null, aggregationWindow, aggregationWindow);
                    }

                    AggregateMetricsEventSource.Log.ModuleInitializationEnd();
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <see cref="ApplicationInsightsLogger"/>
 /// </summary>
 public ApplicationInsightsLogger(string name, TelemetryClient telemetryClient, Func <string, LogLevel, bool> filter)
 {
     this.categoryName    = name;
     this.telemetryClient = telemetryClient;
     this.filter          = filter;
     this.sdkVersion      = SdkVersionUtils.VersionPrefix + SdkVersionUtils.GetAssemblyVersion();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance using the specified telemetry client
 /// </summary>
 /// <param name="client">The TelemetryClient instance to use to emit telemetry events</param>
 public ClientTelemetryEndpointBehavior(TelemetryClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     this.telemetryClient = client;
     this.telemetryClient.Context.GetInternalContext().SdkVersion = "wcf: " + SdkVersionUtils.GetAssemblyVersion();
 }
        private void InitializeServiceClient(TelemetryConfiguration configuration)
        {
            if (this.serviceClient != null)
            {
                // service client has been passed through a constructor, we don't need to do anything
                return;
            }

            Uri serviceEndpointUri;

            if (string.IsNullOrWhiteSpace(this.QuickPulseServiceEndpoint))
            {
                // endpoint is not specified in configuration, use the default one
                serviceEndpointUri = QuickPulseDefaults.ServiceEndpoint;
            }
            else
            {
                // endpoint appears to have been specified in configuration, try using it
                try
                {
                    serviceEndpointUri = new Uri(this.QuickPulseServiceEndpoint);
                }
                catch (Exception e)
                {
                    throw new ArgumentException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Error initializing QuickPulse module. QPS endpoint is not a correct URI: '{0}'",
                                  this.QuickPulseServiceEndpoint),
                              e);
                }
            }

            // create the default production implementation of the service client with the best service endpoint we could get
            string instanceName    = GetInstanceName(configuration);
            var    assemblyVersion = SdkVersionUtils.GetAssemblyVersion();

            this.serviceClient = new QuickPulseServiceClient(serviceEndpointUri, instanceName, assemblyVersion, this.timeProvider);

            QuickPulseEventSource.Log.TroubleshootingMessageEvent(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "Service client initialized. Endpoint: '{0}', instance name: '{1}', assembly version: '{2}'",
                    serviceEndpointUri,
                    instanceName,
                    assemblyVersion));
        }
Ejemplo n.º 5
0
        private TelemetryClient GetTelemetryClient(TelemetryConfiguration sourceConfiguration)
        {
            this.channel.EndpointAddress = sourceConfiguration.TelemetryChannel.EndpointAddress;

            var newConfiguration = new TelemetryConfiguration
            {
                TelemetryChannel = this.channel
            };

            CopyConfiguration(sourceConfiguration, newConfiguration);

            var telemetryClient = new TelemetryClient(newConfiguration);

            telemetryClient.Context.GetInternalContext().SdkVersion = "unhnd: " + SdkVersionUtils.GetAssemblyVersion();

            return(telemetryClient);
        }
        /// <summary>
        /// Initialized telemetry module - starts the timer.
        /// </summary>
        /// <param name="configuration">Telemetry configuration to aggregate counters from.</param>
        public void Initialize(TelemetryConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            AggregateMetricsEventSource.Log.ModuleInitializationBegin();

            var sdkVersion = SdkVersionUtils.VersionPrefix + SdkVersionUtils.GetAssemblyVersion();

            this.configuration   = configuration;
            this.telemetryClient = new TelemetryClient(this.configuration);
            this.telemetryClient.Context.GetInternalContext().SdkVersion = sdkVersion;

            aggregationThread = new Thread(new ThreadStart(WorkerThread))
            {
                IsBackground = true
            };
            aggregationThread.Start();

            AggregateMetricsEventSource.Log.ModuleInitializationEnd();
        }
Ejemplo n.º 7
0
 void ITelemetryModule.Initialize(TelemetryConfiguration configuration)
 {
     this.telemetryClient = new TelemetryClient(configuration);
     this.telemetryClient.Context.GetInternalContext().SdkVersion = "wcf: " + SdkVersionUtils.GetAssemblyVersion();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:HostingDiagnosticListener"/> class.
 /// </summary>
 /// <param name="client"><see cref="TelemetryClient"/> to post traces to.</param>
 public HostingDiagnosticListener(TelemetryClient client)
 {
     this.client     = client;
     this.sdkVersion = SdkVersionUtils.VersionPrefix + SdkVersionUtils.GetAssemblyVersion();
 }
        /// <summary>
        /// Initializes the telemetry module.
        /// </summary>
        /// <param name="configuration">Telemetry Configuration used for creating TelemetryClient for sending exceptions to ApplicationInsights.</param>
        public void Initialize(TelemetryConfiguration configuration)
        {
            // Core SDK creates 1 instance of a module but calls Initialize multiple times
            if (!this.isInitialized)
            {
                lock (this.lockObject)
                {
                    if (!this.isInitialized)
                    {
                        this.isInitialized = true;

                        this.telemetryClient = new TelemetryClient(configuration);
                        this.telemetryClient.Context.GetInternalContext().SdkVersion = "unobs: " + SdkVersionUtils.GetAssemblyVersion();

                        this.registerAction(this.TaskSchedulerOnUnobservedTaskException);
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:HostingDiagnosticListener"/> class.
 /// </summary>
 /// <param name="client"><see cref="TelemetryClient"/> to post traces to.</param>
 /// <param name="correlationIdLookupHelper">A store for correlation ids that we don't have to query it everytime.</param>
 public HostingDiagnosticListener(TelemetryClient client, ICorrelationIdLookupHelper correlationIdLookupHelper)
 {
     this.client = client;
     this.correlationIdLookupHelper = correlationIdLookupHelper;
     this.sdkVersion = SdkVersionUtils.VersionPrefix + SdkVersionUtils.GetAssemblyVersion();
 }
Ejemplo n.º 11
0
 internal static string GetAssemblyVersion()
 {
     return(SdkVersionUtils.GetAssemblyVersion());
 }