-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Seq component to use OTEL's
AddProcessor
instead of `AddOtl…
…pExporter` (#3697) * Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. * Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. * Move OTLP exporter options onto SeqSettings.cs * Add test * Update README * Renamed Seq settings * Change order of config * Updated code doc * ConfigurationSchema.json * Throw an exception if ServerUrl is unspecified, but HealthChecks is enabled. * Fix tests * PR feedback Fix #3546
- Loading branch information
1 parent
3a601cb
commit e58ae7d
Showing
10 changed files
with
246 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetCurrent)</TargetFramework> | ||
<RunTestsOnHelix>true</RunTestsOnHelix> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>Aspire.Seq</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Components\Aspire.Seq\Aspire.Seq.csproj" /> | ||
<ProjectReference Include="..\Aspire.Components.Common.Tests\Aspire.Components.Common.Tests.csproj" /> | ||
|
||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
| ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Extensions.Hosting; | ||
using OpenTelemetry.Exporter; | ||
using Xunit; | ||
|
||
namespace Aspire.Seq.Tests; | ||
|
||
public class SeqTests | ||
{ | ||
[Fact] | ||
public void SeqEndpointCanBeConfigured() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
builder.AddSeqEndpoint("seq", s => | ||
{ | ||
s.HealthChecks = false; | ||
s.Logs.TimeoutMilliseconds = 1000; | ||
s.Traces.Protocol = OtlpExportProtocol.Grpc; | ||
}); | ||
|
||
using var host = builder.Build(); | ||
} | ||
|
||
[Fact] | ||
public void ServerUrlSettingOverridesExporterEndpoints() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
var serverUrl = "http://localhost:9876"; | ||
|
||
SeqSettings settings = new SeqSettings(); | ||
|
||
builder.AddSeqEndpoint("seq", s => | ||
{ | ||
settings = s; | ||
s.ServerUrl = serverUrl; | ||
s.ApiKey = "ABCDE12345"; | ||
s.Logs.Endpoint = new Uri("http://localhost:1234/ingest/otlp/v1/logs"); | ||
s.Traces.Endpoint = new Uri("http://localhost:1234/ingest/otlp/v1/traces"); | ||
}); | ||
|
||
Assert.Equal(settings.Logs.Endpoint, new Uri("http://localhost:9876/ingest/otlp/v1/logs")); | ||
Assert.Equal(settings.Traces.Endpoint, new Uri("http://localhost:9876/ingest/otlp/v1/traces")); | ||
} | ||
|
||
[Fact] | ||
public void ApiKeySettingIsMergedWithConfiguredHeaders() | ||
{ | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
|
||
SeqSettings settings = new SeqSettings(); | ||
|
||
builder.AddSeqEndpoint("seq", s => | ||
{ | ||
settings = s; | ||
s.HealthChecks = false; | ||
s.ApiKey = "ABCDE12345"; | ||
s.Logs.Headers = "speed=fast,quality=good"; | ||
s.Traces.Headers = "quality=good,speed=fast"; | ||
}); | ||
|
||
Assert.Equal("speed=fast,quality=good,X-Seq-ApiKey=ABCDE12345", settings.Logs.Headers); | ||
Assert.Equal("quality=good,speed=fast,X-Seq-ApiKey=ABCDE12345", settings.Traces.Headers); | ||
} | ||
} |