Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public static IResourceBuilder<GoFeatureFlagResource> AddGoFeatureFlag(
name: GoFeatureFlagResource.PrimaryEndpointName)
.WithHttpHealthCheck("/health")
.WithEntrypoint("/go-feature-flag")
.WithArgs(args);
.WithArgs(args)
.WithOtlpExporter();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Net.Sockets;
using Aspire.Components.Common.Tests;
using Aspire.Hosting;
using Aspire.Hosting.ApplicationModel;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace CommunityToolkit.Aspire.Hosting.GoFeatureFlag.Tests;
Expand Down Expand Up @@ -91,29 +94,6 @@ public async Task GoFeatureFlagCreatesConnectionString()
Assert.Equal("Endpoint=http://{goff.bindings.http.host}:{goff.bindings.http.port}", connectionStringResource.ConnectionStringExpression.ValueExpression);
}

[Theory]
[InlineData(LogLevel.Debug, "DEBUG")]
[InlineData(LogLevel.Information, "INFO")]
[InlineData(LogLevel.Warning, "WARN")]
[InlineData(LogLevel.Error, "ERROR")]
public async Task AddSurrealServerContainerWithLogLevel(LogLevel logLevel, string? expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why deleted?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, probably Copilot assuming that it was not relevant as it's named Surreal.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot can you re-introduce this test but rename it to AddGoFeatureFlagServerContainerWithLogLevel

{
var appBuilder = DistributedApplication.CreateBuilder();

var goff = appBuilder
.AddGoFeatureFlag("goff")
.WithLogLevel(logLevel);

using var app = appBuilder.Build();

var config = await goff.Resource.GetEnvironmentVariableValuesAsync();

bool hasValue = config.TryGetValue("LOGLEVEL", out var value);

Assert.True(hasValue);
Assert.Equal(expected, value);
}

[Theory]
[InlineData(LogLevel.Trace)]
[InlineData(LogLevel.Critical)]
Expand All @@ -128,4 +108,21 @@ public void AddSurrealServerContainerWithLogLevelThrowsOnUnsupportedLogLevel(Log

Assert.Throws<ArgumentOutOfRangeException>(func);
}

[Fact]
public void AddGoFeatureFlagAddsOtelAnnotation()
{
var appBuilder = DistributedApplication.CreateBuilder();

var goff = appBuilder.AddGoFeatureFlag("goff");

using var app = appBuilder.Build();

var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();
var resource = Assert.Single(appModel.Resources.OfType<GoFeatureFlagResource>());

// Verify that OTEL environment callback annotation is present (added by WithOtlpExporter)
var envAnnotations = resource.Annotations.OfType<EnvironmentCallbackAnnotation>().ToArray();
Assert.NotEmpty(envAnnotations);
}
}
Loading