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

Span interface definition, Span model definition added #25

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2179823
feature :
KawhiWei Oct 17, 2023
57aeb76
Merge pull request #1 from KawhiWei/vv_feature_span_model_writer_defi…
KawhiWei Oct 17, 2023
4a8a204
feat :
KawhiWei Oct 18, 2023
8484a86
feature:
KawhiWei Oct 18, 2023
7411648
Merge pull request #2 from KawhiWei/vv_feature_span_model_writer_defi…
KawhiWei Oct 18, 2023
92e35a9
Revert "Vv feature span model writer definition"
KawhiWei Oct 18, 2023
41f1208
Merge pull request #3 from KawhiWei/revert-2-vv_feature_span_model_wr…
KawhiWei Oct 18, 2023
14c7705
Revert "feature :"
KawhiWei Oct 18, 2023
b728ea8
Merge pull request #4 from KawhiWei/revert-1-vv_feature_span_model_wr…
KawhiWei Oct 18, 2023
6ffca79
Merge branch 'dotnetcore:main' into main
KawhiWei Oct 18, 2023
1299cf1
1.Changes within the Mocha.Storage MysqlSpanWrite, EntityFrameworkSpa…
KawhiWei Oct 18, 2023
613afc5
feature:
KawhiWei Oct 18, 2023
0a345f2
Merge branch 'dotnetcore:main' into main
KawhiWei Oct 18, 2023
8b54b50
Merge branch 'main' into vv_feature_span_model_writer_definition
KawhiWei Oct 18, 2023
123c2c0
feature
KawhiWei Oct 18, 2023
c385220
feat :
KawhiWei Oct 19, 2023
a811ed6
feat :
KawhiWei Oct 22, 2023
2e4eb5a
feat :
KawhiWei Oct 22, 2023
6a5d649
feature:
KawhiWei Oct 22, 2023
292cb87
Fix whitespace formatting. Insert '\s'.
KawhiWei Oct 22, 2023
9f3935a
Fix:
KawhiWei Oct 22, 2023
74f931c
Fix the issue of adding utf-8-bom to some files
KawhiWei Oct 22, 2023
777512c
feature
KawhiWei Oct 23, 2023
f6b64ba
fixed:
KawhiWei Oct 23, 2023
223cdb5
Fixed:
KawhiWei Oct 23, 2023
a11d9b1
feature
KawhiWei Oct 23, 2023
0fb55a1
Fixed
KawhiWei Oct 23, 2023
4ea4653
change TraceReadQuery SpanAttributes Type
KawhiWei Oct 23, 2023
07a3bfc
change WriteAsync Return
KawhiWei Oct 23, 2023
c0c9aac
feature SpanKind
KawhiWei Oct 23, 2023
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

# file header
file_header_template = Licensed to the.NET Core Community under one or more agreements.\nThe.NET Core Community licenses this file to you under the MIT license.
file_header_template = Licensed to the .NET Core Community under one or more agreements.\nThe .NET Core Community licenses this file to you under the MIT license.
19 changes: 19 additions & 0 deletions src/Mocha.Core/Enums/SpanKind.cs
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
}
4 changes: 4 additions & 0 deletions src/Mocha.Core/Mocha.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
</PropertyGroup>

<ItemGroup>
liuhaoyang marked this conversation as resolved.
Show resolved Hide resolved
<ProjectReference Include="..\Mocha.Protocol.Generated\Mocha.Protocol.Generated.csproj" />
</ItemGroup>
liuhaoyang marked this conversation as resolved.
Show resolved Hide resolved

</Project>
8 changes: 4 additions & 4 deletions src/Mocha.Core/Storage/ISpanReader.cs
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.

liuhaoyang marked this conversation as resolved.
Show resolved Hide resolved
using Mocha.Core.Storage.Query;

namespace Mocha.Core.Storage;

/// <summary>
///
/// </summary>
public interface ISpanReader
{
Task<IEnumerable<string>> FindTraceIdListAsync(TraceReadQuery query);

liuhaoyang marked this conversation as resolved.
Show resolved Hide resolved
Task FindTraceList(string serviceName);
Task FindSpanListByTraceIdAsync(string traceId);
}
6 changes: 3 additions & 3 deletions src/Mocha.Core/Storage/ISpanWriter.cs
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);
}
19 changes: 19 additions & 0 deletions src/Mocha.Core/Storage/Query/TraceReadQuery.cs
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
{
liuhaoyang marked this conversation as resolved.
Show resolved Hide resolved
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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// The .NET Core Community licenses this file to you under the MIT license.

using Mocha.Core.Storage;
using Mocha.Core.Storage.Query;

namespace Mocha.Storage.Mysql;
namespace Mocha.Storage.EntityFrameworkStorage;

public class MySqlSpanWriter : ISpanWriter
public class EntityFrameworkSpanReader : ISpanReader
{
public Task<bool> WriterAsync()
public Task<IEnumerable<string>> FindTraceIdListAsync(TraceReadQuery query)
{
throw new NotImplementedException();
}

public bool Writer()
public Task FindSpanListByTraceIdAsync(string traceId)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

using Mocha.Core.Storage;

namespace Mocha.Storage.Mysql;
namespace Mocha.Storage.EntityFrameworkStorage;

public class MySqlSpanReader : ISpanReader
public class EntityFrameworkSpanWriter : ISpanWriter
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码格式化

public Task FindTraceList(string serviceName)
public Task WriteAsync(IEnumerable<OpenTelemetry.Proto.Trace.V1.Span> spans)
{
throw new NotImplementedException();
}
Expand Down
41 changes: 41 additions & 0 deletions src/Mocha.Storage/EntityFrameworkStorage/Trace/Span.cs
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
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要写default!

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 src/Mocha.Storage/EntityFrameworkStorage/Trace/SpanAttribute.cs
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 src/Mocha.Storage/EntityFrameworkStorage/Trace/SpanEvent.cs
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 src/Mocha.Storage/EntityFrameworkStorage/Trace/SpanLink.cs
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!;
}
6 changes: 5 additions & 1 deletion src/Mocha.Storage/Mocha.Storage.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和其他project一样,开启Nullable enable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和其他project一样,开启Nullable enable

开了的

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -9,4 +8,9 @@
<ItemGroup>
<ProjectReference Include="..\Mocha.Core\Mocha.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions src/Mocha.Storage/MochaContext.cs
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>();
}