Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-dotnet
提交
d5e6053f
S
SkyAPM-dotnet
项目概览
SkyAPM
/
SkyAPM-dotnet
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyAPM-dotnet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
d5e6053f
编写于
2月 17, 2019
作者:
L
Lemon
提交者:
GitHub
2月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `IAdditionalConfigurationSource` to load the agent-config from the config center. (#151)
上级
6793d430
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
140 addition
and
32 deletion
+140
-32
src/SkyApm.Agent.AspNet/Extensions/ServiceCollectionExtensions.cs
...pm.Agent.AspNet/Extensions/ServiceCollectionExtensions.cs
+5
-4
src/SkyApm.Agent.AspNetCore/Extensions/ServiceCollectionExtensions.cs
...gent.AspNetCore/Extensions/ServiceCollectionExtensions.cs
+1
-0
src/SkyApm.Utilities.Configuration/ConfigAccessor.cs
src/SkyApm.Utilities.Configuration/ConfigAccessor.cs
+5
-28
src/SkyApm.Utilities.Configuration/ConfigurationFactory.cs
src/SkyApm.Utilities.Configuration/ConfigurationFactory.cs
+75
-0
src/SkyApm.Utilities.Configuration/IAdditionalConfigurationSource.cs
...Utilities.Configuration/IAdditionalConfigurationSource.cs
+27
-0
src/SkyApm.Utilities.Configuration/IConfigurationFactory.cs
src/SkyApm.Utilities.Configuration/IConfigurationFactory.cs
+27
-0
未找到文件。
src/SkyApm.Agent.AspNet/Extensions/ServiceCollectionExtensions.cs
浏览文件 @
d5e6053f
...
...
@@ -47,7 +47,8 @@ namespace SkyApm.Agent.AspNet.Extensions
services
.
AddSingleton
<
IConfigAccessor
,
ConfigAccessor
>();
services
.
AddSingleton
<
IEnvironmentProvider
,
HostingEnvironmentProvider
>();
services
.
AddSingleton
<
InstrumentRequestCallback
>();
services
.
AddSingleton
<
IConfigurationFactory
,
ConfigurationFactory
>();
services
.
AddSingleton
<
ITracingContext
,
Tracing
.
TracingContext
>();
services
.
AddSingleton
<
ICarrierPropagator
,
CarrierPropagator
>();
services
.
AddSingleton
<
ICarrierFormatter
,
Sw3CarrierFormatter
>();
...
...
@@ -61,19 +62,19 @@ namespace SkyApm.Agent.AspNet.Extensions
services
.
AddSingleton
<
IUniqueIdParser
,
UniqueIdParser
>();
services
.
AddSingleton
<
ISegmentContextMapper
,
SegmentContextMapper
>();
services
.
AddSingleton
<
IBase64Formatter
,
Base64Formatter
>();
services
.
AddSingleton
<
SimpleCountSamplingInterceptor
>();
services
.
AddSingleton
<
ISamplingInterceptor
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
IExecutionService
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
ISamplingInterceptor
,
RandomSamplingInterceptor
>();
services
.
AddSingleton
<
ISkyApmClientV5
,
SkyApmClientV5
>();
services
.
AddSingleton
<
ISegmentReporter
,
SegmentReporter
>();
services
.
AddSingleton
<
ConnectionManager
>();
services
.
AddSingleton
<
IPingCaller
,
PingCaller
>();
services
.
AddSingleton
<
IServiceRegister
,
ServiceRegister
>();
services
.
AddSingleton
<
IExecutionService
,
ConnectService
>();
services
.
AddSingleton
<
ILoggerFactory
,
DefaultLoggerFactory
>();
return
services
;
}
...
...
src/SkyApm.Agent.AspNetCore/Extensions/ServiceCollectionExtensions.cs
浏览文件 @
d5e6053f
...
...
@@ -57,6 +57,7 @@ namespace SkyApm.Agent.AspNetCore
services
.
AddSingleton
<
IRuntimeEnvironment
>(
RuntimeEnvironment
.
Instance
);
services
.
AddSingleton
<
TracingDiagnosticProcessorObserver
>();
services
.
AddSingleton
<
IConfigAccessor
,
ConfigAccessor
>();
services
.
AddSingleton
<
IConfigurationFactory
,
ConfigurationFactory
>();
services
.
AddSingleton
<
IHostedService
,
InstrumentationHostedService
>();
services
.
AddSingleton
<
IEnvironmentProvider
,
HostingEnvironmentProvider
>();
services
.
AddTracing
().
AddSampling
().
AddGrpcTransport
().
AddLogging
();
...
...
src/SkyApm.Utilities.Configuration/ConfigAccessor.cs
浏览文件 @
d5e6053f
...
...
@@ -22,40 +22,15 @@ using System.Reflection;
using
Microsoft.Extensions.Configuration
;
using
SkyApm.Config
;
// ReSharper disable StringLiteralTypo
namespace
SkyApm.Utilities.Configuration
{
public
class
ConfigAccessor
:
IConfigAccessor
{
private
const
string
CONFIG_FILE_PATH_COMPATIBLE
=
"SKYWALKING__CONFIG__PATH"
;
private
const
string
CONFIG_FILE_PATH
=
"SKYAPM__CONFIG__PATH"
;
private
readonly
IConfiguration
_configuration
;
public
ConfigAccessor
(
I
EnvironmentProvider
environmentProvider
)
public
ConfigAccessor
(
I
ConfigurationFactory
factory
)
{
var
builder
=
new
ConfigurationBuilder
();
builder
.
AddSkyWalkingDefaultConfig
();
builder
.
AddJsonFile
(
"appsettings.json"
,
true
).
AddJsonFile
(
$"appsettings.
{
environmentProvider
.
EnvironmentName
}
.json"
,
true
);
builder
.
AddJsonFile
(
"skywalking.json"
,
true
).
AddJsonFile
(
$"skywalking.
{
environmentProvider
.
EnvironmentName
}
.json"
,
true
);
builder
.
AddJsonFile
(
"skyapm.json"
,
true
).
AddJsonFile
(
$"skyapm.
{
environmentProvider
.
EnvironmentName
}
.json"
,
true
);
if
(!
string
.
IsNullOrEmpty
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH_COMPATIBLE
)))
{
builder
.
AddJsonFile
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH_COMPATIBLE
),
false
);
}
if
(!
string
.
IsNullOrEmpty
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH
)))
{
builder
.
AddJsonFile
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH
),
false
);
}
builder
.
AddEnvironmentVariables
();
_configuration
=
builder
.
Build
();
_configuration
=
factory
.
Create
();
}
public
T
Get
<
T
>()
where
T
:
class
,
new
()
...
...
@@ -72,7 +47,9 @@ namespace SkyApm.Utilities.Configuration
return
_configuration
.
GetSection
(
config
.
GetSections
()).
GetValue
<
T
>(
key
);
}
//hign performance
/// <summary>
/// high performance
/// </summary>
private
static
class
New
<
T
>
where
T
:
new
()
{
public
static
readonly
Func
<
T
>
Instance
=
Expression
.
Lambda
<
Func
<
T
>>
...
...
src/SkyApm.Utilities.Configuration/ConfigurationFactory.cs
0 → 100644
浏览文件 @
d5e6053f
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM 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.
*
*/
using
System
;
using
System.Collections.Generic
;
using
Microsoft.Extensions.Configuration
;
// ReSharper disable StringLiteralTypo
namespace
SkyApm.Utilities.Configuration
{
public
class
ConfigurationFactory
:
IConfigurationFactory
{
private
const
string
CONFIG_FILE_PATH_COMPATIBLE
=
"SKYWALKING__CONFIG__PATH"
;
private
const
string
CONFIG_FILE_PATH
=
"SKYAPM__CONFIG__PATH"
;
private
readonly
IEnvironmentProvider
_environmentProvider
;
private
readonly
IEnumerable
<
IAdditionalConfigurationSource
>
_additionalConfigurations
;
public
ConfigurationFactory
(
IEnvironmentProvider
environmentProvider
,
IEnumerable
<
IAdditionalConfigurationSource
>
additionalConfigurations
)
{
_environmentProvider
=
environmentProvider
;
_additionalConfigurations
=
additionalConfigurations
;
}
public
IConfiguration
Create
()
{
var
builder
=
new
ConfigurationBuilder
();
builder
.
AddSkyWalkingDefaultConfig
();
builder
.
AddJsonFile
(
"appsettings.json"
,
true
)
.
AddJsonFile
(
$"appsettings.
{
_environmentProvider
.
EnvironmentName
}
.json"
,
true
);
builder
.
AddJsonFile
(
"skywalking.json"
,
true
)
.
AddJsonFile
(
$"skywalking.
{
_environmentProvider
.
EnvironmentName
}
.json"
,
true
);
builder
.
AddJsonFile
(
"skyapm.json"
,
true
)
.
AddJsonFile
(
$"skyapm.
{
_environmentProvider
.
EnvironmentName
}
.json"
,
true
);
if
(!
string
.
IsNullOrEmpty
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH_COMPATIBLE
)))
{
builder
.
AddJsonFile
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH_COMPATIBLE
),
false
);
}
if
(!
string
.
IsNullOrEmpty
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH
)))
{
builder
.
AddJsonFile
(
Environment
.
GetEnvironmentVariable
(
CONFIG_FILE_PATH
),
false
);
}
builder
.
AddEnvironmentVariables
();
foreach
(
var
additionalConfiguration
in
_additionalConfigurations
)
{
additionalConfiguration
.
Load
(
builder
);
}
return
builder
.
Build
();
}
}
}
\ No newline at end of file
src/SkyApm.Utilities.Configuration/IAdditionalConfigurationSource.cs
0 → 100644
浏览文件 @
d5e6053f
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM 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.
*
*/
using
Microsoft.Extensions.Configuration
;
namespace
SkyApm.Utilities.Configuration
{
public
interface
IAdditionalConfigurationSource
{
void
Load
(
ConfigurationBuilder
builder
);
}
}
\ No newline at end of file
src/SkyApm.Utilities.Configuration/IConfigurationFactory.cs
0 → 100644
浏览文件 @
d5e6053f
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM 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.
*
*/
using
Microsoft.Extensions.Configuration
;
namespace
SkyApm.Utilities.Configuration
{
public
interface
IConfigurationFactory
{
IConfiguration
Create
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录