Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/dd-trace/src/opentelemetry/span.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { timeInputToHrTime } = require('@opentelemetry/core')
const tracer = require('../../')
const DatadogSpan = require('../opentracing/span')
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../constants')
const { SERVICE_NAME, RESOURCE_NAME } = require('../../../../ext/tags')

const SpanContext = require('./span_context')

Expand Down Expand Up @@ -40,7 +41,8 @@ class Span {
hostname: _tracer._hostname,
integrationName: 'otel',
tags: {
'service.name': _tracer._service
[SERVICE_NAME]: _tracer._service,
[RESOURCE_NAME]: spanName
}
}, _tracer._debug)

Expand Down
12 changes: 9 additions & 3 deletions packages/dd-trace/test/opentelemetry/span.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const SpanContext = require('../../src/opentelemetry/span_context')
const { NoopSpanProcessor } = require('../../src/opentelemetry/span_processor')

const { ERROR_MESSAGE, ERROR_STACK, ERROR_TYPE } = require('../../src/constants')
const { SERVICE_NAME, RESOURCE_NAME } = require('../../../../ext/tags')

function makeSpan (...args) {
const tracerProvider = new TracerProvider()
Expand All @@ -24,15 +25,13 @@ describe('OTel Span', () => {
const span = makeSpan('name')

const context = span._ddSpan.context()
expect(context._tags['service.name']).to.equal(tracer._tracer._service)
expect(context._tags[SERVICE_NAME]).to.equal(tracer._tracer._service)
expect(context._hostname).to.equal(tracer._hostname)
})

it('should expose parent span id', () => {
tracer.trace('outer', (outer) => {
global.hax = true
const span = makeSpan('name', {})
global.hax = false

expect(span.parentSpanId).to.equal(outer.context()._spanId.toString(16))
})
Expand All @@ -44,6 +43,13 @@ describe('OTel Span', () => {
expect(span.name).to.equal('name')
})

it('should copy span name to resource.name', () => {
const span = makeSpan('name')

const context = span._ddSpan.context()
expect(context._tags[RESOURCE_NAME]).to.equal('name')
})

it('should expose span context', () => {
const span = makeSpan('name')

Expand Down