Esempio n. 1
0
        private static void DumpDiagnostics(HostOptions options, Microsoft.Extensions.Logging.ILogger logger)
        {
            var providerText = new List <string>();

            providerText.AddRange(
                new[] { options.DistributedTraceProvider, options.LoggingProvider, options.MetricsProvider }
                .Where(p => p is object)
                .Cast <string>());

            foreach (var text in providerText)
            {
                if (DiagnosticsProvider.TryParse(text, out var provider))
                {
                    if (DiagnosticsProvider.WellKnownProviders.TryGetValue(provider.Key, out var wellKnown))
                    {
                        logger.LogInformation(wellKnown.LogFormat, provider.Value);
                    }
                    else
                    {
                        logger.LogWarning("Unknown diagnostics provider {Key}:{Value}", provider.Key, provider.Value);
                    }
                }
                else
                {
                    logger.LogError("Could not parse provider argument: {Arg}", text);
                }
            }
        }
Esempio n. 2
0
        private static AggregateApplicationProcessor CreateApplicationProcessor(ReplicaRegistry replicaRegistry, HostOptions options, Microsoft.Extensions.Logging.ILogger logger)
        {
            var diagnosticsCollector = new DiagnosticsCollector(logger)
            {
                // Local run always uses metrics for the dashboard
                MetricSink = new MetricSink(logger),
            };

            if (options.LoggingProvider != null &&
                DiagnosticsProvider.TryParse(options.LoggingProvider, out var logging))
            {
                diagnosticsCollector.LoggingSink = new LoggingSink(logger, logging);
            }

            if (options.DistributedTraceProvider != null &&
                DiagnosticsProvider.TryParse(options.DistributedTraceProvider, out var tracing))
            {
                diagnosticsCollector.TracingSink = new TracingSink(logger, tracing);
            }

            // Print out what providers were selected and their values
            DumpDiagnostics(options, logger);

            var processors = new List <IApplicationProcessor>
            {
                new EventPipeDiagnosticsRunner(logger, diagnosticsCollector),
                new PortAssigner(logger),
                new ProxyService(logger),
                new HttpProxyService(logger),
                new DockerImagePuller(logger),
                new FuncFinder(logger),
                new ReplicaMonitor(logger),
                new DockerRunner(logger, replicaRegistry),
                new ProcessRunner(logger, replicaRegistry, ProcessRunnerOptions.FromHostOptions(options))
            };

            // If the docker command is specified then transform the ProjectRunInfo into DockerRunInfo
            if (options.Docker)
            {
                processors.Insert(0, new TransformProjectsIntoContainers(logger));
            }

            return(new AggregateApplicationProcessor(processors));
        }