Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix span types for http servers and clients #470

Merged
merged 2 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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