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

AWS MQ span attributes #1977

Merged
merged 6 commits into from
Jul 19, 2024
Merged

AWS MQ span attributes #1977

merged 6 commits into from
Jul 19, 2024

Conversation

obenkenobi
Copy link
Contributor

Overview

This PR uses the changes from the DynamoDB PR. Merge the DynamoDB PR first before merging this PR.

This PR adds new span attributes containing endpoint information from a message broker. This is so the Java Agent can properly link with infrastructure entities generated from AWS MQ. In addition, otel compatible attributes are also added (some are experimental) for routing keys and queues for RabbitMQ.

The new span attributes are the following:

  • server.address which contain the message broker host
  • server.port which contain the message broker port.
  • messaging.rabbitmq.destination.routing_key which is the routing key for a RabbitMQ operation
  • messaging.destination.name which will be the destination for a RabbitMQ operation. For producers this will be the exchange name. For consumers this is the queue name.
  • messaging.destination_publish.name is an otel attribute for message consumers used to indicate what the destination name for the producer is. In the case of RabbitMQ, this is the exchange name.

The externals API has new optional parameters to add host and port for message broker spans, via the method instance(host,port).

For example

ExternalParameters messageProduceParameters = MessageProduceParameters
    .library("JMS")
    .destinationType(DestinationType.NAMED_QUEUE)
    .destinationName("MessageQueue")
    .outboundHeaders(outboundMessageHeaders)
    .instance("localhost", 8088)
    .build();
NewRelic.getAgent().getTracedMethod().reportAsExternal(messageProduceParameters);

ExternalParameters messageConsumeParameters = MessageConsumeParameters
    .library("JMS")
    .destinationType(DestinationType.NAMED_TOPIC)
    .destinationName("MessageTopic")
    .inboundHeaders(inboundMessageHeaders)
    .instance("localhost", 8088)
    .build();
NewRelic.getAgent().getTracedMethod().reportAsExternal(messageConsumeParameters);

Our JMS (if ActiveMQ is used) and RabbitMQ instrumentation automatically add the span attributes.

To get host and port from ActiveMQ, a new instrumentation module was added called activemq-client-5.8.0

On top of that, therabbit-amqp and jms instrumentation was altered to automatically include host and port span attributes.

For our RabbitMQ instrumentation, the existing agent attributes message.routingKey and message.queueName are also added to spans.

In addition the instrumentation was revised so instrumentation module names better match the versions they apply to and to allow host and port information to be reported.

Related Github Issue

#1876
#1832

@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 37.93103% with 36 lines in your changes missing coverage. Please review.

Project coverage is 70.61%. Comparing base (85e2eea) to head (a7c7b9b).
Report is 11 commits behind head on main.

Files Patch % Lines
...java/com/newrelic/agent/tracers/DefaultTracer.java 0.00% 10 Missing ⚠️
...ewrelic/agent/bridge/messaging/BrokerInstance.java 0.00% 7 Missing ⚠️
...ava/com/newrelic/agent/tracers/AbstractTracer.java 36.36% 5 Missing and 2 partials ⚠️
...ewrelic/agent/bridge/DefaultCollectionFactory.java 0.00% 5 Missing ⚠️
...om/newrelic/agent/util/AgentCollectionFactory.java 0.00% 5 Missing ⚠️
...newrelic/agent/bridge/messaging/JmsProperties.java 0.00% 1 Missing ⚠️
...elic/agent/service/analytics/SpanEventFactory.java 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1977   +/-   ##
=========================================
  Coverage     70.61%   70.61%           
- Complexity     9860     9873   +13     
=========================================
  Files           827      829    +2     
  Lines         39857    39914   +57     
  Branches       6068     6077    +9     
=========================================
+ Hits          28144    28185   +41     
- Misses         8983     8999   +16     
  Partials       2730     2730           

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

@obenkenobi obenkenobi merged commit 8f4dbbf into main Jul 19, 2024
111 checks passed
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.

3 participants