Esempio n. 1
0
        private void EnableProvider(EtwListeningRequest request)
        {
            string errorMessage;

            if (!request.Validate(out errorMessage))
            {
                EventSourceListenerEventSource.Log.FailedToEnableProviders(
                    nameof(EtwTelemetryModule),
                    string.IsNullOrEmpty(request.ProviderName) ? request.ProviderGuid.ToString() : request.ProviderName,
                    errorMessage);
            }

            try
            {
                if (request.ProviderGuid != Guid.Empty)
                {
                    this.EnableProvider(request.ProviderGuid, request.Level, request.Keywords);
                }
                else
                {
                    this.EnableProvider(request.ProviderName, request.Level, request.Keywords);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                EventSourceListenerEventSource.Log.AccessDenied(nameof(EtwTelemetryModule), ex.Message);
            }
            catch (Exception ex)
            {
                EventSourceListenerEventSource.Log.FailedToEnableProviders(
                    nameof(EtwTelemetryModule),
                    string.IsNullOrEmpty(request.ProviderName) ? request.ProviderGuid.ToString() : request.ProviderName,
                    ex.Message);
            }
        }
Esempio n. 2
0
        private void EnableProviders()
        {
            // Enable TPL provider to get hierarchical activity IDs
            var tplProviderRequest = new EtwListeningRequest()
            {
                ProviderGuid = TplActivities.TplEventSourceGuid,
                Level        = TraceEventLevel.Always,
                Keywords     = TplActivities.TaskFlowActivityIdsKeyword
            };

            this.EnableProvider(tplProviderRequest);

            foreach (EtwListeningRequest request in this.Sources)
            {
                this.EnableProvider(request);
            }
        }