Skip to content

Commit 595950f

Browse files
authored
Add some improvements (#283)
* fix conflict and compatibility of hosting * Add missing license header
1 parent b08027d commit 595950f

File tree

19 files changed

+244
-24
lines changed

19 files changed

+244
-24
lines changed

sample/SkyApm.Sample.GenericHost/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using Microsoft.Extensions.Hosting;
3+
using SkyApm.Agent.GeneralHost;
34

45
namespace SkyApm.Sample.GenericHost
56
{

sample/SkyApm.Sample.GenericHost/SkyApm.Sample.GenericHost.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
2121
</ItemGroup>
2222

23-
<ItemGroup>
24-
<ProjectReference Include="..\..\src\SkyApm.Agent.Hosting\SkyApm.Agent.Hosting.csproj" />
23+
<ItemGroup>
24+
<ProjectReference Include="..\..\src\SkyApm.Agent.GeneralHost\SkyApm.Agent.GeneralHost.csproj" />
2525
</ItemGroup>
2626
</Project>

sample/grpc/SkyApm.Sample.GrpcServer/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using GrpcGreeter;
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.Hosting;
5+
using SkyApm.Agent.GeneralHost;
56
using System;
67
using System.Net.Http;
78
using System.Threading;

sample/grpc/SkyApm.Sample.GrpcServer/SkyApm.Sample.GrpcServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" PrivateAssets="All" />
1919
</ItemGroup>
2020
<ItemGroup>
21-
<ProjectReference Include="..\..\..\src\SkyApm.Agent.Hosting\SkyApm.Agent.Hosting.csproj" />
21+
<ProjectReference Include="..\..\..\src\SkyApm.Agent.GeneralHost\SkyApm.Agent.GeneralHost.csproj" />
2222
<ProjectReference Include="..\SkyApm.Sample.GrpcProto\SkyApm.Sample.GrpcProto.csproj" />
2323
</ItemGroup>
2424
</Project>

src/SkyApm.Abstractions/Tracing/ICarrierHeaderCollection.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
using System.Collections.Generic;
220

321
namespace SkyApm.Tracing

src/SkyApm.Agent.AspNetCore/SkyApmHostingStartup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818

1919
using Microsoft.AspNetCore.Hosting;
20+
using Microsoft.Extensions.DependencyInjection;
2021
using SkyApm.Agent.AspNetCore;
21-
using SkyApm.Agent.Hosting;
2222
using SkyApm.AspNetCore.Diagnostics;
2323

2424
[assembly: HostingStartup(typeof(SkyApmHostingStartup))]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Microsoft.Extensions.Hosting;
20+
using SkyApm.Agent.Hosting;
21+
22+
namespace SkyApm.Agent.GeneralHost
23+
{
24+
public static class HostBuilderExtensions
25+
{
26+
public static IHostBuilder AddSkyAPM(this IHostBuilder builder) => builder.UseSkyAPM();
27+
}
28+
}

src/SkyApm.Agent.GeneralHost/SkyApm.Agent.GeneralHost.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
1313
</PropertyGroup>
1414

15+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
16+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" PrivateAssets="All" />
17+
</ItemGroup>
18+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
19+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" PrivateAssets="All" />
20+
</ItemGroup>
21+
1522
<ItemGroup>
1623
<ProjectReference Include="..\SkyApm.Agent.Hosting\SkyApm.Agent.Hosting.csproj" />
1724
</ItemGroup>

src/SkyApm.Agent.Hosting/Extensions/HostBuilderExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
*
1717
*/
1818

19-
using SkyApm.Agent.Hosting;
19+
using Microsoft.Extensions.DependencyInjection;
20+
using Microsoft.Extensions.Hosting;
2021

21-
namespace Microsoft.Extensions.Hosting
22+
namespace SkyApm.Agent.Hosting
2223
{
2324
public static class HostBuilderExtensions
2425
{
25-
public static IHostBuilder AddSkyAPM(this IHostBuilder builder) =>
26+
public static IHostBuilder UseSkyAPM(this IHostBuilder builder) =>
2627
builder.ConfigureServices((context, services) => services.AddSkyAPM());
2728
}
2829
}

src/SkyApm.Agent.Hosting/Extensions/ServiceCollectionExtensions.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using SkyApm.Diagnostics;
2222
using SkyApm.Diagnostics.EntityFrameworkCore;
2323
using SkyApm.Diagnostics.Grpc;
24+
using SkyApm.Diagnostics.Grpc.Net.Client;
2425
using SkyApm.Diagnostics.HttpClient;
2526
using SkyApm.Diagnostics.SqlClient;
2627
using SkyApm.Logging;
@@ -35,10 +36,10 @@
3536
using SkyApm.Utilities.DependencyInjection;
3637
using SkyApm.Utilities.Logging;
3738
using System;
38-
using Microsoft.Extensions.DependencyInjection;
39-
using SkyApm.Diagnostics.Grpc.Net.Client;
39+
using SkyApm;
40+
using SkyApm.Agent.Hosting;
4041

41-
namespace SkyApm.Agent.Hosting
42+
namespace Microsoft.Extensions.DependencyInjection
4243
{
4344
public static class ServiceCollectionExtensions
4445
{
@@ -67,7 +68,7 @@ internal static IServiceCollection AddSkyAPMCore(this IServiceCollection service
6768
services.AddSingleton<IConfigurationFactory, ConfigurationFactory>();
6869
services.AddSingleton<IHostedService, InstrumentationHostedService>();
6970
services.AddSingleton<IEnvironmentProvider, HostingEnvironmentProvider>();
70-
services.AddTracing().AddSampling().AddGrpcTransport().AddLogging();
71+
services.AddTracing().AddSampling().AddGrpcTransport().AddSkyApmLogging();
7172
var extensions = services.AddSkyApmExtensions()
7273
.AddHttpClient()
7374
.AddGrpcClient()
@@ -118,7 +119,7 @@ private static IServiceCollection AddGrpcTransport(this IServiceCollection servi
118119
return services;
119120
}
120121

121-
private static IServiceCollection AddLogging(this IServiceCollection services)
122+
private static IServiceCollection AddSkyApmLogging(this IServiceCollection services)
122123
{
123124
services.AddSingleton<ILoggerFactory, DefaultLoggerFactory>();
124125
return services;

src/SkyApm.Diagnostics.Grpc/Client/ClientDiagnosticInterceptor.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Grpc.Core;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Grpc.Core;
220
using Grpc.Core.Interceptors;
321
using System;
422
using System.Collections.Generic;
@@ -64,4 +82,4 @@ public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(TR
6482
}
6583
}
6684
}
67-
}
85+
}

src/SkyApm.Diagnostics.Grpc/Client/ClientDiagnosticProcessor.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Grpc.Core;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Grpc.Core;
220
using Grpc.Core.Interceptors;
321
using SkyApm.Common;
422
using SkyApm.Tracing;
@@ -19,7 +37,7 @@ public ClientDiagnosticProcessor(IExitSegmentContextAccessor segmentContextAcces
1937
_segmentContextAccessor = segmentContextAccessor;
2038
}
2139

22-
public Metadata BeginRequest<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> grpcContext)
40+
public Metadata BeginRequest<TRequest, TResponse>(ClientInterceptorContext<TRequest, TResponse> grpcContext)
2341
where TRequest : class
2442
where TResponse : class
2543
{
@@ -69,4 +87,4 @@ public void DiagnosticUnhandledException(Exception exception)
6987
}
7088
}
7189
}
72-
}
90+
}

src/SkyApm.Diagnostics.Grpc/GrpcCarrierHeaderCollection.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Grpc.Core;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Grpc.Core;
220
using SkyApm.Tracing;
321
using System;
422
using System.Collections;

src/SkyApm.Diagnostics.Grpc/Server/ServerDiagnosticInterceptor.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Grpc.Core;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Grpc.Core;
220
using Grpc.Core.Interceptors;
321
using System;
422
using System.Collections.Generic;
@@ -9,7 +27,8 @@ namespace SkyApm.Diagnostics.Grpc.Server
927
{
1028
public class ServerDiagnosticInterceptor : Interceptor
1129
{
12-
private readonly ServerDiagnosticProcessor _processor;
30+
private readonly ServerDiagnosticProcessor _processor;
31+
1332
public ServerDiagnosticInterceptor(ServerDiagnosticProcessor processor)
1433
{
1534
_processor = processor;

src/SkyApm.Diagnostics.Grpc/Server/ServerDiagnosticProcessor.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Grpc.Core;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Grpc.Core;
220
using SkyApm.Common;
321
using SkyApm.Tracing;
422
using SkyApm.Tracing.Segments;

src/SkyApm.Diagnostics.Grpc/SkyWalkingBuilderExtensions.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Microsoft.Extensions.DependencyInjection;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Microsoft.Extensions.DependencyInjection;
220
using SkyApm.Diagnostics.Grpc.Client;
321
using SkyApm.Diagnostics.Grpc.Server;
422
using SkyApm.Utilities.DependencyInjection;

src/SkyApm.Diagnostics.SmartSql/SkyWalkingBuilderExtensions.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
using Microsoft.Extensions.DependencyInjection;
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
using Microsoft.Extensions.DependencyInjection;
220
using SkyApm.Utilities.DependencyInjection;
321
using System;
422

src/SkyApm.Diagnostics.SmartSql/SmartSqlTracingDiagnosticProcessor.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to the SkyAPM under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
119
using System;
220
using System.Collections;
321
using System.Collections.Generic;

0 commit comments

Comments
 (0)