-
Notifications
You must be signed in to change notification settings - Fork 146
add skywalking-client-js in action #170
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
Changes from all commits
be4c482
4598019
f823856
8913e14
9bdec87
60dbc94
b08b31e
a705115
fb0e3e9
544bb79
365539b
06aaa69
4279848
7e4273f
28366e3
26db3ac
e60ab80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| title: SkyWalking-client-js实战体验 | ||
| date: 2020-12-13 | ||
| author: tristan-tsl | ||
| description: 本文将详细介绍如何使用SkyWalking监控前端项目的页面加载情况及错误日志 | ||
| --- | ||
|
|
||
|
|
||
|
|
||
| 首先我们前端项目是通过Nginx代理出来。我们需要修改Nginx添加SkyWalking-OAP端点, 让SkyWalking-OAP可以被浏览器访问到。我们的Nginx配置如下(Ingress-Nginx暂略) | ||
|
|
||
| ``` | ||
| location /browser { | ||
| proxy_pass http://<your_skywalking_oap_ip>:12800; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| } | ||
| ``` | ||
|
Comment on lines
+12
to
+18
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 文章示例代码格式不规整。 |
||
|
|
||
| 前端项目需要安装一下SkyWalking依赖: | ||
|
|
||
| ``` | ||
| npm install skywalking-client-js --save | ||
| ``` | ||
|
|
||
| 每一个项目的package.json中的name都要用项目名称且不能与其他项目重复, version尽量保持有意义 | ||
|
|
||
| 在路由/公共js中调整添加如下内容 | ||
|
|
||
| 注意: router.beforeEach在实际项目中最好只声明一次 | ||
|
|
||
| ``` | ||
| import ClientMonitor from 'skywalking-client-js' | ||
|
|
||
| const router = createRouter() // 在router创建之后 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const package_json = require('../../package.json') | ||
| const set_skywalking_monitor = async function(to, from, next) { | ||
| const skywalking_config = { | ||
| service: package_json.name, | ||
| serviceVersion: package_json.version, | ||
| pagePath: location.href.substring(0, location.href.indexOf('#') + 1) + to.path, | ||
| jsErrors: true, | ||
| apiErrors: true, | ||
| resourceErrors: true, | ||
| useFmp: true, | ||
| enableSPA: true, | ||
| autoTracePerf: true | ||
| } | ||
| try { | ||
| ClientMonitor.register(skywalking_config) | ||
| ClientMonitor.setPerformance(skywalking_config) | ||
| } catch (e) { | ||
| console.log(e) | ||
| } | ||
| next() | ||
| } | ||
| router.beforeEach(set_skywalking_monitor) | ||
| ``` | ||
|
|
||
| 效果: | ||
|
|
||
| 目前能看到各个系统的前端页面访问记录的时间 | ||
|
|
||
| 控制台的打印日志 | ||
|
|
||
|  | ||
|
|
||
|  | ||
|
|
||
|  | ||
|
|
||
| 参考文档: | ||
|
|
||
| https://github.com/apache/skywalking-client-js | ||
|
|
||
| 谢谢观看, 后续我会在SkyWalking-client-js这块写更多实战文章 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议删除此句。 |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请补充项目部署架构图,明确这句话的背景。