首先下载buterfly release版本 git
解压并经过命令启动:dotnet Butterfly.Web.dll --EnableHttpCollector=truegithub
能够采用bat文件的方式 web
cd C:\Users\Lenovo\Desktop\butterfly-web-preview-0.0.8 dotnet Butterfly.Web.dll --EnableHttpCollector=true
其中进入路径须要自行替换 json
测试demo中 12.0和 7.0 使用方法不彻底一致 app
7.0的ocelot 使用时 只须要在 startup中的 ConfigureServices 测试
添加以下代码this
services.AddOcelot(Configuration) .AddOpenTracing(option => { //this is the url that the butterfly collector server is running on... option.CollectorUrl = "http://192.168.66.241:9618"; option.Service = "Ocelot"; });
而 12.0 的时候若是这么写 会出现 找不到AddOpenTracing 方法的问题 url
须要添加nuget包 Butterfly.Client.AspNetCore spa
引用0.0.8时可能会出现没法追踪到请求的问题 引用0.0.7时 可能出现 依赖视图没法显示问题 具体使用哪一个须要自行权衡日志
使用代码依然在startup中配置
services.AddButterfly(option => { //增长日志 //this is the url that the butterfly collector server is running on... option.CollectorUrl = Configuration.GetSection("Setting:Butterfly:CollectorUrl").Value; option.Service = Configuration.GetSection("Setting:Butterfly:Service").Value; });
而后在appsettings.json 中加入
//Butterfly日志追踪 "Butterfly": { "CollectorUrl": "http://localhost:9618", //追踪地址 "Service": "OcelotButterfly" //显示名称 }
如图 :
最后在 configuration.json 中 ReRoutes内
为每一个服务 增长内容
"HttpHandlerOptions": { "UseTracing": true // use butterfly to tracing request chain }
如图所示:
访问 http://localhost:9618便可