Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/EasyTrace.Tests/Export/ActivityExportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Task SingleBatchActivity()
var inMemoryExporter = new InMemoryExport();
var source = new TraceActivitySourceBuilder()
.SetTimeProvider(new MoqTimeProvider())
.SetIdentifierGenerator(MoqIdentGenerator.Sequence(1))
.SetIdentifierGenerator(MoqIdentGenerator.Sequence(2))
.SetBatchExportOptions(new BatchExportOptions
{
MaxExportBatchSize = 2,
Expand Down Expand Up @@ -116,7 +116,7 @@ public Task MultiBatchActivity()
var inMemoryExporter = new InMemoryExport();
var source = new TraceActivitySourceBuilder()
.SetTimeProvider(new MoqTimeProvider())
.SetIdentifierGenerator(MoqIdentGenerator.Sequence(10))
.SetIdentifierGenerator(MoqIdentGenerator.Sequence(20))
.SetBatchExportOptions(new BatchExportOptions
{
MaxExportBatchSize = 2,
Expand Down
42 changes: 30 additions & 12 deletions src/EasyTrace.Tests/Export/OtlpExportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public Task HttpExport()
// Make activity source.
var source = new TraceActivitySourceBuilder()
.SetTimeProvider(new MoqTimeProvider())
.SetIdentifierGenerator(MoqIdentGenerator.Set(
ActivityTraceId.CreateFromString("0af7651916cd43dd8448eb211c80319c"),
ActivitySpanId.CreateFromString("b7ad6b7169203331"),
ActivitySpanId.CreateFromString("b9ad6b7169203331")
))
.SetIdentifierGenerator(MoqIdentGenerator.Sequence(9))
.SetResources(new Dictionary<string, string>
{
["telemetry.sdk.name"] = "easytrace",
Expand All @@ -52,7 +48,7 @@ public Task HttpExport()
})
.SetBatchExportOptions(new BatchExportOptions
{
MaxExportBatchSize = 2,
MaxExportBatchSize = 3,
ScheduledDelayMilliseconds = uint.MaxValue,
})
.AddOtlpExporter(new HttpExportParameters
Expand All @@ -62,11 +58,27 @@ public Task HttpExport()
})
.Build(nameof(ActivityExportTests));

// TODO: Add more actions (x3 MaxExportBatchSize) to test splitting into multiple messages.
// Make activity for batch export.
{
using var _ = source.Start();
using var __ = source.Start();
{
using (var _ = source.Start()) {}
using (var _ = source.Start()) {}
using (var _ = source.Start()) {}
}
Task.Delay(100).Wait();

{
using var _ = source.Start();
using (var __ = source.Start()) {}
using (var __ = source.Start()) {}
}
Task.Delay(100).Wait();

{
using var _ = source.Start();
using var __ = source.Start();
using var ___ = source.Start();
}
Task.Delay(100).Wait();
}

Expand Down Expand Up @@ -138,7 +150,13 @@ public static TestRequestCache GetInstance()

public void Set(string key, byte[] value)
{
_cache[key] = value;
if (_cache.TryGetValue(key, out var list))
{
list.Add(Convert.ToHexStringLower(value));
return;
}

_cache[key] = [Convert.ToHexStringLower(value)];
}

public string GetAllCache()
Expand All @@ -149,14 +167,14 @@ public string GetAllCache()
{
result.Append(" {\n");
result.AppendFormat($" \"key\": \"{item.Key}\",\n");
result.AppendFormat($" \"value\": \"{string.Join(", ", item.Value)}\",\n");
result.AppendFormat($" \"value\": \"{string.Join(", \n", item.Value)}\",\n");
result.Append(" },\n");
}

result.Append("]\n");
return result.ToString();
}

private readonly ConcurrentDictionary<string, byte[]> _cache = new();
private readonly ConcurrentDictionary<string, List<string>> _cache = new();
private static TestRequestCache? _instance;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b9ad6b7169203331|Source: ActivityExportTests |OperationName: Child2|Kind: Internal|StartTime: 00:00:00.0000300|EndTime: 00:00:00.0000400,
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b8ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000500,
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000600
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b9ad6b7169203331|ParentId: b8ad6b7169203331|Source: ActivityExportTests |OperationName: Child2|Kind: Internal|StartTime: 00:00:00.0000300|EndTime: 00:00:00.0000400,
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b8ad6b7169203331|ParentId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000500,
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000600
]
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b76d6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000300,
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b5ad6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000400,
TraceId: 0a27651916cd43dd8448eb211c80319c|SpanId: b7ad8b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000600|EndTime: 00:00:00.0000700,
TraceId: 0a27651916cd43dd8448eb211c80319c|SpanId: b7a76b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000500|EndTime: 00:00:00.0000800,
TraceId: 0af3651916cd43dd8448eb211c80319c|SpanId: baad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0001000|EndTime: 00:00:00.0001100,
TraceId: 0af3651916cd43dd8448eb211c80319c|SpanId: b7ad697169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000900|EndTime: 00:00:00.0001200,
TraceId: 0af7451916cd43dd8448eb211c80319c|SpanId: b7ac6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0001400|EndTime: 00:00:00.0001500,
TraceId: 0af7451916cd43dd8448eb211c80319c|SpanId: b7bd6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0001300|EndTime: 00:00:00.0001600,
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6e7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0001800|EndTime: 00:00:00.0001900,
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7addb7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0001700|EndTime: 00:00:00.0002000,
TraceId: 06f7651916cd43dd8448eb211c80319c|SpanId: b70d6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0002200|EndTime: 00:00:00.0002300,
TraceId: 06f7651916cd43dd8448eb211c80319c|SpanId: bfad6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0002100|EndTime: 00:00:00.0002400,
TraceId: 0a77651916cd43dd8448eb211c80319c|SpanId: b7ad2b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0002600|EndTime: 00:00:00.0002700,
TraceId: 0a77651916cd43dd8448eb211c80319c|SpanId: b7a16b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0002500|EndTime: 00:00:00.0002800,
TraceId: 0af8651916cd43dd8448eb211c80319c|SpanId: b4ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0003000|EndTime: 00:00:00.0003100,
TraceId: 0af8651916cd43dd8448eb211c80319c|SpanId: b7ad637169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0002900|EndTime: 00:00:00.0003200,
TraceId: 0af7951916cd43dd8448eb211c80319c|SpanId: b7a66b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0003400|EndTime: 00:00:00.0003500,
TraceId: 0af7951916cd43dd8448eb211c80319c|SpanId: b75d6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0003300|EndTime: 00:00:00.0003600,
TraceId: 0af76a1916cd43dd8448eb211c80319c|SpanId: b7ad687169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0003800|EndTime: 00:00:00.0003900,
TraceId: 0af76a1916cd43dd8448eb211c80319c|SpanId: b7ad7b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0003700|EndTime: 00:00:00.0004000
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b2ad6b7169203331|ParentId: b1ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000300,
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b1ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000400,
TraceId: 02f7651916cd43dd8448eb211c80319c|SpanId: b7a46b7169203331|ParentId: b73d6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000600|EndTime: 00:00:00.0000700,
TraceId: 02f7651916cd43dd8448eb211c80319c|SpanId: b73d6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000500|EndTime: 00:00:00.0000800,
TraceId: 0a37651916cd43dd8448eb211c80319c|SpanId: b7ad667169203331|ParentId: b7ad5b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0001000|EndTime: 00:00:00.0001100,
TraceId: 0a37651916cd43dd8448eb211c80319c|SpanId: b7ad5b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000900|EndTime: 00:00:00.0001200,
TraceId: 0af4651916cd43dd8448eb211c80319c|SpanId: b7ad6b7869203331|ParentId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0001400|EndTime: 00:00:00.0001500,
TraceId: 0af4651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0001300|EndTime: 00:00:00.0001600,
TraceId: 0af7551916cd43dd8448eb211c80319c|SpanId: b7ad6b716a203331|ParentId: b7ad6b7199203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0001800|EndTime: 00:00:00.0001900,
TraceId: 0af7551916cd43dd8448eb211c80319c|SpanId: b7ad6b7199203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0001700|EndTime: 00:00:00.0002000,
TraceId: 0af7661916cd43dd8448eb211c80319c|SpanId: b7ad6b71692c3331|ParentId: b7ad6b7169b03331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0002200|EndTime: 00:00:00.0002300,
TraceId: 0af7661916cd43dd8448eb211c80319c|SpanId: b7ad6b7169b03331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0002100|EndTime: 00:00:00.0002400,
TraceId: 0af7657916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203e31|ParentId: b7ad6b716920d331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0002600|EndTime: 00:00:00.0002700,
TraceId: 0af7657916cd43dd8448eb211c80319c|SpanId: b7ad6b716920d331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0002500|EndTime: 00:00:00.0002800,
TraceId: 0af7651816cd43dd8448eb211c80319c|SpanId: b7ad6b716920333f|ParentId: b7ad6b71692033f1|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0003000|EndTime: 00:00:00.0003100,
TraceId: 0af7651816cd43dd8448eb211c80319c|SpanId: b7ad6b71692033f1|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0002900|EndTime: 00:00:00.0003200,
TraceId: 0af7651996cd43dd8448eb211c80319c|SpanId: bdad6b7169203331|ParentId: bead6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0003400|EndTime: 00:00:00.0003500,
TraceId: 0af7651996cd43dd8448eb211c80319c|SpanId: bead6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0003300|EndTime: 00:00:00.0003600,
TraceId: 0af765191acd43dd8448eb211c80319c|SpanId: b7ab6b7169203331|ParentId: b7cd6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0003800|EndTime: 00:00:00.0003900,
TraceId: 0af765191acd43dd8448eb211c80319c|SpanId: b7cd6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0003700|EndTime: 00:00:00.0004000
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b76d6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000300,
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b5ad6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000400
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b2ad6b7169203331|ParentId: b1ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000300,
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b1ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000400
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: TestName|Kind: Client|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: TestName|Kind: Client|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: TestName|Kind: Consumer|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: TestName|Kind: Consumer|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: TestName|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: TestName|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: TestName|Kind: Producer|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: TestName|Kind: Producer|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|Source: ActivityExportTests |OperationName: TestName|Kind: Server|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
TraceId: 0af7651916cd43dd8448eb211c80319c|SpanId: b7ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: TestName|Kind: Server|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000200
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b74d6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000300,
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b3ad6b7169203331|Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000400
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b2ad6b7169203331|ParentId: b1ad6b7169203331|Source: ActivityExportTests |OperationName: Child1|Kind: Internal|StartTime: 00:00:00.0000200|EndTime: 00:00:00.0000300,
TraceId: 01f7651916cd43dd8448eb211c80319c|SpanId: b1ad6b7169203331|ParentId: |Source: ActivityExportTests |OperationName: Parent|Kind: Internal|StartTime: 00:00:00.0000100|EndTime: 00:00:00.0000400
]
Loading
Loading