Skip to content

Commit 1e9b191

Browse files
author
David Lima
committed
chore(opencensus): update opencensus to remove related warnings
update opencensus to remove uuidv3 package warning and DeprecationWarning: Socket.prototype._handle is deprecated BREAKING CHANGE: need to fix tests, startChildSpan uses a object now, RootSpan was removed may affect keymetrics#274
1 parent b6b1bd7 commit 1e9b191

28 files changed

+127
-122
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
"all": true
8484
},
8585
"dependencies": {
86-
"@opencensus/core": "0.0.9",
87-
"@opencensus/propagation-b3": "0.0.8",
86+
"@opencensus/core": "0.0.22",
87+
"@opencensus/propagation-b3": "0.0.22",
8888
"async": "~2.6.1",
8989
"debug": "~4.3.1",
9090
"eventemitter2": "^6.3.1",

src/census/exporter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Transport } from '../services/transport'
22
import { ServiceManager } from '../serviceManager'
33
import { TracingConfig } from 'src/features/tracing'
4-
import { Exporter, ExporterBuffer, ExporterConfig, RootSpan, Span, SpanKind, Attributes, CanonicalCode } from '@opencensus/core'
4+
import { Exporter, ExporterBuffer, ExporterConfig, Span, SpanKind, Attributes, CanonicalCode } from '@opencensus/core'
55
import { defaultConfig } from './config/default-config'
66
import { Constants } from './constants'
77

@@ -58,19 +58,19 @@ export class CustomCensusExporter implements Exporter {
5858
* Is called whenever a span is ended.
5959
* @param root the ended span
6060
*/
61-
onEndSpan (root: RootSpan) {
61+
onEndSpan (root: Span) {
6262
this.buffer.addToBuffer(root)
6363
}
6464

6565
// tslint:disable-next-line:no-empty
66-
onStartSpan (root: RootSpan) {}
66+
onStartSpan (root: Span) {}
6767

6868
/**
6969
* Send a trace to zipkin service
7070
* @param zipkinTraces Trace translated to Zipkin Service
7171
*/
7272
private sendTraces (zipkinTraces: TranslatedSpan[]) {
73-
return new Promise((resolve, reject) => {
73+
return new Promise<null>((resolve, reject) => {
7474
zipkinTraces.forEach(span => {
7575
const isRootClient = span.kind === 'CLIENT' && !span.parentId
7676
if (isRootClient && this.config.outbound === false) return
@@ -80,15 +80,15 @@ export class CustomCensusExporter implements Exporter {
8080
this.transport.send('trace-span', span)
8181
}
8282
})
83-
resolve()
83+
resolve(null)
8484
})
8585
}
8686

8787
/**
8888
* Mount a list (array) of spans translated to Zipkin format
8989
* @param rootSpans Rootspan array to be translated
9090
*/
91-
private mountSpanList (rootSpans: RootSpan[]): TranslatedSpan[] {
91+
private mountSpanList (rootSpans: Span[]): TranslatedSpan[] {
9292
const spanList: TranslatedSpan[] = []
9393

9494
for (const root of rootSpans) {
@@ -109,7 +109,7 @@ export class CustomCensusExporter implements Exporter {
109109
* @param span Span to be translated
110110
* @param rootSpan Only necessary if the span has rootSpan
111111
*/
112-
private translateSpan (span: Span | RootSpan): TranslatedSpan {
112+
private translateSpan (span: Span | Span): TranslatedSpan {
113113
const spanTranslated = {
114114
traceId: span.traceId,
115115
name: span.name,
@@ -138,7 +138,7 @@ export class CustomCensusExporter implements Exporter {
138138
* Send the rootSpans to zipkin service
139139
* @param rootSpans RootSpan array
140140
*/
141-
publish (rootSpans: RootSpan[]) {
141+
publish (rootSpans: Span[]) {
142142
const spanList = this.mountSpanList(rootSpans)
143143

144144
return this.sendTraces(spanList).catch((err) => {

src/census/plugins/__tests__/express.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { CoreTracer, RootSpan, SpanEventListener, logger } from '@opencensus/core'
17+
import { CoreTracer, Span, SpanEventListener, logger } from '@opencensus/core'
1818
import * as assert from 'assert'
1919
import * as express from 'express'
2020
import * as http from 'http'
@@ -25,12 +25,12 @@ import { AddressInfo } from 'net'
2525

2626
/** Collects ended root spans to allow for later analysis. */
2727
class RootSpanVerifier implements SpanEventListener {
28-
endedRootSpans: RootSpan[] = []
28+
endedRootSpans: Span[] = []
2929

30-
onStartSpan (span: RootSpan): void {
30+
onStartSpan (span: Span): void {
3131
return
3232
}
33-
onEndSpan (root: RootSpan) {
33+
onEndSpan (root: Span) {
3434
this.endedRootSpans.push(root)
3535
}
3636
}

src/census/plugins/__tests__/http.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { CoreTracer, HeaderGetter, HeaderSetter, Propagation, RootSpan, Span, SpanContext, SpanEventListener, logger } from '@opencensus/core'
17+
import { CoreTracer, HeaderGetter, HeaderSetter, Propagation, Span, SpanContext, SpanEventListener, logger } from '@opencensus/core'
1818
import * as assert from 'assert'
1919
import * as http from 'http'
2020
import * as nock from 'nock'
@@ -67,12 +67,12 @@ class DummyPropagation implements Propagation {
6767
}
6868

6969
class RootSpanVerifier implements SpanEventListener {
70-
endedRootSpans: RootSpan[] = []
70+
endedRootSpans: Span[] = []
7171

72-
onStartSpan (span: RootSpan): void {
72+
onStartSpan (span: Span): void {
7373
return
7474
}
75-
onEndSpan (root: RootSpan) {
75+
onEndSpan (root: Span) {
7676
this.endedRootSpans.push(root)
7777
}
7878
}
@@ -195,7 +195,7 @@ describe('HttpPlugin', () => {
195195
const testPath = '/outgoing/rootSpan/childs/1'
196196
doNock(urlHost, testPath, 200, 'Ok')
197197
const options = { name: 'TestRootSpan' }
198-
return tracer.startRootSpan(options, async (root: RootSpan) => {
198+
return tracer.startRootSpan(options, async (root: Span) => {
199199
await httpRequest.get(`${urlHost}${testPath}`).then((result) => {
200200
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
201201
assert.strictEqual(root.spans.length, 1)
@@ -216,7 +216,7 @@ describe('HttpPlugin', () => {
216216
urlHost, testPath, httpErrorCodes[i],
217217
httpErrorCodes[i].toString())
218218
const options = { name: 'TestRootSpan' }
219-
return tracer.startRootSpan(options, async (root: RootSpan) => {
219+
return tracer.startRootSpan(options, async (root: Span) => {
220220
await httpRequest.get(`${urlHost}${testPath}`).then((result) => {
221221
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
222222
assert.strictEqual(root.spans.length, 1)
@@ -237,7 +237,7 @@ describe('HttpPlugin', () => {
237237
const num = 5
238238
doNock(urlHost, testPath, 200, 'Ok', num)
239239
const options = { name: 'TestRootSpan' }
240-
return tracer.startRootSpan(options, async (root: RootSpan) => {
240+
return tracer.startRootSpan(options, async (root: Span) => {
241241
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
242242
for (let i = 0; i < num; i++) {
243243
await httpRequest.get(`${urlHost}${testPath}`).then((result) => {

src/census/plugins/__tests__/http2.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { CoreTracer, RootSpan, Span, SpanEventListener, logger } from '@opencensus/core'
17+
import { CoreTracer, Span, SpanEventListener, logger } from '@opencensus/core'
1818
import * as assert from 'assert'
1919
import * as http2 from 'http2'
2020
import * as semver from 'semver'
@@ -24,12 +24,12 @@ import { plugin, Http2Plugin } from '../http2'
2424
const VERSION = process.versions.node
2525

2626
class RootSpanVerifier implements SpanEventListener {
27-
endedRootSpans: RootSpan[] = []
27+
endedRootSpans: Span[] = []
2828

29-
onStartSpan (root: RootSpan): void {
29+
onStartSpan (root: Span): void {
3030
return
3131
}
32-
onEndSpan (root: RootSpan) {
32+
onEndSpan (root: Span) {
3333
this.endedRootSpans.push(root)
3434
}
3535
}
@@ -168,7 +168,7 @@ describe('Http2Plugin', () => {
168168
const requestOptions = { ':method': 'GET', ':path': testPath }
169169
const options = { name: 'TestRootSpan' }
170170

171-
return tracer.startRootSpan(options, async (root: RootSpan) => {
171+
return tracer.startRootSpan(options, async (root: Span) => {
172172
await http2Request.get(client, requestOptions).then((result) => {
173173
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
174174
assert.strictEqual(root.spans.length, 1)
@@ -189,7 +189,7 @@ describe('Http2Plugin', () => {
189189
const requestOptions = { ':method': 'GET', ':path': testPath }
190190
const options = { name: 'TestRootSpan' }
191191

192-
return tracer.startRootSpan(options, async (root: RootSpan) => {
192+
return tracer.startRootSpan(options, async (root: Span) => {
193193
await http2Request.get(client, requestOptions).then((result) => {
194194
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
195195
assert.strictEqual(root.spans.length, 1)
@@ -211,7 +211,7 @@ describe('Http2Plugin', () => {
211211
const num = 5
212212
const options = { name: 'TestRootSpan' }
213213

214-
return tracer.startRootSpan(options, async (root: RootSpan) => {
214+
return tracer.startRootSpan(options, async (root: Span) => {
215215
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
216216
for (let i = 0; i < num; i++) {
217217
await http2Request.get(client, requestOptions).then((result) => {

src/census/plugins/__tests__/https.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { CoreTracer, RootSpan, Span, SpanEventListener, logger } from '@opencensus/core'
17+
import { CoreTracer, Span, SpanEventListener, logger } from '@opencensus/core'
1818
import * as assert from 'assert'
1919
import * as fs from 'fs'
2020
import * as https from 'https'
@@ -64,12 +64,12 @@ const httpRequest = {
6464
const VERSION = process.versions.node
6565

6666
class RootSpanVerifier implements SpanEventListener {
67-
endedRootSpans: RootSpan[] = []
67+
endedRootSpans: Span[] = []
6868

69-
onStartSpan (span: RootSpan): void {
69+
onStartSpan (span: Span): void {
7070
return
7171
}
72-
onEndSpan (root: RootSpan) {
72+
onEndSpan (root: Span) {
7373
this.endedRootSpans.push(root)
7474
}
7575
}
@@ -201,7 +201,7 @@ describe('HttpsPlugin', () => {
201201
const testPath = '/outgoing/rootSpan/childs/1'
202202
doNock(urlHost, testPath, 200, 'Ok')
203203
const options = { name: 'TestRootSpan' }
204-
return tracer.startRootSpan(options, async (root: RootSpan) => {
204+
return tracer.startRootSpan(options, async (root: Span) => {
205205
await requestMethod(`${urlHost}${testPath}`).then((result) => {
206206
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
207207
assert.strictEqual(root.spans.length, 1)
@@ -223,7 +223,7 @@ describe('HttpsPlugin', () => {
223223
urlHost, testPath, httpErrorCodes[i],
224224
httpErrorCodes[i].toString())
225225
const options = { name: 'TestRootSpan' }
226-
return tracer.startRootSpan(options, async (root: RootSpan) => {
226+
return tracer.startRootSpan(options, async (root: Span) => {
227227
await requestMethod(`${urlHost}${testPath}`).then((result) => {
228228
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
229229
assert.strictEqual(root.spans.length, 1)
@@ -244,7 +244,7 @@ describe('HttpsPlugin', () => {
244244
const num = 5
245245
doNock(urlHost, testPath, 200, 'Ok', num)
246246
const options = { name: 'TestRootSpan' }
247-
return tracer.startRootSpan(options, async (root: RootSpan) => {
247+
return tracer.startRootSpan(options, async (root: Span) => {
248248
assert.ok(root.name.indexOf('TestRootSpan') >= 0)
249249
for (let i = 0; i < num; i++) {
250250
await requestMethod(`${urlHost}${testPath}`).then((result) => {

src/census/plugins/__tests__/ioredis.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { CoreTracer, RootSpan, SpanEventListener, Span, logger, SpanKind } from '@opencensus/core'
17+
import { CoreTracer, SpanEventListener, Span, logger, SpanKind } from '@opencensus/core'
1818
import * as assert from 'assert'
1919
import * as ioredis from 'ioredis'
2020

2121
import { plugin, IORedisPluginConfig } from '../ioredis'
2222

2323
/** Collects ended root spans to allow for later analysis. */
2424
class RootSpanVerifier implements SpanEventListener {
25-
endedRootSpans: RootSpan[] = []
25+
endedRootSpans: Span[] = []
2626

27-
onStartSpan (span: RootSpan): void {
27+
onStartSpan (span: Span): void {
2828
return
2929
}
30-
onEndSpan (root: RootSpan) {
30+
onEndSpan (root: Span) {
3131
this.endedRootSpans.push(root)
3232
}
3333
}
@@ -114,7 +114,7 @@ describe('RedisPlugin', () => {
114114
/** Should intercept query */
115115
describe('Instrumenting query operations', () => {
116116
it('should create a child span for hset', (done) => {
117-
tracer.startRootSpan({ name: 'insertRootSpan' }, (rootSpan: RootSpan) => {
117+
tracer.startRootSpan({ name: 'insertRootSpan' }, (rootSpan: Span) => {
118118
client.hset('hash', 'random', 'random', (err, result) => {
119119
assert.ifError(err)
120120
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0)
@@ -129,7 +129,7 @@ describe('RedisPlugin', () => {
129129
})
130130

131131
it('should create a child span for get', (done) => {
132-
tracer.startRootSpan({ name: 'getRootSpan' }, (rootSpan: RootSpan) => {
132+
tracer.startRootSpan({ name: 'getRootSpan' }, (rootSpan: Span) => {
133133
client.get('test', (err, result) => {
134134
assert.ifError(err)
135135
assert.strictEqual(result, 'data')
@@ -145,7 +145,7 @@ describe('RedisPlugin', () => {
145145
})
146146

147147
it('should create a child span for del', (done) => {
148-
tracer.startRootSpan({ name: 'removeRootSpan' }, async (rootSpan: RootSpan) => {
148+
tracer.startRootSpan({ name: 'removeRootSpan' }, async (rootSpan: Span) => {
149149
await client.del('test')
150150
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0)
151151
rootSpan.end()
@@ -161,7 +161,7 @@ describe('RedisPlugin', () => {
161161
plugin.disable()
162162
const conf: IORedisPluginConfig = { detailedCommands: true }
163163
plugin.enable(ioredis, tracer, VERSION, conf, '')
164-
tracer.startRootSpan({ name: 'insertRootSpan' }, (rootSpan: RootSpan) => {
164+
tracer.startRootSpan({ name: 'insertRootSpan' }, (rootSpan: Span) => {
165165
client.set('test', 'data', (err, result) => {
166166
assert.ifError(err)
167167
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0)
@@ -183,7 +183,7 @@ describe('RedisPlugin', () => {
183183
})
184184

185185
it('should not create a child span for insert', (done) => {
186-
tracer.startRootSpan({ name: 'insertRootSpan' }, (rootSpan: RootSpan) => {
186+
tracer.startRootSpan({ name: 'insertRootSpan' }, (rootSpan: Span) => {
187187
client.hset('hash', 'random', 'random', (err, result) => {
188188
assert.ifError(err)
189189
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0)
@@ -197,7 +197,7 @@ describe('RedisPlugin', () => {
197197
})
198198

199199
it('should not create a child span for get', (done) => {
200-
tracer.startRootSpan({ name: 'getRootSpan' }, (rootSpan: RootSpan) => {
200+
tracer.startRootSpan({ name: 'getRootSpan' }, (rootSpan: Span) => {
201201
client.get('test', (err, result) => {
202202
assert.ifError(err)
203203
assert.strictEqual(result, 'data')
@@ -211,7 +211,7 @@ describe('RedisPlugin', () => {
211211
})
212212

213213
it('should not create a child span for del', (done) => {
214-
tracer.startRootSpan({ name: 'removeRootSpan' }, async (rootSpan: RootSpan) => {
214+
tracer.startRootSpan({ name: 'removeRootSpan' }, async (rootSpan: Span) => {
215215
await client.del('test')
216216
assert.strictEqual(rootSpanVerifier.endedRootSpans.length, 0)
217217
rootSpan.end()

0 commit comments

Comments
 (0)