Skip to content

Commit 28049d9

Browse files
authored
Merge pull request #151 from DataDog/v0.3.0
v0.3.0
2 parents 8977d04 + df78b93 commit 28049d9

36 files changed

+1799
-106
lines changed

.circleci/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
image: redis:4.0-alpine
3232
- &mongo
3333
image: mongo:3.6
34+
- &elasticsearch
35+
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
36+
- &rabbitmq
37+
image: rabbitmq:3.6-alpine
3438
working_directory: ~/dd-trace-js
3539
steps:
3640
- checkout
@@ -54,6 +58,8 @@ jobs:
5458
- *mysql
5559
- *redis
5660
- *mongo
61+
- *elasticsearch
62+
- *rabbitmq
5763
build-node-6:
5864
<<: *node-base
5965
docker:
@@ -62,6 +68,8 @@ jobs:
6268
- *mysql
6369
- *redis
6470
- *mongo
71+
- *elasticsearch
72+
- *rabbitmq
6573
build-node-8:
6674
<<: *node-base
6775
docker:
@@ -70,6 +78,8 @@ jobs:
7078
- *mysql
7179
- *redis
7280
- *mongo
81+
- *elasticsearch
82+
- *rabbitmq
7383
build-node-latest:
7484
<<: *node-base
7585
docker:
@@ -78,6 +88,8 @@ jobs:
7888
- *mysql
7989
- *redis
8090
- *mongo
91+
- *elasticsearch
92+
- *rabbitmq
8193

8294
workflows:
8395
version: 2

LICENSE-3rdparty.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require,cls-hooked,BSD-2-Clause,Copyright 2013-2016 Forrest L Norvell
44
require,continuation-local-storage,BSD-2-Clause,Copyright 2013-2016 Forrest L Norvell
55
require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
66
require,koalas,MIT,Copyright 2013-2017 Brian Woodward
7+
require,lodash.kebabcase,MIT,Copyright JS Foundation and other contributors
78
require,methods,MIT,Copyright 2013-2014 TJ Holowaychuk 2013-2014 TJ Holowaychuk
89
require,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
910
require,opentracing,MIT,Copyright 2016 Resonance Labs Inc
@@ -16,11 +17,13 @@ require,require-in-the-middle,MIT,Copyright 2016-2018 Thomas Watson Steen
1617
require,safe-buffer,MIT,Copyright Feross Aboukhadijeh
1718
require,shimmer,BSD-2-Clause,Copyright Forrest L Norvell
1819
require,url-parse,MIT,Copyright 2015 Unshift.io Arnout Kazemier the Contributors
20+
dev,amqplib,MIT,Copyright 2013-2014 Michael Bridgen
1921
dev,axios,MIT,Copyright 2014-present Matt Zabriskie
2022
dev,benchmark,MIT,Copyright 2010-2016 Mathias Bynens Robert Kieffer John-David Dalton
2123
dev,bluebird,MIT,Copyright 2013-2018 Petka Antonov
2224
dev,body-parser,MIT,Copyright 2014 Jonathan Ong 2014-2015 Douglas Christopher Wilson
2325
dev,chai,MIT,Copyright 2017 Chai.js Assertion Library
26+
dev,elasticsearch,Apache-2.0,Copyright 2013 Elasticsearch BV
2427
dev,eslint,MIT,Copyright JS Foundation and other contributors https://js.foundation
2528
dev,eslint-config-standard,MIT,Copyright Feross Aboukhadijeh
2629
dev,eslint-plugin-import,MIT,Copyright 2015 Ben Mosher
@@ -29,6 +32,7 @@ dev,eslint-plugin-promise,ISC,jden and other contributors
2932
dev,eslint-plugin-standard,MIT,Copyright 2015 Jamund Ferguson
3033
dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
3134
dev,get-port,MIT,Copyright Sindre Sorhus
35+
dev,graphql,MIT,Copyright 2015-present Facebook Inc.
3236
dev,gulp,MIT,Copyright 2013-2017 Blaine Bublitz Eric Schoffstall and other contributors
3337
dev,gulp-jsdoc3,Apache-2.0,Copyright Marc Udoff
3438
dev,jsdoc,Apache-2.0,Copyright 2011-present Michael Mathews and the contributors to JSDoc

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ services:
2121
image: mongo:3.6
2222
ports:
2323
- "127.0.0.1:27017:27017"
24+
elasticsearch:
25+
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
26+
ports:
27+
- "127.0.0.1:9200:9200"
28+
rabbitmq:
29+
image: rabbitmq:3.6-alpine
30+
ports:
31+
- "127.0.0.1:5672:5672"

docs/API.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,65 @@ tracer.use('pg', {
101101

102102
Each integration also has its own list of default tags. These tags get automatically added to the span created by the integration.
103103

104+
<h3 id="amqplib">amqplib</h3>
105+
106+
<h5 id="amqplib-tags">Tags</h5>
107+
108+
| Tag | Description |
109+
|------------------|-----------------------------------------------------------|
110+
| out.host | The host of the AMQP server. |
111+
| out.port | The port of the AMQP server. |
112+
| span.kind | Set to either `producer` or `consumer` where it applies. |
113+
| amqp.queue | The queue targeted by the command (when available). |
114+
| amqp.exchange | The exchange targeted by the command (when available). |
115+
| amqp.routingKey | The routing key targeted by the command (when available). |
116+
| amqp.consumerTag | The consumer tag (when available). |
117+
| amqp.source | The source exchange of the binding (when available). |
118+
| amqp.destination | The destination exchange of the binding (when available). |
119+
120+
<h5 id="amqplib-config">Configuration Options</h5>
121+
122+
| Option | Default | Description |
123+
|------------------|---------------------------|----------------------------------------|
124+
| service | *Service name of the app* | The service name for this integration. |
125+
126+
<h5 id="amqplib-limitations">Known Limitations</h5>
127+
128+
When consuming messages, the current span will be immediately finished. This means that if any asynchronous operation is started in the message handler callback, its duration will be excluded from the span duration.
129+
130+
For example:
131+
132+
```js
133+
channel.consume('queue', msg => {
134+
setTimeout(() => {
135+
// The message span will not include the 1 second from this operation.
136+
}, 1000)
137+
}, {}, () => {})
138+
```
139+
140+
This limitation doesn't apply to other commands. We are working on improving this behavior in a future version.
141+
142+
<h3 id="elasticsearch">elasticsearch</h3>
143+
144+
<h5 id="elasticsearch-tags">Tags</h5>
145+
146+
| Tag | Description |
147+
|----------------------|-------------------------------------------------------|
148+
| db.type | Always set to `elasticsearch`. |
149+
| out.host | The host of the Elasticsearch server. |
150+
| out.port | The port of the Elasticsearch server. |
151+
| span.kind | Always set to `client`. |
152+
| elasticsearch.method | The underlying HTTP request verb. |
153+
| elasticsearch.url | The underlying HTTP request URL path. |
154+
| elasticsearch.body | The body of the query. |
155+
| elasticsearch.params | The parameters of the query. |
156+
157+
<h5 id="elasticsearch-config">Configuration Options</h5>
158+
159+
| Option | Default | Description |
160+
|------------------|------------------|----------------------------------------|
161+
| service | elasticsearch | The service name for this integration. |
162+
104163
<h3 id="express">express</h3>
105164

106165
<h5 id="express-tags">Tags</h5>
@@ -117,6 +176,38 @@ Each integration also has its own list of default tags. These tags get automatic
117176
|------------------|---------------------------|----------------------------------------|
118177
| service | *Service name of the app* | The service name for this integration. |
119178

179+
<h3 id="graphql">graphql</h3>
180+
181+
The `graphql` integration uses the operation name as the span resource name. If no operation name is set, the resource name will always be just `query` or `mutation`.
182+
183+
For example:
184+
185+
```graphql
186+
# good, the resource name will be `query HelloWorld`
187+
query HelloWorld {
188+
hello
189+
world
190+
}
191+
192+
# bad, the resource name will be `query`
193+
{
194+
hello
195+
world
196+
}
197+
```
198+
199+
<h5 id="graphql-tags">Tags</h5>
200+
201+
| Tag | Description |
202+
|------------------|-----------------------------------------------------------|
203+
| graphql.document | The original GraphQL document. |
204+
205+
<h5 id="graphql-config">Configuration Options</h5>
206+
207+
| Option | Default | Description |
208+
|---------|--------------------------------------------------|----------------------------------------|
209+
| service | *Service name of the app suffixed with -graphql* | The service name for this integration. |
210+
120211
<h3 id="http">http / https</h3>
121212

122213
<h5 id="http-tags">Tags</h5>
@@ -233,7 +324,7 @@ Options can be configured as a parameter to the [init()](https://datadog.github.
233324
| tags | | {} | Set global tags that should be applied to all spans. |
234325
| sampleRate | | 1 | Percentage of spans to sample as a float between 0 and 1. |
235326
| flushInterval | | 2000 | Interval in milliseconds at which the tracer will submit traces to the agent. |
236-
| experimental | | {} | Experimental features can be enabled all at once using boolean `true` or individually using key/value pairs. Available experimental features: `asyncHooks`. |
327+
| experimental | | {} | Experimental features can be enabled all at once using boolean `true` or individually using key/value pairs. There are currently no experimental features available. |
237328
| plugins | | true | Whether or not to enable automatic instrumentation of external libraries using the built-in plugins. |
238329

239330
<h3 id="custom-logging">Custom Logging</h3>

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = '0.2.1'
1+
module.exports = '0.3.0'

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dd-trace",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "Datadog APM tracing client for JavaScript (experimental)",
55
"main": "index.js",
66
"scripts": {
@@ -29,14 +29,15 @@
2929
},
3030
"homepage": "https://github.com/DataDog/dd-trace-js#readme",
3131
"engines": {
32-
"node": ">=4"
32+
"node": ">=4.7"
3333
},
3434
"dependencies": {
3535
"cls-bluebird": "^2.1.0",
3636
"cls-hooked": "^4.2.2",
3737
"continuation-local-storage": "^3.2.1",
3838
"int64-buffer": "^0.1.9",
3939
"koalas": "^1.0.2",
40+
"lodash.kebabcase": "^4.1.1",
4041
"methods": "^1.1.2",
4142
"msgpack-lite": "^0.1.26",
4243
"opentracing": "0.14.1",
@@ -52,11 +53,13 @@
5253
"url-parse": "^1.2.0"
5354
},
5455
"devDependencies": {
56+
"amqplib": "^0.5.2",
5557
"axios": "^0.18.0",
5658
"benchmark": "^2.1.4",
5759
"bluebird": "^3.5.1",
5860
"body-parser": "^1.18.2",
5961
"chai": "^4.1.2",
62+
"elasticsearch": "^15.0.0",
6063
"eslint": "^4.15.0",
6164
"eslint-config-standard": "^11.0.0-beta.0",
6265
"eslint-plugin-import": "^2.8.0",
@@ -65,6 +68,7 @@
6568
"eslint-plugin-standard": "^3.0.1",
6669
"express": "^4.16.2",
6770
"get-port": "^3.2.0",
71+
"graphql": "^0.13.2",
6872
"gulp": "^3.9.1",
6973
"gulp-jsdoc3": "^2.0.0",
7074
"jsdoc": "^3.5.5",

scripts/helpers/color.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict'
2+
3+
// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
4+
module.exports = {
5+
GRAY: '\\033[1;90m',
6+
CYAN: '\\033[1;36m',
7+
NONE: '\\033[0m'
8+
}

scripts/helpers/exec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
3+
const execSync = require('child_process').execSync
4+
const color = require('./color')
5+
6+
function exec (command, options) {
7+
options = Object.assign({ stdio: [0, 1, 2] }, options)
8+
9+
execSync(`echo "${color.GRAY}$ ${command}${color.NONE}"`, options)
10+
execSync(command, options)
11+
}
12+
13+
module.exports = exec

scripts/helpers/title.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict'
2+
3+
const exec = require('child_process').execSync
4+
const color = require('./color')
5+
6+
function title (str) {
7+
const options = { stdio: [0, 1, 2] }
8+
const line = ''.padStart(str.length, '=')
9+
10+
exec(`echo "${color.CYAN}${line}${color.NONE}"`, options)
11+
exec(`echo "${color.CYAN}${str}${color.NONE}"`, options)
12+
exec(`echo "${color.CYAN}${line}${color.NONE}"`, options)
13+
}
14+
15+
module.exports = title

scripts/publish_docs.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict'
2+
3+
const fs = require('fs')
4+
const exec = require('./helpers/exec')
5+
const title = require('./helpers/title')
6+
7+
title(`Publishing API documentation to GitHub Pages`)
8+
9+
const msg = process.argv[2]
10+
11+
if (!msg) {
12+
throw new Error('Please provide a reason for the change. Example: node scripts/publish_docs.js "fix typo"')
13+
}
14+
15+
if (fs.existsSync('yarn.lock')) {
16+
exec('yarn')
17+
} else {
18+
exec('npm install')
19+
}
20+
21+
exec('rm -rf ./out')
22+
exec('git clone -b gh-pages --single-branch [email protected]:DataDog/dd-trace-js.git out')
23+
exec('npm run jsdoc')
24+
exec('git add -A', { cwd: './out' })
25+
exec(`git commit -m "${msg}"`, { cwd: './out' })
26+
exec('git push', { cwd: './out' })

0 commit comments

Comments
 (0)