Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Feb 13, 2025
1 parent b704951 commit 7da113f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/otel/segments/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function createConsumerSegment(agent, otelSpan) {
const system = otelSpan.attributes[ATTR_MESSAGING_SYSTEM] ?? 'unknown'
const destination = otelSpan.attributes[ATTR_MESSAGING_DESTINATION] ?? 'unknown'
const destKind = otelSpan.attributes[ATTR_MESSAGING_DESTINATION_KIND] ?? 'unknown'
const segmentName = `OtherTransaction/Message/${system}/${destKind}/Named/${destination}`
const segmentName = `${system}/${destKind}/Named/${destination}`

const txAttrs = transaction.trace.attributes
txAttrs.addAttribute(DESTINATIONS.TRANS_SCOPE, 'message.queueName', destination)
Expand All @@ -39,11 +39,10 @@ function createConsumerSegment(agent, otelSpan) {
//
// )
transaction.setPartialName(segmentName)
transaction.finalizeName()

const segment = agent.tracer.createSegment({
recorder,
name: segmentName,
name: transaction.getFullName(),
parent: transaction.trace.root,
transaction
})
Expand Down
7 changes: 3 additions & 4 deletions test/versioned/otel-bridge/span.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,21 +409,20 @@ test('messaging consumer metrics are bridged correctly', (t, end) => {
tracer.startActiveSpan('consumer-test', { kind: otel.SpanKind.CONSUMER, attributes }, (span) => {
const tx = agent.getTransaction()
const segment = agent.tracer.getSegment()
assert.equal(segment.name, 'OtherTransaction/Message/kafka/queue/Named/work-queue')
span.end()
const duration = hrTimeToMilliseconds(span.duration)
assert.equal(duration, segment.getDurationInMillis())
tx.end()

assert.equal(segment.name, 'OtherTransaction/Message/kafka/queue/Named/work-queue')
assert.equal(tx.type, 'message')

const unscopedMetrics = tx.metrics.unscoped
const expectedMetrics = [
'OtherTransaction/all',
'OtherTransaction/Message/all',
'OtherTransaction/Message/OtherTransaction/Message/kafka/queue/Named/work-queue',
'OtherTransactionTotalTime',
'OtherTransactionTotalTime/Message/OtherTransaction/Message/kafka/queue/Named/work-queue'
'OtherTransaction/Message/kafka/queue/Named/work-queue',
'OtherTransactionTotalTime'
]
for (const expectedMetric of expectedMetrics) {
assert.equal(unscopedMetrics[expectedMetric].callCount, 1, `${expectedMetric}.callCount`)
Expand Down

0 comments on commit 7da113f

Please sign in to comment.