Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,12 @@ public static IResourceBuilder<OpenTelemetryCollectorResource> WithConfig(this I
/// <returns></returns>
private static IResourceBuilder<OpenTelemetryCollectorResource> WithFirstStartup(this IResourceBuilder<OpenTelemetryCollectorResource> builder)
{
builder.OnBeforeResourceStarted((resource, beforeStartedEvent, cancellationToken) =>
builder.OnBeforeResourceStarted((collectorResource, beforeStartedEvent, cancellationToken) =>
{
var logger = beforeStartedEvent.Services.GetRequiredService<ResourceLoggerService>().GetLogger(resource);
var logger = beforeStartedEvent.Services.GetRequiredService<ResourceLoggerService>().GetLogger(collectorResource);
var appModel = beforeStartedEvent.Services.GetRequiredService<DistributedApplicationModel>();
var resources = appModel.GetProjectResources();
var collectorResource = appModel.Resources.OfType<OpenTelemetryCollectorResource>().FirstOrDefault();

if (collectorResource is null)
{
logger.LogWarning("No collector resource found");
return Task.CompletedTask;
}
foreach (var resourceItem in resources.Where(r => r.HasAnnotationOfType<OtlpExporterAnnotation>()))
{
resourceItem.Annotations.Add(new WaitAnnotation(collectorResource, WaitType.WaitUntilHealthy));
Expand All @@ -140,18 +134,11 @@ private static IResourceBuilder<OpenTelemetryCollectorResource> WithFirstStartup
/// <param name="builder"></param>
private static IResourceBuilder<OpenTelemetryCollectorResource> AddEnvironmentVariablesEventHook(this IResourceBuilder<OpenTelemetryCollectorResource> builder)
{
builder.OnResourceEndpointsAllocated((resource, allocatedEvent, cancellationToken) =>
builder.OnResourceEndpointsAllocated((collectorResource, allocatedEvent, cancellationToken) =>
{
var logger = allocatedEvent.Services.GetRequiredService<ResourceLoggerService>().GetLogger(resource);
var logger = allocatedEvent.Services.GetRequiredService<ResourceLoggerService>().GetLogger(collectorResource);
var appModel = allocatedEvent.Services.GetRequiredService<DistributedApplicationModel>();
var resources = appModel.GetProjectResources();
var collectorResource = appModel.Resources.OfType<OpenTelemetryCollectorResource>().FirstOrDefault();

if (collectorResource is null)
{
logger.LogWarning("No collector resource found");
return Task.CompletedTask;
}

var grpcEndpoint = collectorResource.GetEndpoint(collectorResource.GrpcEndpoint.EndpointName);
var httpEndpoint = collectorResource.GetEndpoint(collectorResource.HttpEndpoint.EndpointName);
Expand Down
6 changes: 2 additions & 4 deletions src/Shared/DevCertHostingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static IResourceBuilder<TResource> RunWithHttpsDevCertificate<TResource>(
{
throw new InvalidOperationException("RunWithHttpsDevCertificate needs environment variables only for Resources that aren't Containers.");
}

// Create temp directory for certificate export
var tempDir = Directory.CreateTempSubdirectory("aspire-dev-certs");
var certExportPath = Path.Combine(tempDir.FullName, "dev-cert.pem");
Expand All @@ -58,7 +58,7 @@ public static IResourceBuilder<TResource> RunWithHttpsDevCertificate<TResource>(
var existingResource = builder.ApplicationBuilder.Resources.FirstOrDefault(r => r.Name == exportResourceName);
IResourceBuilder<ExecutableResource> exportExecutable;

if (existingResource == null)
if (existingResource is null)
{
// Create the executable resource to export the certificate
exportExecutable = builder.ApplicationBuilder
Expand All @@ -85,8 +85,6 @@ public static IResourceBuilder<TResource> RunWithHttpsDevCertificate<TResource>(
// Configure the current resource with the certificate paths
if (builder.Resource is ContainerResource containerResource)
{


var certFileDest = $"{DEV_CERT_BIND_MOUNT_DEST_DIR}/{CERT_FILE_NAME}";
var certKeyFileDest = $"{DEV_CERT_BIND_MOUNT_DEST_DIR}/{CERT_KEY_FILE_NAME}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../CommunityToolkit.Aspire.Testing/CommunityToolkit.Aspire.Testing.csproj" />
Copy link
Contributor

@davidfowl davidfowl Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..\
../

😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go complain to the editor teams - I added the reference via devkit on my devcontainer 😝

<ProjectReference Include="..\..\src\CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector\CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector.csproj" />
</ItemGroup>

Expand Down
Loading
Loading