Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions src/Microsoft.Tye.Extensions/Zipkin/ZipkinExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,48 @@ public override Task ProcessAsync(ExtensionContext context, ExtensionConfigurati
};
context.Application.Services.Add(service);

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

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

if (context.Operation == ExtensionContext.OperationKind.LocalRun)
switch (context.Operation)
{
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);
case 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";
}

// Use service discovery to find zipkin
sidecar.Args.Add("--provider:zipkin=service:zipkin");
sidecar.Dependencies.Add("zipkin");
}
break;
}
case 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");
}

break;
}
default:
throw new ArgumentOutOfRangeException();
}

return Task.CompletedTask;
Expand Down