Skip to content

Commit 511e65a

Browse files
authored
Merge branch 'master' into renamed-hapi
2 parents 6ad9c6c + e72679a commit 511e65a

File tree

8 files changed

+152
-18
lines changed

8 files changed

+152
-18
lines changed

.ci/docker/docker-compose-node-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
PGUSER: 'postgres'
2222
NODE_VERSION: ${NODE_VERSION}
2323
TAV: ${TAV_VERSIONS}
24+
ELASTIC_APM_ASYNC_HOOKS: ${ELASTIC_APM_ASYNC_HOOKS}
2425
HOME: /tmp
2526
PATH: /app/node_modules/.bin:./node_modules/.bin:/app/node_modules:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
2627
volumes:

.ci/scripts/get_tav.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
## Given the git SHA it will parse the git log and search for any changes in any
3+
## files under lib/instrumentation/modules/* or test/instrumentation/modules/*
4+
## and will create a YAML file with the list of TAVs.
5+
set -xuo pipefail
6+
7+
OUTPUT=$1
8+
9+
GIT_DIFF=git-diff.txt
10+
CHANGES=changes.txt
11+
12+
cleanup() {
13+
rm -f ${CHANGES} ${GIT_DIFF} || true
14+
}
15+
trap cleanup EXIT
16+
17+
if [[ -n "${CHANGE_TARGET}" ]] && [[ -n "${GIT_SHA}" ]] ; then
18+
19+
git diff --name-only origin/"${CHANGE_TARGET}"..."${GIT_SHA}" > ${GIT_DIFF}
20+
21+
grep 'lib/instrumentation/modules' ${GIT_DIFF}| sed 's#lib/instrumentation/modules/##g' > ${CHANGES}
22+
grep 'test/instrumentation/modules' ${GIT_DIFF} | sed 's#test/instrumentation/modules/##g' >> ${CHANGES}
23+
24+
if [[ $(wc -l <${CHANGES}) -gt 0 ]]; then
25+
sed -iback 's#/.*##g; s#^/##g; s#\..*##g' ${CHANGES}
26+
27+
## Generate the file with the content
28+
echo 'TAV:' > "${OUTPUT}"
29+
while read -r tav; do
30+
echo " - $tav" >> "${OUTPUT}"
31+
done <${CHANGES}
32+
fi
33+
fi

.travis.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,23 @@ services:
1515
- redis-server
1616
- postgresql
1717
- cassandra
18+
19+
cache:
20+
directories:
21+
- deb-cache
22+
23+
env:
24+
global:
25+
- ELASTICSEARCH_DEB_VERSION=6.6.0
26+
- ELASTICSEARCH_DEB_PACKAGE=elasticsearch-${ELASTICSEARCH_DEB_VERSION}.deb
1827

1928
before_install:
20-
- curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.deb && sudo dpkg -i --force-confnew elasticsearch-6.6.0.deb && sudo service elasticsearch restart
29+
- |
30+
if [ ! -f ./deb-cache/$ELASTICSEARCH_DEB_PACKAGE ]
31+
then
32+
curl -o ./deb-cache/$ELASTICSEARCH_DEB_PACKAGE https://artifacts.elastic.co/downloads/elasticsearch/$ELASTICSEARCH_DEB_PACKAGE
33+
fi
34+
- sudo dpkg -i --force-confnew ./deb-cache/$ELASTICSEARCH_DEB_PACKAGE && sudo service elasticsearch restart
2135

2236
install:
2337
- for i in {1..3}; do travis_wait 5 npm install && break; rm -rf node_modules; done

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.13.0 - 2019/7/30
2+
* fix: standardize user-agent header ([#1238](https://elastic/apm-agent-nodejs/pull/1238))
3+
* feat: add support for APM Agent Configuration via Kibana ([#1197](https://elastic/apm-agent-nodejs/pull/1197))
4+
* feat(metrics): breakdown graphs ([#1219](https://elastic/apm-agent-nodejs/pull/1219))
5+
* feat(config): default serviceVersion to package version ([#1237](https://elastic/apm-agent-nodejs/pull/1237))
6+
17
# 2.12.1 - 2019/7/7
28
* fix(knex): abort early on unsupported version of knex ([#1189](https://github.com/elastic/apm-agent-nodejs/pull/1189))
39

Jenkinsfile

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ pipeline {
2424
quietPeriod(10)
2525
}
2626
triggers {
27-
issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*')
27+
issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?(?:module\\W+)?tests(?:\\W+please)?.*')
2828
}
2929
parameters {
3030
booleanParam(name: 'Run_As_Master_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on master branch.')
3131
booleanParam(name: 'tav_ci', defaultValue: true, description: 'Enable TAV tests.')
32+
booleanParam(name: 'tests_ci', defaultValue: true, description: 'Enable tests.')
3233
booleanParam(name: 'test_edge_ci', defaultValue: true, description: 'Enable tests for edge versions of nodejs.')
3334
}
3435
stages {
@@ -42,6 +43,15 @@ pipeline {
4243
deleteDir()
4344
gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true)
4445
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
46+
script {
47+
dir("${BASE_DIR}"){
48+
def regexps =[
49+
"^lib/instrumentation/modules/",
50+
"^test/instrumentation/modules/"
51+
]
52+
env.TAV_UPDATED = isGitRegionMatch(regexps: regexps)
53+
}
54+
}
4555
}
4656
}
4757
/**
@@ -74,6 +84,10 @@ pipeline {
7484
environment {
7585
HOME = "${env.WORKSPACE}"
7686
}
87+
when {
88+
beforeAgent true
89+
expression { return params.tests_ci }
90+
}
7791
steps {
7892
withGithubNotify(context: 'Test', tab: 'tests') {
7993
deleteDir()
@@ -87,10 +101,17 @@ pipeline {
87101
script {
88102
def node = readYaml(file: '.ci/.jenkins_nodejs.yml')
89103
def parallelTasks = [:]
104+
def parallelTasksWithoutAsyncHooks = [:]
90105
node['NODEJS_VERSION'].each{ version ->
91106
parallelTasks["Node.js-${version}"] = generateStep(version: version)
107+
parallelTasksWithoutAsyncHooks["Node.js-${version}-async-hooks-false"] = generateStep(version: version)
92108
}
109+
110+
env.ELASTIC_APM_ASYNC_HOOKS = "true"
93111
parallel(parallelTasks)
112+
113+
env.ELASTIC_APM_ASYNC_HOOKS = "false"
114+
parallel(parallelTasksWithoutAsyncHooks)
94115
}
95116
}
96117
}
@@ -115,21 +136,21 @@ pipeline {
115136
expression { return params.Run_As_Master_Branch }
116137
triggeredBy 'TimerTrigger'
117138
changeRequest()
139+
expression { return env.TAV_UPDATED != "false" }
118140
}
119141
expression { return params.tav_ci }
120142
}
121143
}
122144
steps {
123-
withGithubNotify(context: 'TAV Test', tab: 'tests') {
124-
deleteDir()
125-
unstash 'source'
126-
dir("${BASE_DIR}"){
127-
script {
128-
def node = readYaml(file: '.ci/.jenkins_tav_nodejs.yml')
129-
def tav = readYaml(file: '.ci/.jenkins_tav.yml')
145+
deleteDir()
146+
unstash 'source'
147+
dir("${BASE_DIR}"){
148+
script {
149+
def tavContext = getSmartTAVContext()
150+
withGithubNotify(context: tavContext.ghContextName, description: tavContext.ghDescription, tab: 'tests') {
130151
def parallelTasks = [:]
131-
node['NODEJS_VERSION'].each{ version ->
132-
tav['TAV'].each{ tav_item ->
152+
tavContext.node['NODEJS_VERSION'].each{ version ->
153+
tavContext.tav['TAV'].each{ tav_item ->
133154
parallelTasks["Node.js-${version}-${tav_item}"] = generateStep(version: version, tav: tav_item)
134155
}
135156
}
@@ -271,7 +292,13 @@ def generateStep(Map params = [:]){
271292
dir("${BASE_DIR}"){
272293
retry(2){
273294
sleep randomNumber(min:10, max: 30)
274-
sh(label: "Run Tests", script: """.ci/scripts/test.sh "${version}" "${tav}" "${edge}" """)
295+
if (version?.startsWith('6')) {
296+
catchError {
297+
sh(label: 'Run Tests', script: """.ci/scripts/test.sh "${version}" "${tav}" "${edge}" """)
298+
}
299+
} else {
300+
sh(label: "Run Tests", script: """.ci/scripts/test.sh "${version}" "${tav}" "${edge}" """)
301+
}
275302
}
276303
}
277304
} catch(e){
@@ -286,3 +313,44 @@ def generateStep(Map params = [:]){
286313
}
287314
}
288315
}
316+
317+
/**
318+
* Gather the TAV context for the current execution. Then the TAV stage will execute
319+
* the TAV using a smarter approach.
320+
*/
321+
def getSmartTAVContext() {
322+
context = [:]
323+
context.ghContextName = 'TAV Test'
324+
context.ghDescription = context.ghContextName
325+
context.node = readYaml(file: '.ci/.jenkins_tav_nodejs.yml')
326+
327+
if (env.GITHUB_COMMENT) {
328+
def modules = getModulesFromCommentTrigger(regex: '(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?module\\W+tests\\W+for\\W+(.+)')
329+
if (modules.isEmpty()) {
330+
context.ghDescription = 'TAV Test disabled'
331+
context.tav = readYaml(text: 'TAV:')
332+
context.node = readYaml(text: 'NODEJS_VERSION:')
333+
} else {
334+
if (modules.find{ it == 'ALL' }) {
335+
context.tav = readYaml(file: '.ci/.jenkins_tav.yml')
336+
} else {
337+
context.ghContextName = 'TAV Test Subset'
338+
context.ghDescription = 'TAV Test comment-triggered'
339+
context.tav = readYaml(text: """TAV:${modules.collect{ "\n - ${it}"}.join("") }""")
340+
}
341+
}
342+
} else if (params.Run_As_Master_Branch) {
343+
context.ghDescription = 'TAV Test param-triggered'
344+
context.tav = readYaml(file: '.ci/.jenkins_tav.yml')
345+
} else if (changeRequest() && env.TAV_UPDATED != "false") {
346+
context.ghContextName = 'TAV Test Subset'
347+
context.ghDescription = 'TAV Test changes-triggered'
348+
sh '.ci/scripts/get_tav.sh .ci/.jenkins_generated_tav.yml'
349+
context.tav = readYaml(file: '.ci/.jenkins_generated_tav.yml')
350+
} else {
351+
context.ghDescription = 'TAV Test disabled'
352+
context.tav = readYaml(text: 'TAV:')
353+
context.node = readYaml(text: 'NODEJS_VERSION:')
354+
}
355+
return context
356+
}

lib/agent.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ Agent.prototype.setCustomContext = function (context) {
201201
}
202202

203203
Agent.prototype.setTag = function (key, value) {
204-
this.logger.warn('Called deprecated method: apm.setTag(...)')
204+
if (!this.setTag._deprecatedLogged) {
205+
this.setTag._deprecatedLogged = true
206+
this.logger.warn('Called deprecated method: apm.setTag(...)')
207+
}
205208
return this.setLabel(key, value)
206209
}
207210

@@ -212,7 +215,10 @@ Agent.prototype.setLabel = function (key, value) {
212215
}
213216

214217
Agent.prototype.addTags = function (tags) {
215-
this.logger.warn('Called deprecated method: apm.addTags(...)')
218+
if (!this.addTags._deprecatedLogged) {
219+
this.addTags._deprecatedLogged = true
220+
this.logger.warn('Called deprecated method: apm.addTags(...)')
221+
}
216222
return this.addLabels(tags)
217223
}
218224

lib/instrumentation/generic-span.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ GenericSpan.prototype.duration = function () {
6565
}
6666

6767
GenericSpan.prototype.setTag = function (key, value) {
68-
this._agent.logger.warn(`Called deprecated method: ${this.constructor.name.toLowerCase()}.setTag(...)`)
68+
if (!this.setTag._deprecatedLogged) {
69+
this.setTag._deprecatedLogged = true
70+
this._agent.logger.warn(`Called deprecated method: ${this.constructor.name.toLowerCase()}.setTag(...)`)
71+
}
6972
return this.setLabel(key, value)
7073
}
7174

@@ -81,7 +84,10 @@ GenericSpan.prototype.setLabel = function (key, value) {
8184
}
8285

8386
GenericSpan.prototype.addTags = function (tags) {
84-
this._agent.logger.warn(`Called deprecated method: ${this.constructor.name.toLowerCase()}.addTags(...)`)
87+
if (!this.addTags._deprecatedLogged) {
88+
this.addTags._deprecatedLogged = true
89+
this._agent.logger.warn(`Called deprecated method: ${this.constructor.name.toLowerCase()}.addTags(...)`)
90+
}
8591
return this.addLabels(tags)
8692
}
8793

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elastic-apm-node",
3-
"version": "2.12.1",
3+
"version": "2.13.0",
44
"description": "The official Elastic APM agent for Node.js",
55
"main": "index.js",
66
"types": "index.d.ts",
@@ -166,7 +166,7 @@
166166
"typescript": "^3.5.2",
167167
"untildify": "^4.0.0",
168168
"util.promisify": "^1.0.0",
169-
"wait-on": "^3.1.0",
169+
"wait-on": "3.2.0",
170170
"ws": "^7.0.1"
171171
},
172172
"greenkeeper": {

0 commit comments

Comments
 (0)