Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Exporter.Geneva] Fix user event unit tests failures on .NET 9 #2326

Open
xiang17 opened this issue Nov 15, 2024 · 0 comments
Open

[Exporter.Geneva] Fix user event unit tests failures on .NET 9 #2326

xiang17 opened this issue Nov 15, 2024 · 0 comments
Assignees
Labels
comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva

Comments

@xiang17
Copy link
Contributor

xiang17 commented Nov 15, 2024

          Consider creating separate issue and link them in the code.

Originally posted by @Kielek in #2316 (comment)

Two test cases were tagged as skip due to failure after the SDK is bumped to 9.0:

[Fact(Skip = "This would fail on Ubuntu. Skipping for now.")]
public void UserEvents_Enabled_Success_Linux()
{
EnsureUserEventsEnabled();
var listener = new PerfTracepointListener(
MetricUnixUserEventsDataTransport.MetricsTracepointName,
MetricUnixUserEventsDataTransport.MetricsTracepointNameArgs);
if (listener.IsEnabled())
{
throw new NotSupportedException($"{MetricUnixUserEventsDataTransport.MetricsTracepointName} is already enabled");
}
try
{
listener.Enable();
MetricUnixUserEventsDataTransport.Instance.SendOtlpProtobufEvent(
testRequest,
testRequest.Length);
Thread.Sleep(5000);
foreach (var e in listener.Events)
{
this.testOutputHelper.WriteLine(string.Join(", ", e.Select(kvp => $"{kvp.Key}={kvp.Value}")));
}
Assert.Single(listener.Events);
var @event = listener.Events[0];
Assert.EndsWith($" ({MetricUnixUserEventsDataTransport.MetricsProtocol})", @event["protocol"]);
Assert.Equal(MetricUnixUserEventsDataTransport.MetricsVersion, @event["version"]);
var eventBufferStringData = @event["buffer"].AsSpan();
byte[] eventBuffer = new byte[(eventBufferStringData.Length + 1) / 3];
var index = 0;
var position = 0;
while (position < eventBufferStringData.Length)
{
eventBuffer[index++] = byte.Parse(eventBufferStringData.Slice(position, 2), NumberStyles.HexNumber);
position += 3;
}
Assert.Equal(testRequest, eventBuffer);
}
finally
{
try
{
listener.Disable();
}
catch
{
}
listener.Dispose();
}
}
[Fact(Skip = "This would fail on Ubuntu. Skipping for now.")]
public void UserEvents_Disabled_Success_Linux()
{
EnsureUserEventsEnabled();
var listener = new PerfTracepointListener(
MetricUnixUserEventsDataTransport.MetricsTracepointName,
MetricUnixUserEventsDataTransport.MetricsTracepointNameArgs);
if (listener.IsEnabled())
{
throw new NotSupportedException($"{MetricUnixUserEventsDataTransport.MetricsTracepointName} is already enabled");
}
try
{
MetricUnixUserEventsDataTransport.Instance.SendOtlpProtobufEvent(
testRequest,
testRequest.Length);
Thread.Sleep(5000);
Assert.Empty(listener.Events);
}
finally
{
listener.Dispose();
}
}

@Kielek Kielek added the comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva
Projects
None yet
Development

No branches or pull requests

3 participants