Example #1
0
        public override Task ProcessAsync(ExtensionContext context, ExtensionConfiguration config)
        {
            if (context.Application.Services.Any(s => s.Name == "zipkin"))
            {
                context.Output.WriteDebugLine("zipkin service already configured. Skipping...");
            }
            else
            {
                context.Output.WriteDebugLine("Injecting zipkin service...");
                var service = new ContainerServiceBuilder("zipkin", "openzipkin/zipkin")
                {
                    Bindings =
                    {
                        new BindingBuilder()
                        {
                            Port          = 9411,
                            ContainerPort = 9411,
                            Protocol      = "http",
                        },
                    },
                };
                context.Application.Services.Add(service);

                foreach (var s in context.Application.Services)
                {
                    if (object.ReferenceEquals(s, service))
                    {
                        continue;
                    }

                    // make zipkin available as a dependency of everything.
                    if (!s.Dependencies.Contains(service.Name))
                    {
                        s.Dependencies.Add(service.Name);
                    }
                }
            }

            if (context.Operation == ExtensionContext.OperationKind.LocalRun)
            {
                if (context.Options !.DistributedTraceProvider is null)
                {
                    // For local development we hardcode the port and hostname
                    context.Options.DistributedTraceProvider = "zipkin=http://localhost:9411";
                }
            }
            else if (context.Operation == ExtensionContext.OperationKind.Deploy)
            {
                foreach (var project in context.Application.Services.OfType <DotnetProjectServiceBuilder>())
                {
                    var sidecar = DiagnosticAgent.GetOrAddSidecar(project);

                    // Use service discovery to find zipkin
                    sidecar.Args.Add("--provider:zipkin=service:zipkin");
                    sidecar.Dependencies.Add("zipkin");
                }
            }

            return(Task.CompletedTask);
        }
Example #2
0
        public override Task ProcessAsync(ExtensionContext context, ExtensionConfiguration config)
        {
            if (context.Application.Services.Any(s => s.Name == "elastic"))
            {
                context.Output.WriteDebugLine("elastic service already configured. Skipping...");
            }
            else
            {
                context.Output.WriteDebugLine("Injecting elastic service...");

                // We're using an "all-in-one" docker image for local dev that makes that
                // easy to set up.
                //
                // See: https://elk-docker.readthedocs.io/
                var elastic = new ContainerServiceBuilder("elastic", "sebp/elk")
                {
                    Bindings =
                    {
                        new BindingBuilder()
                        {
                            Name          = "kibana",
                            Port          = 5601,
                            ContainerPort = 5601,
                            Protocol      = "http",
                        },
                        new BindingBuilder()
                        {
                            Port          = 9200,
                            ContainerPort = 9200,
                            Protocol      = "http",
                        },
                    },
                };
                context.Application.Services.Add(elastic);

                if (config.Data.TryGetValue("logPath", out var obj) &&
                    obj is string logPath &&
                    !string.IsNullOrEmpty(logPath))
                {
                    // https://elk-docker.readthedocs.io/#persisting-log-data
                    elastic.Volumes.Add(new VolumeBuilder(logPath, "elk-data", "/var/lib/elasticsearch"));
                }

                foreach (var s in context.Application.Services)
                {
                    if (object.ReferenceEquals(s, elastic))
                    {
                        continue;
                    }

                    // make elastic available as a dependency of everything.
                    if (!s.Dependencies.Contains(elastic.Name))
                    {
                        s.Dependencies.Add(elastic.Name);
                    }
                }
            }

            if (context.Operation == ExtensionContext.OperationKind.LocalRun)
            {
                if (context.Options !.LoggingProvider is null)
                {
                    // For local development we hardcode the port and hostname
                    context.Options.LoggingProvider = "elastic=http://localhost:9200";
                }
            }
            else if (context.Operation == ExtensionContext.OperationKind.Deploy)
            {
                // For deployments, remove the kibana binding. We don't need to talk to it,
                // so don't make the user specify it.
                var elastic = context.Application.Services.Single(s => s.Name == "elastic");
                var kibana  = elastic.Bindings.Single(b => b.Name == "kibana");
                elastic.Bindings.Remove(kibana);

                foreach (var project in context.Application.Services.OfType <DotnetProjectServiceBuilder>())
                {
                    var sidecar = DiagnosticAgent.GetOrAddSidecar(project);

                    // Use service discovery to find elastic
                    sidecar.Args.Add("--provider:elastic=service:elastic");
                    sidecar.Dependencies.Add("elastic");
                }
            }

            return(Task.CompletedTask);
        }
Example #3
0
        public override Task ProcessAsync(ExtensionContext context, ExtensionConfiguration config)
        {
            if (context.Application.Services.Any(s => s.Name == "seq"))
            {
                context.Output.WriteDebugLine("seq service already configured. Skipping...");
            }
            else
            {
                context.Output.WriteDebugLine("Injecting seq service...");

                var seq = new ContainerServiceBuilder("seq", "datalust/seq")
                {
                    EnvironmentVariables =
                    {
                        new EnvironmentVariableBuilder("ACCEPT_EULA")
                        {
                            Value = "Y"
                        },
                    },
                    Bindings =
                    {
                        new BindingBuilder()
                        {
                            Port          = 5341,
                            ContainerPort = 80,
                            Protocol      = "http",
                        },
                    },
                };
                context.Application.Services.Add(seq);

                if (config.Data.TryGetValue("logPath", out var obj) &&
                    obj is string logPath &&
                    !string.IsNullOrEmpty(logPath))
                {
                    seq.Volumes.Add(new VolumeBuilder(logPath, "seq-data", "/data"));
                }

                foreach (var s in context.Application.Services)
                {
                    if (object.ReferenceEquals(s, seq))
                    {
                        continue;
                    }

                    // make seq available as a dependency of everything.
                    if (!s.Dependencies.Contains(seq.Name))
                    {
                        s.Dependencies.Add(seq.Name);
                    }
                }
            }

            if (context.Operation == ExtensionContext.OperationKind.LocalRun)
            {
                if (context.Options !.LoggingProvider is null)
                {
                    // For local development we hardcode the port and hostname
                    context.Options.LoggingProvider = "seq=http://localhost:5341";
                }
            }
            else if (context.Operation == ExtensionContext.OperationKind.Deploy)
            {
                foreach (var project in context.Application.Services.OfType <DotnetProjectServiceBuilder>())
                {
                    var sidecar = DiagnosticAgent.GetOrAddSidecar(project);

                    // Use service discovery to find seq
                    sidecar.Args.Add("--provider:seq=service:seq");
                    sidecar.Dependencies.Add("seq");
                }
            }

            return(Task.CompletedTask);
        }