Skip to content

Commit 8423307

Browse files
committed
Merge branch 'master' into v2-api
2 parents 061c48e + 69448f5 commit 8423307

File tree

6 files changed

+59
-6
lines changed

6 files changed

+59
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 1.10.1 - 2018/7/31
2+
* fix(graphql): handle execute args object (#484)
3+
4+
# 1.10.0 - 2018/7/30
5+
* feat(cassandra): instrument Cassandra queries (#437)
6+
* feat(mssql): instrument SQL Server queries (#444)
7+
18
# 1.9.0 - 2018/7/25
29
* fix(parsers): use basic-auth rather than req.auth (#475)
310
* feat(agent): add currentTransaction getter (#462)

lib/instrumentation/modules/graphql.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module.exports = function (graphql, agent, version, enabled) {
9595
}
9696

9797
function wrapExecute (orig) {
98-
return function wrappedExecute (schema, document, rootValue, contextValue, variableValues, operationName) {
98+
function wrappedExecuteImpl (schema, document, rootValue, contextValue, variableValues, operationName) {
9999
var trans = agent._instrumentation.currentTransaction
100100
var span = agent.buildSpan()
101101
var id = span && span.transaction.id
@@ -135,6 +135,26 @@ module.exports = function (graphql, agent, version, enabled) {
135135
}
136136
return p
137137
}
138+
139+
return function wrappedExecute (argsOrSchema, document, rootValue, contextValue, variableValues, operationName) {
140+
return arguments.length === 1
141+
? wrappedExecuteImpl(
142+
argsOrSchema.schema,
143+
argsOrSchema.document,
144+
argsOrSchema.rootValue,
145+
argsOrSchema.contextValue,
146+
argsOrSchema.variableValues,
147+
argsOrSchema.operationName
148+
)
149+
: wrappedExecuteImpl(
150+
argsOrSchema,
151+
document,
152+
rootValue,
153+
contextValue,
154+
variableValues,
155+
operationName
156+
)
157+
}
138158
}
139159

140160
function extractDetails (document, operationName) {

lib/instrumentation/modules/tedious.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ module.exports = function (tedious, agent, version, enabled) {
4444
return originalMakeRequest.apply(this, arguments)
4545
}
4646

47+
const preparing = request.sqlTextOrProcedure === 'sp_prepare'
4748
const params = request.parametersByName
4849
const sql = (params.statement || params.stmt || {}).value
49-
const name = sqlSummary(sql) + (request.preparing ? ' (prepare)' : '')
50+
const name = sqlSummary(sql) + (preparing ? ' (prepare)' : '')
5051
span.setDbContext({ statement: sql, type: 'sql' })
5152
span.start(name, 'db.mssql.query')
5253

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elastic-apm-node",
3-
"version": "1.9.0",
3+
"version": "1.10.1",
44
"description": "The official Elastic APM agent for Node.js",
55
"main": "index.js",
66
"scripts": {
@@ -152,7 +152,7 @@
152152
]
153153
},
154154
"coordinates": [
155-
55.777395,
156-
12.592147
155+
55.777008,
156+
12.592123
157157
]
158158
}

test/.jenkins_tav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TAV:
22
- generic-pool+mysql+mysql2+redis+koa-router+handlebars+mongodb-core
3-
- ioredis+pg+cassandra-driver
3+
- ioredis+pg+cassandra-driver+tedious
44
- mimic-response+got+bluebird
55
- knex+ws+graphql+express-graphql+elasticsearch+hapi+express+express-queue

test/instrumentation/modules/graphql.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,31 @@ test('graphql.execute', function (t) {
5151
})
5252
})
5353

54+
test('graphql.execute args object', function (t) {
55+
resetAgent(done(t))
56+
57+
var schema = graphql.buildSchema('type Query { hello: String }')
58+
var root = {hello () {
59+
return Promise.resolve('Hello world!')
60+
}}
61+
var query = '{ hello }'
62+
var source = new graphql.Source(query)
63+
var documentAST = graphql.parse(source)
64+
var args = {
65+
schema: schema,
66+
document: documentAST,
67+
rootValue: root
68+
}
69+
70+
agent.startTransaction('foo')
71+
72+
graphql.execute(args).then(function (response) {
73+
agent.endTransaction()
74+
t.deepEqual(response, {data: {hello: 'Hello world!'}})
75+
agent.flush()
76+
})
77+
})
78+
5479
if (semver.satisfies(pkg.version, '>=0.12')) {
5580
test('graphql.execute sync', function (t) {
5681
resetAgent(done(t))

0 commit comments

Comments
 (0)