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

feat: Added otel consumer span processing #2834

Closed
wants to merge 11 commits into from

Conversation

jsumners-nr
Copy link
Contributor

This PR resolves #2651.

@jsumners-nr jsumners-nr marked this pull request as ready for review December 13, 2024 15:23
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

Attention: Patch coverage is 89.79436% with 134 lines in your changes missing coverage. Please review.

Project coverage is 79.24%. Comparing base (972b59d) to head (39716e2).
Report is 17 commits behind head on next.

Files with missing lines Patch % Lines
lib/transaction/tracer/index.js 71.77% 35 Missing ⚠️
api.js 9.67% 28 Missing ⚠️
lib/transaction/trace/index.js 91.12% 15 Missing ⚠️
lib/shim/transaction-shim.js 60.71% 11 Missing ⚠️
lib/instrumentation/undici.js 77.77% 8 Missing ⚠️
lib/agent.js 82.75% 5 Missing ⚠️
lib/db/query-parsers/elasticsearch.js 95.09% 5 Missing ⚠️
lib/instrumentation/core/http-outbound.js 90.24% 4 Missing ⚠️
lib/metrics/recorders/other.js 0.00% 3 Missing ⚠️
lib/shim/shim.js 98.43% 3 Missing ⚠️
... and 11 more

❗ There is a different number of reports uploaded between BASE (972b59d) and HEAD (39716e2). Click for more details.

HEAD has 7 uploads less than BASE
Flag BASE (972b59d) HEAD (39716e2)
integration-tests-cjs-18.x 1 0
integration-tests-cjs-22.x 1 0
unit-tests-22.x 1 0
unit-tests-18.x 1 0
unit-tests-20.x 1 0
integration-tests-cjs-20.x 1 0
integration-tests-esm-22.x 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             next    #2834       +/-   ##
===========================================
- Coverage   97.26%   79.24%   -18.02%     
===========================================
  Files         294      287        -7     
  Lines       46405    45542      -863     
===========================================
- Hits        45135    36091     -9044     
- Misses       1270     9451     +8181     
Flag Coverage Δ
integration-tests-cjs-18.x ?
integration-tests-cjs-20.x ?
integration-tests-cjs-22.x ?
integration-tests-esm-18.x 49.87% <30.25%> (-0.04%) ⬇️
integration-tests-esm-20.x 49.88% <30.25%> (-0.04%) ⬇️
integration-tests-esm-22.x ?
unit-tests-18.x ?
unit-tests-20.x ?
unit-tests-22.x ?
versioned-tests-18.x 79.15% <89.79%> (-0.03%) ⬇️
versioned-tests-20.x 79.16% <89.79%> (-0.03%) ⬇️
versioned-tests-22.x 79.16% <89.79%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bizob2828 bizob2828 self-assigned this Dec 16, 2024
lib/otel/segment-synthesis.js Outdated Show resolved Hide resolved
lib/otel/segment-synthesis.js Outdated Show resolved Hide resolved
lib/otel/segments/consumer.js Outdated Show resolved Hide resolved
lib/otel/segments/consumer.js Outdated Show resolved Hide resolved
const destination = otelSpan.attributes[SEMATTRS_MESSAGING_DESTINATION] ?? 'unknown'
const segmentName = `OtherTransaction/consumer/${operation}/${destination}`

transaction.trace.attributes.addAttribute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's more logic in the subscribe-consume for adding other segment and trace attributes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good test, specific to amqplib but should apply to all but obviously the destination kind and destination vary: https://github.com/newrelic/node-newrelic/blob/main/test/versioned/amqplib/amqp-utils.js#L103

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this one. Is there a document somewhere that clearly lists out the attribute names and expected values that are required?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you know the answer to that question 😄

test('should create consumer segment from otel span', (t) => {
const { synth, tracer } = t.nr
const span = createSpan({ tracer, kind: SpanKind.CONSUMER })
span.setAttribute('messaging.operation', 'receive')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test will have to be updated once the feedback is addressed for the new name and also attributes

Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to resolve merge conflicts. Regarding the tx and segment attributes you can either try to figure out now or we can reconcile later


const txAttrs = transaction.trace.attributes
txAttrs.addAttribute(DESTINATIONS.TRANS_SCOPE, 'message.queueName', destination)
// txAttrs.addAttribute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this. All the other attributes seem to be all over the place. I'm not sure if we have access to host/port in the otel spans. Then the message.parameters attributes vary depending on the library. Same with message.routingKey

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at amqplib a lot of the parameters live on these span attributes:

              [SemanticAttributes.MESSAGING_DESTINATION]: exchange,
              [SemanticAttributes.MESSAGING_DESTINATION_KIND]:
                MessagingDestinationKindValues.TOPIC,
              [SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY]:
                msg.fields?.routingKey,
              [SemanticAttributes.MESSAGING_OPERATION]:
                MessagingOperationValues.PROCESS,
              [SemanticAttributes.MESSAGING_MESSAGE_ID]:
                msg?.properties.messageId,
              [SemanticAttributes.MESSAGING_CONVERSATION_ID]:
                msg?.properties.correlationId,

@bizob2828 bizob2828 force-pushed the next branch 2 times, most recently from 26f5ea2 to fe95d98 Compare December 19, 2024 15:59
@jsumners-nr jsumners-nr closed this Jan 2, 2025
@jsumners-nr jsumners-nr deleted the issue-2651 branch January 2, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants