Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周奇琪
9 years ago
Commit
3860bbec726f8e99871b71e9b9b756f11b398940
1 parent
0a9db220
加oneapm的监控
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
5 deletions
.gitignore
app.js
config/common.js
oneapm.js
package.json
test/library/timer.test.js
.gitignore
View file @
3860bbe
...
...
@@ -139,3 +139,4 @@ public/css/*
public/bundle/*
.eslintcache
*.log.*
.vscode/
...
...
app.js
View file @
3860bbe
...
...
@@ -5,15 +5,19 @@
*/
'use strict'
;
const
config
=
require
(
'./config/common'
);
// use one apm
if
(
config
.
useOneapm
)
{
require
(
'oneapm'
);
}
let
express
=
require
(
'express'
),
path
=
require
(
'path'
),
bodyParser
=
require
(
'body-parser'
),
cookieParser
=
require
(
'cookie-parser'
),
favicon
=
require
(
'serve-favicon'
);
require
(
'express-handlebars'
);
let
app
=
express
();
app
.
set
(
'view engine'
,
'.hbs'
);
...
...
config/common.js
View file @
3860bbe
...
...
@@ -7,6 +7,7 @@
const
isProduction
=
process
.
env
.
NODE_ENV
===
'production'
;
const
isTest
=
process
.
env
.
NODE_ENV
===
'test'
;
module
.
exports
=
{
domains
:
{
...
...
@@ -14,6 +15,7 @@ module.exports = {
service
:
'http://testservice.yoho.cn:28077'
,
search
:
'http://192.168.10.64:8080/yohosearch/'
},
useOneapm
:
false
,
loggers
:
{
infoFile
:
{
name
:
'info'
,
...
...
@@ -41,5 +43,12 @@ module.exports = {
if
(
isProduction
)
{
Object
.
assign
(
module
.
exports
,
{
appName
:
'www.yohobuy.com'
,
useOneapm
:
true
});
}
else
if
(
isTest
)
{
Object
.
assign
(
module
.
exports
,
{
appName
:
'www.yohobuy.com for test'
,
useOneapm
:
true
});
}
...
...
oneapm.js
0 → 100644
View file @
3860bbe
// use for app name
const
commonConfig
=
require
(
'./config/common'
);
/**
* OneAPM agent configuration.
*
* See lib/config.defaults.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports
.
config
=
{
/**
* Array of application names.
*/
app_name
:
[
commonConfig
.
appName
],
// eslint-disable-line
/**
* Your OneAPM license key.
*/
license_key
:
'BwEGA1dRDlQ6357HHQ1AD1xJVkbc9fNfWRtQUwhQG41c5QFWGFIDSQoHc0e8AgMaUlcUVw0='
,
// eslint-disable-line
logging
:
{
// eslint-disable-line
/**
* Level at which to log. 'trace' is most useful to OneAPM when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
*/
level
:
'info'
// eslint-disable-line
},
transaction_events
:
{
// eslint-disable-line
enabled
:
true
// eslint-disable-line
}
};
...
...
package.json
View file @
3860bbe
...
...
@@ -26,6 +26,7 @@
"lodash"
:
"^4.12.0"
,
"md5"
:
"^2.1.0"
,
"morgan"
:
"^1.7.0"
,
"oneapm"
:
"^1.2.20"
,
"request-promise"
:
"^3.0.0"
,
"serve-favicon"
:
"^2.3.0"
,
"winston"
:
"^2.2.0"
,
...
...
test/library/timer.test.js
View file @
3860bbe
...
...
@@ -2,12 +2,14 @@ let expect = require('expect.js');
let
Timer
=
require
(
'../../library/timer'
);
describe
(
'/library/timer'
,
function
()
{
it
(
'延迟100ms,期望大于或等于100ms'
,
function
(
done
)
{
describe
(
'/library/timer'
,
function
()
{
// eslint-disable-line
it
(
'延迟100ms,期望大于或等于100ms'
,
function
(
done
)
{
// eslint-disable-line
let
t
=
new
Timer
();
t
.
put
(
'aa'
);
setTimeout
(
function
()
{
let
time
=
t
.
put
(
'aa'
);
expect
(
Math
.
round
(
time
)
>=
100
).
to
.
be
.
ok
();
done
();
},
100
);
...
...
Please
register
or
login
to post a comment