Skip to content

Commit

Permalink
fix span types for http servers and clients (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev committed Feb 28, 2019
1 parent 8db093d commit 944cfb8
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion ext/types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

module.exports = {
HTTP: 'http'
HTTP: 'http',
WEB: 'web'
}
2 changes: 1 addition & 1 deletion src/plugins/http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function patch (http, methodName, tracer, config) {
[SPAN_KIND]: CLIENT,
'service.name': getServiceName(tracer, config, options),
'resource.name': method,
'span.type': 'web',
'span.type': 'http',
'http.method': method,
'http.url': uri
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/util/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const types = require('../../../ext/types')
const kinds = require('../../../ext/kinds')
const urlFilter = require('./urlfilter')

const HTTP = types.HTTP
const WEB = types.WEB
const SERVER = kinds.SERVER
const RESOURCE_NAME = tags.RESOURCE_NAME
const SERVICE_NAME = tags.SERVICE_NAME
Expand Down Expand Up @@ -227,7 +227,7 @@ function addRequestTags (req) {
[HTTP_URL]: url,
[HTTP_METHOD]: req.method,
[SPAN_KIND]: SERVER,
[SPAN_TYPE]: HTTP
[SPAN_TYPE]: WEB
})

addHeaders(req)
Expand Down
6 changes: 3 additions & 3 deletions test/plugins/express.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Plugin', () => {
const spans = sort(traces[0])

expect(spans[0]).to.have.property('service', 'test')
expect(spans[0]).to.have.property('type', 'http')
expect(spans[0]).to.have.property('type', 'web')
expect(spans[0]).to.have.property('resource', 'GET /user')
expect(spans[0].meta).to.have.property('span.kind', 'server')
expect(spans[0].meta).to.have.property('http.url', `http://localhost:${port}/user`)
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('Plugin', () => {
const spans = sort(traces[0])

expect(spans[0]).to.have.property('service', 'test')
expect(spans[0]).to.have.property('type', 'http')
expect(spans[0]).to.have.property('type', 'web')
expect(spans[0]).to.have.property('resource', 'GET /app/user/:id')
expect(spans[0].meta).to.have.property('span.kind', 'server')
expect(spans[0].meta).to.have.property('http.url', `http://localhost:${port}/app/user/1`)
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Plugin', () => {
const spans = sort(traces[0])

expect(spans[0]).to.have.property('service', 'test')
expect(spans[0]).to.have.property('type', 'http')
expect(spans[0]).to.have.property('type', 'web')
expect(spans[0]).to.have.property('resource', 'GET /app/user/:id')
expect(spans[0].meta).to.have.property('span.kind', 'server')
expect(spans[0].meta).to.have.property('http.url', `http://localhost:${port}/app/user/1`)
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/hapi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Plugin', () => {
.use(traces => {
expect(traces[0][0]).to.have.property('name', 'hapi.request')
expect(traces[0][0]).to.have.property('service', 'test')
expect(traces[0][0]).to.have.property('type', 'http')
expect(traces[0][0]).to.have.property('type', 'web')
expect(traces[0][0]).to.have.property('resource', 'GET /user/{id}')
expect(traces[0][0].meta).to.have.property('span.kind', 'server')
expect(traces[0][0].meta).to.have.property('http.url', `http://localhost:${port}/user/123`)
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/http/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Plugin', () => {
agent
.use(traces => {
expect(traces[0][0]).to.have.property('service', 'test-http-client')
expect(traces[0][0]).to.have.property('type', 'web')
expect(traces[0][0]).to.have.property('type', 'http')
expect(traces[0][0]).to.have.property('resource', 'GET')
expect(traces[0][0].meta).to.have.property('span.kind', 'client')
expect(traces[0][0].meta).to.have.property('http.url', `${protocol}://localhost:${port}/user`)
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/http/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Plugin', () => {
.use(traces => {
expect(traces[0][0]).to.have.property('name', 'http.request')
expect(traces[0][0]).to.have.property('service', 'test')
expect(traces[0][0]).to.have.property('type', 'http')
expect(traces[0][0]).to.have.property('type', 'web')
expect(traces[0][0]).to.have.property('resource', 'GET')
expect(traces[0][0].meta).to.have.property('span.kind', 'server')
expect(traces[0][0].meta).to.have.property('http.url', `http://localhost:${port}/user`)
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/koa.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Plugin', () => {
.use(traces => {
expect(traces[0][0]).to.have.property('name', 'koa.request')
expect(traces[0][0]).to.have.property('service', 'test')
expect(traces[0][0]).to.have.property('type', 'http')
expect(traces[0][0]).to.have.property('type', 'web')
expect(traces[0][0]).to.have.property('resource', 'GET')
expect(traces[0][0].meta).to.have.property('span.kind', 'server')
expect(traces[0][0].meta).to.have.property('http.url', `http://localhost:${port}/user`)
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('Plugin', () => {
.use(traces => {
expect(traces[0][0]).to.have.property('name', 'koa.request')
expect(traces[0][0]).to.have.property('service', 'test')
expect(traces[0][0]).to.have.property('type', 'http')
expect(traces[0][0]).to.have.property('type', 'web')
expect(traces[0][0]).to.have.property('resource', 'GET')
expect(traces[0][0].meta).to.have.property('span.kind', 'server')
expect(traces[0][0].meta).to.have.property('http.url', `http://localhost:${port}/user`)
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/restify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Plugin', () => {
.use(traces => {
expect(traces[0][0]).to.have.property('name', 'restify.request')
expect(traces[0][0]).to.have.property('service', 'test')
expect(traces[0][0]).to.have.property('type', 'http')
expect(traces[0][0]).to.have.property('type', 'web')
expect(traces[0][0]).to.have.property('resource', 'GET')
expect(traces[0][0].meta).to.have.property('span.kind', 'server')
expect(traces[0][0].meta).to.have.property('http.url', `http://localhost:${port}/user`)
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/util/web.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const types = require('../../../ext/types')
const kinds = require('../../../ext/kinds')
const tags = require('../../../ext/tags')

const HTTP = types.HTTP
const WEB = types.WEB
const SERVER = kinds.SERVER
const RESOURCE_NAME = tags.RESOURCE_NAME
const SERVICE_NAME = tags.SERVICE_NAME
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('plugins/util/web', () => {
res.end()

expect(span.context()._tags).to.include({
[SPAN_TYPE]: HTTP,
[SPAN_TYPE]: WEB,
[HTTP_URL]: 'http://localhost/user/123',
[HTTP_METHOD]: 'GET',
[SPAN_KIND]: SERVER
Expand Down

0 comments on commit 944cfb8

Please sign in to comment.