Content-Length: 249454 | pFad | http://github.com/dotnet/tye/commit/3c7befca6c07802e31fc470c3d1b2fee354cf587

F9 Refactore zipkin extension (#816) · dotnet/tye@3c7befc · GitHub
Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
Refactore zipkin extension (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirh3e authored Dec 1, 2020
1 parent 7a9e5c8 commit 3c7befc
Showing 1 changed file with 29 additions and 20 deletions.
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

0 comments on commit 3c7befc

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dotnet/tye/commit/3c7befca6c07802e31fc470c3d1b2fee354cf587

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy