private static string GetOutOfProcessStoragePath(
            this TracingConfiguration configuration)
        {
            // note: Considering to have one global path for out-of-process
            // attachments so that just the out-of-process collector is
            // uploading attachments instead of every application is uploading
            // its own attachments.

            return(configuration.GetInProcessStoragePath());
        }
        /// <summary>
        /// Gets the path for storing attachments temporarily.
        /// </summary>
        /// <param name="configuration">A configuration instance.</param>
        /// <returns>A temp path for attachments.</returns>
        public static string GetAttachmentsStoragePath(
            this TracingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return((configuration.Debug || configuration.InProcess)
                ? configuration.GetInProcessStoragePath()
                : configuration.GetOutOfProcessStoragePath());
        }
        private static string GetInProcessStoragePath(
            this TracingConfiguration configuration,
            string directoryName)
        {
            var path = Path.Combine(configuration.ApplicationRootPath, directoryName);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return(path);
        }
        private static string GetStoragePath(
            this TracingConfiguration configuration,
            string directoryName)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return((configuration.Debug || configuration.InProcess)
                ? configuration.GetInProcessStoragePath(directoryName)
                : configuration.GetOutOfProcessStoragePath(directoryName));
        }
        private static string GetInProcessStoragePath(
            this TracingConfiguration configuration)
        {
            string path = Path.Combine(configuration.ApplicationRootPath,
                                       "Attachments");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return(path);
        }
示例#6
0
        /// <summary>
        /// Adds tracing core services to the service collection.
        /// </summary>
        /// <param name="services">
        /// A <see cref="IServiceCollection"/> instance.
        /// </param>
        /// <param name="configuration">
        /// A <see cref="IConfiguration"/> instance.
        /// </param>
        /// <returns>
        /// The provided <see cref="IServiceCollection"/> instance.
        /// </returns>
        public static IServiceCollection AddTracingCore(
            this IServiceCollection services, IConfiguration configuration)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            TracingConfiguration tracingConfiguration = configuration
                                                        .GetSection("Tracing")
                                                        .Get <TracingConfiguration>();

            return(services
                   .AddSingleton <IProvidersDescriptor, CoreProvidersDescriptor>()
                   .AddSingleton(tracingConfiguration));
        }
 /// <summary>
 /// Gets the path for storing attachments temporarily.
 /// </summary>
 /// <param name="configuration">A configuration instance.</param>
 /// <returns>A temp path for attachments.</returns>
 public static string GetEventsStoragePath(
     this TracingConfiguration configuration)
 {
     return(configuration.GetStoragePath("Events"));
 }