Files
WireMock.Net-wiremock/test/WireMock.Net.Tests/OpenTelemetry/OpenTelemetryOptionsParserTests.cs
Petr Houška 4525c61847 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>
2026-01-18 17:22:36 +01:00

43 lines
1.1 KiB
C#

// 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