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

Refactor tracing context #139

Merged
merged 27 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
58aecfc
Delete `ISkyWalkingClient` interface
liuhaoyang Feb 5, 2019
95345d2
Use segment protocol V2
liuhaoyang Feb 5, 2019
e074693
Forget the old api. All context apis will be overwritten.
liuhaoyang Feb 6, 2019
ffe496e
Merge branch 'master' into feature/refactor_tracecontext
liuhaoyang Feb 6, 2019
81659b7
Add segments define
liuhaoyang Feb 9, 2019
6ffcead
Add some apis
liuhaoyang Feb 10, 2019
867af2c
Merge branch 'master' into feature/refactor_tracecontext
liuhaoyang Feb 10, 2019
9a5f50a
Add carrierParser
liuhaoyang Feb 10, 2019
114de87
Add SegmentContextAccessor API
liuhaoyang Feb 11, 2019
7a7baf3
Add SampledDelegate interface
liuhaoyang Feb 11, 2019
aeb90ce
Add thread-safe SamplerChainBuilder
liuhaoyang Feb 11, 2019
f1eba8d
Add SegmentContextFactory
liuhaoyang Feb 12, 2019
beebfbe
Merge branch 'master' into feature/refactor_tracecontext
liuhaoyang Feb 12, 2019
5694428
Merge branch 'master' into feature/refactor_tracecontext
liuhaoyang Feb 12, 2019
706c9aa
Add ITracingContext Interface
liuhaoyang Feb 12, 2019
b5b7dd4
Refactoring the core API for tracing context
liuhaoyang Feb 12, 2019
6adf05e
remove utils package
liuhaoyang Feb 12, 2019
6ea01a7
Resolve issue #57 : Provide percentage-based sampling
liuhaoyang Feb 12, 2019
0308d88
Refactor HttpClient Tracing
liuhaoyang Feb 13, 2019
5379823
Merge branch 'master' into feature/refactor_tracecontext
liuhaoyang Feb 13, 2019
837505e
Fix header carrier
liuhaoyang Feb 13, 2019
0b9ce27
Add async exitSpan sample
liuhaoyang Feb 13, 2019
19295fb
Add Task.WhenAll sample
liuhaoyang Feb 13, 2019
54c8ee9
Refactor EntityFrameworkCore tracing
liuhaoyang Feb 13, 2019
febbcad
Refactor SqlClient & CAP Tracing
liuhaoyang Feb 13, 2019
4870ba5
Refactor Asp.Net tracing
liuhaoyang Feb 13, 2019
4688432
Remove outdated APIs
liuhaoyang Feb 13, 2019
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
14 changes: 4 additions & 10 deletions sample/SkyWalking.Sample.AspNet/skywalking.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"SkyWalking": {
"ApplicationCode": "SkyWalking.Sample.AspNet",
"SpanLimitPerSegment": 300,
"Sampling": {
"SamplePer3Secs": -1
},
"ServiceName": "aspnet-sample",
"Logging": {
"Level": "Information",
"FilePath": "logs\\SkyWalking-{Date}.log"
"Level": "Debug",
"FilePath": "/tmp/logs/SkyWalking-{Date}.log"
},
"Transport": {
"Interval": 3000,
"PendingSegmentLimit": 30000,
"PendingSegmentTimeout": 1000,
"gRPC": {
"Servers": "localhost:11800",
"Timeout": 2000,
"Timeout": 10000,
"ConnectTimeout": 10000
}
}
Expand Down
17 changes: 17 additions & 0 deletions sample/SkyWalking.Sample.Backend/Controllers/DelayController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace SkyWalking.Sample.Backend.Controllers
{
[Route("api/[controller]")]
public class DelayController : Controller
{
// GET
[HttpGet("{delay}")]
public async Task<string> Get(int delay)
{
await Task.Delay(delay);
return $"delay {delay}ms";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using SkyWalking.Tracing;

namespace SkyWalking.Sample.Backend.Sampling
{
public class CustomSamplingInterceptor : ISamplingInterceptor
{
public int Priority { get; } = 0;

public bool Invoke(SamplingContext samplingContext, Sampler next)
{
return next(samplingContext);
}
}
}
4 changes: 4 additions & 0 deletions sample/SkyWalking.Sample.Backend/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SkyWalking.Sample.Backend.Models;
using SkyWalking.Sample.Backend.Sampling;
using SkyWalking.Tracing;

namespace SkyWalking.Sample.Backend
{
Expand All @@ -26,6 +28,8 @@ public void ConfigureServices(IServiceCollection services)
sqliteConnection.Open();

services.AddEntityFrameworkSqlite().AddDbContext<SampleDbContext>(c => c.UseSqlite(sqliteConnection));

services.AddSingleton<ISamplingInterceptor, CustomSamplingInterceptor>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
16 changes: 13 additions & 3 deletions sample/SkyWalking.Sample.Frontend/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ namespace SkyWalking.Sample.Frontend.Controllers
public class ValuesController : Controller
{
// GET api/values
[HttpGet("/values")]
[HttpGet]
public async Task<IEnumerable<string>> Get()
{
await new HttpClient().GetAsync("http://localhost:5002/api/values");
return new string[] { "value1", "value2" };
}
return new string[] {"value1", "value2"};
}

[HttpGet("{id}")]
public async Task<string> Get(int id)
{
var client = new HttpClient();
Task.WhenAll(client.GetAsync("http://localhost:5002/api/delay/2000"),
client.GetAsync("http://localhost:5002/api/values"),
client.GetAsync("http://localhost:5002/api/delay/200"));
return await client.GetStringAsync("http://localhost:5002/api/delay/100");
}
}
}
2 changes: 1 addition & 1 deletion sample/SkyWalking.Sample.Frontend/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
},
"SkyWalking": {
"ApplicationCode": "asp-net-core-frontend"
"ServiceName": "asp-net-core-frontend"
}
}

41 changes: 41 additions & 0 deletions src/SkyWalking.Abstractions/Common/Components.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to the OpenSkywalking under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenSkywalking licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

namespace SkyWalking.Common
{
public static class Components
{
public static readonly StringOrIntValue ASPNETCORE= new StringOrIntValue("AspNetCore");

public static readonly StringOrIntValue HTTPCLIENT = new StringOrIntValue("HttpClient");

public static readonly StringOrIntValue ENTITYFRAMEWORKCORE = new StringOrIntValue("EntityFrameworkCore");

public static readonly StringOrIntValue SQLCLIENT = new StringOrIntValue("SqlClient");

public static readonly StringOrIntValue CAP = new StringOrIntValue("CAP");

public static readonly StringOrIntValue ENTITYFRAMEWORKCORE_SQLITE = new StringOrIntValue("EntityFrameworkCore.Sqlite");

public static readonly StringOrIntValue POMELO_ENTITYFRAMEWORKCORE_MYSQL = new StringOrIntValue("Pomelo.EntityFrameworkCore.MySql");

public static readonly StringOrIntValue NPGSQL_ENTITYFRAMEWORKCORE_POSTGRESQL = new StringOrIntValue("Npgsql.EntityFrameworkCore.PostgreSQL");

public static readonly StringOrIntValue ASPNET = new StringOrIntValue("AspNet");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

namespace SkyWalking
namespace SkyWalking.Common
{
public struct NullableValue
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

namespace SkyWalking
namespace SkyWalking.Common
{
public struct StringOrIntValue
{
Expand All @@ -29,6 +29,8 @@ public StringOrIntValue(int value)
_stringValue = null;
}

public bool HasValue => HasIntValue || HasStringValue;

public bool HasIntValue => _intValue != 0;

public bool HasStringValue => _stringValue != null;
Expand All @@ -53,5 +55,11 @@ public StringOrIntValue(int intValue, string stringValue)
{
return (_stringValue, _intValue);
}

public override string ToString()
{
if (HasIntValue) return _intValue.ToString();
return _stringValue;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Licensed to the OpenSkywalking under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
Expand All @@ -16,30 +16,27 @@
*
*/

using SkyWalking.Context.Ids;

namespace SkyWalking.Context
namespace SkyWalking.Common
{
public interface IContextSnapshot
public static class Tags
{
string EntryOperationName { get; set; }

string ParentOperationName { get; set; }

DistributedTraceId DistributedTraceId { get; }

int EntryApplicationInstanceId { get; set; }
public static readonly string URL = "url";

public static readonly string PATH = "path";

int SpanId { get; }

bool IsFromCurrent { get; }
public static readonly string HTTP_METHOD = "http.method";

bool IsValid { get; }
public static readonly string STATUS_CODE = "status_code";

ID TraceSegmentId { get; }
public static readonly string DB_TYPE = "db.type";

int EntryOperationId { set; }
public static readonly string DB_INSTANCE = "db.instance";

public static readonly string DB_STATEMENT = "db.statement";

int ParentOperationId { set; }
public static readonly string DB_BIND_VARIABLES = "db.bind_vars";

public static readonly string MQ_TOPIC = "mq.topic";
}
}
59 changes: 0 additions & 59 deletions src/SkyWalking.Abstractions/Components/ComponentsDefine.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@
namespace SkyWalking.Config
{
[Config("SkyWalking")]
public class InstrumentationConfig
public class InstrumentConfig
{
public string Namespace { get; set; }

[Obsolete("Use ServiceName.")]
public string ApplicationCode { get; set; }

public string ServiceName { get; set; }

public string[] HeaderVersions { get; set; }
}

public int SpanLimitPerSegment { get; set; } = 300;
public static class HeaderVersions
{
public static string SW3 { get; } = "sw3";

public static string SW6 { get; } = "sw6";
}
}
2 changes: 2 additions & 0 deletions src/SkyWalking.Abstractions/Config/SamplingConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ namespace SkyWalking.Config
public class SamplingConfig
{
public int SamplePer3Secs { get; set; } = -1;

public double Percentage { get; set; } = -1d;
}
}
4 changes: 2 additions & 2 deletions src/SkyWalking.Abstractions/Config/TransportConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace SkyWalking.Config
[Config("SkyWalking", "Transport")]
public class TransportConfig
{
public int PendingSegmentLimit { get; set; } = 30000;
public int QueueSize { get; set; } = 30000;

/// <summary>
/// Flush Interval Millisecond
Expand All @@ -31,7 +31,7 @@ public class TransportConfig
/// <summary>
/// Data queued beyond this time will be discarded.
/// </summary>
public int PendingSegmentTimeout { get; set; } = 1000;
public int BatchSize { get; set; } = 3000;

public string ProtocolVersion { get; set; } = ProtocolVersions.V6;
}
Expand Down
Loading