mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 00:38:28 +02:00
Add OTEL tracing support for Wiremock + automatic OTEL for Aspire integration (#1418)
* Update aspire to 13.1 (examples + code) Allows usage of aspire CLI which is very useful for dev in codespaces (for my next PR). * Add OTEL support * Initial PR feedback * PR feedback * PR feedback * PR feedback * Cleanup. * Cleanup * Fix * Fix * Rename stuff around to be more accurate * PR feedback * Update WireMock.Net.OpenTelemetry.csproj Update <Authors> * PR feedback parser * PR feedback package versions * Status code feedback. * Update preprocessor directives to to Activity Tracing instead of OpenTelemetry. Is more descriptive. * Add tests * Improve tests --------- Co-authored-by: Stef Heyenrath <Stef.Heyenrath@gmail.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using WireMock.OpenTelemetry;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.OpenTelemetry;
|
||||
|
||||
public class OpenTelemetryOptionsParserTests
|
||||
{
|
||||
[Fact]
|
||||
public void TryParseArguments_Enabled_ShouldReturnOptions()
|
||||
{
|
||||
// Act
|
||||
var result = OpenTelemetryOptionsParser.TryParseArguments(new[]
|
||||
{
|
||||
"--OpenTelemetryEnabled", "true",
|
||||
"--OpenTelemetryExcludeAdminRequests", "false",
|
||||
"--OpenTelemetryOtlpExporterEndpoint", "http://localhost:4317"
|
||||
}, null, out var options);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
options.Should().NotBeNull();
|
||||
options!.ExcludeAdminRequests.Should().BeFalse();
|
||||
options.OtlpExporterEndpoint.Should().Be("http://localhost:4317");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParseArguments_NotEnabled_ShouldReturnNull()
|
||||
{
|
||||
// Act
|
||||
var result = OpenTelemetryOptionsParser.TryParseArguments(Array.Empty<string>(), null, out var options);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
options.Should().BeNull();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user