zhike-zipkin-frontend
v0.0.7
Published
zipkin frontend wrapper for fetch and axios
Downloads
4
Readme
zipkin前端组件
to-do list
- [x] fetch支持
- [x] axios支持
配置
config = {
serviceName: String // 服务名称
}
// 示例
const tracingConfig = {
serviceName: "browser"
}
使用示例
安装
npm i zhike-zipkin-frontend
示例代码
Fetch
const {wrapFetch} = require('zhike-zipkin-frontend');
const zipkinFetch = wrapFetch({serviceName: 'browser'})(fetch);
zipkinFetch('http://localhost:8081/')
.then(response => (response.text()))
.then(text => log(text))
.catch(err => log(`Failed:\n${err.stack}`));
Axios
import { wrapAxios } from 'zhike-zipkin-frontend';
const zipkinAxios = wrapAxios({
zipkinServiceUrl,
serviceName: 'USKid-browser',
})({ request: axios });
常规用法:
zipkinAxios.get('http://localhost:8081/')
.then(response => (response.text()))
.then(text => log(text))
.catch(err => log(`Failed:\n${err.stack}`));
zipkinAxios.get === axios.get;
zipkinAxios.put === axios.put;
zipkinAxios.post === axios.post;
zipkinAxios.del === axios.del;
zipkinAxios.sendRequest(url, config) === axios(config);