-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Span interface definition, Span model definition added (#25)
1. Changes within the Mocha.Storage MysqlSpanWrite, EntityFrameworkSpanWrite MySQLSpanReader EntityFrameworkSpanReader 2. Changes within the Mocha.Core.Storage ISpanWriter, ISpanWrite 3. Add MochaContext definition 4. #7
- Loading branch information
Showing
14 changed files
with
180 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
namespace Mocha.Core.Enums; | ||
|
||
public enum SpanKind | ||
{ | ||
Unspecified = 0, | ||
|
||
Client = 1, | ||
|
||
Server = 2, | ||
|
||
Internal = 3, | ||
|
||
Producer = 4, | ||
|
||
Consumer = 5 | ||
} |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
using Mocha.Core.Storage.Query; | ||
|
||
namespace Mocha.Core.Storage; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public interface ISpanReader | ||
{ | ||
Task<IEnumerable<string>> FindTraceIdListAsync(TraceReadQuery query); | ||
|
||
Task FindTraceList(string serviceName); | ||
Task FindSpanListByTraceIdAsync(string traceId); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
using OpenTelemetry.Proto.Trace.V1; | ||
|
||
namespace Mocha.Core.Storage; | ||
|
||
public interface ISpanWriter | ||
{ | ||
Task<bool> WriterAsync(); | ||
|
||
bool Writer(); | ||
Task WriteAsync(IEnumerable<Span> spans); | ||
} |
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,19 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
using System.Collections; | ||
|
||
namespace Mocha.Core.Storage.Query; | ||
|
||
public class TraceReadQuery | ||
{ | ||
public string? ServiceName { get; set; } | ||
|
||
public IDictionary<string, string>? SpanAttributes { get; set; } | ||
|
||
public long? StartTimeStamp { get; set; } | ||
|
||
public long? EndTimeStamp { get; set; } | ||
|
||
public string? SpanName { get; set; } | ||
} |
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,41 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
using Mocha.Core.Enums; | ||
|
||
namespace Mocha.Storage.EntityFrameworkStorage.Trace; | ||
|
||
public class Span | ||
{ | ||
public string TraceId { get; set; } = string.Empty; | ||
|
||
public string SpanId { get; set; } = string.Empty; | ||
|
||
public string SpanName { get; set; } = string.Empty; | ||
|
||
public string ParentSpanId { get; set; } = string.Empty; | ||
|
||
public string ServiceName { get; set; } = string.Empty; | ||
|
||
public long StartTime { get; set; } | ||
|
||
public long EndTime { get; set; } | ||
|
||
public double Duration { get; set; } | ||
|
||
public int StatusCode { get; set; } | ||
|
||
public string? StatusMessage { get; set; } = string.Empty; | ||
|
||
public SpanKind SpanKind { get; set; } | ||
|
||
public uint TraceFlags { get; set; } | ||
|
||
public string? TraceState { get; set; } | ||
|
||
public IEnumerable<SpanLink> SpanLinks { get; set; } = Enumerable.Empty<SpanLink>(); | ||
|
||
public IEnumerable<SpanAttribute> SpanAttributes { get; set; } = Enumerable.Empty<SpanAttribute>(); | ||
|
||
public IEnumerable<SpanEvent> SpanEvents { get; set; } = Enumerable.Empty<SpanEvent>(); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Mocha.Storage/EntityFrameworkStorage/Trace/SpanAttribute.cs
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,19 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
namespace Mocha.Storage.EntityFrameworkStorage.Trace; | ||
|
||
public class SpanAttribute | ||
{ | ||
public string AttributeKey { get; set; } = string.Empty; | ||
|
||
public string AttributeValue { get; set; } = string.Empty; | ||
|
||
public long TimeBucket { get; set; } | ||
|
||
public string TraceId { get; set; } = string.Empty; | ||
|
||
public string SpanId { get; set; } = string.Empty; | ||
|
||
public Span Span { get; set; } = default!; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Mocha.Storage/EntityFrameworkStorage/Trace/SpanEvent.cs
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 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
|
||
namespace Mocha.Storage.EntityFrameworkStorage.Trace; | ||
|
||
public class SpanEvent | ||
{ | ||
public string TraceId { get; set; } = string.Empty; | ||
|
||
public long TimeBucket { get; set; } | ||
|
||
public string EventName { get; set; } = string.Empty; | ||
|
||
public Span Span { get; set; } = default!; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Mocha.Storage/EntityFrameworkStorage/Trace/SpanLink.cs
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,19 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
namespace Mocha.Storage.EntityFrameworkStorage.Trace; | ||
|
||
public class SpanLink | ||
{ | ||
public string TraceId { get; private set; } = string.Empty; | ||
|
||
public string SpanId { get; private set; } = string.Empty; | ||
|
||
public string LinkedSpanId { get; private set; } = string.Empty; | ||
|
||
public string TraceState { get; private set; } = string.Empty; | ||
|
||
public bool Flags { get; private set; } | ||
|
||
public Span Span { get; set; } = default!; | ||
} |
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,22 @@ | ||
// Licensed to the .NET Core Community under one or more agreements. | ||
// The .NET Core Community licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
using Mocha.Storage.EntityFrameworkStorage.Trace; | ||
|
||
namespace Mocha.Storage; | ||
|
||
public class MochaContext : DbContext | ||
{ | ||
public MochaContext(DbContextOptions options) : base(options) | ||
{ | ||
} | ||
|
||
public DbSet<SpanAttribute> SpanAttributes => Set<SpanAttribute>(); | ||
|
||
public DbSet<SpanEvent> SpanEvents => Set<SpanEvent>(); | ||
|
||
public DbSet<SpanLink> SpanLinks => Set<SpanLink>(); | ||
|
||
public DbSet<Span> Spans => Set<Span>(); | ||
} |