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

add jms extension #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
205 changes: 205 additions & 0 deletions extensions/jms/_jms-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
inspectit:
instrumentation:

actions:
'a_jms_getDestination':
imports:
- 'javax.jms'
input:
_arg0: Object
_this: Object
value-body: |
Destination dest = null;
if(_arg0 instanceof Destination) {
dest = (Destination) _arg0;
}
if(_this instanceof MessageProducer && dest == null){
dest = ((MessageProducer)_this).getDestination();
}
if(_arg0 instanceof Message && dest == null) {
dest = ((Message) _arg0).getJMSDestination();
}
if(dest instanceof Queue) {
return ((Queue)dest).getQueueName();
}
if(dest instanceof Topic) {
return ((Topic)dest).getTopicName();
}
return null;

'a_jms_write_down_propagation':
is-void: true
imports:
- java.util
- javax.jms
input:
msgIndex: int
_args: Object[]
_attachments: ObjectAttachments
_context: InspectitContext
value-body: |
Message msg = (Message)_args[msgIndex];
Object propagationAlreadyPerformed = _attachments.attach(msg, "down_prop_performed", Boolean.TRUE);
if(propagationAlreadyPerformed == null) {
Map headers = _context.getDownPropagationHeaders();
Iterator it = headers.entrySet().iterator();
while(it.hasNext()) {
Map$Entry e = (Map$Entry) it.next();
//we remove hyphens as they are not allowed as property names by the JMS spec
msg.setStringProperty( ((String) e.getKey()).replaceAll("-",""), (String) e.getValue());
}
}

'a_jms_read_down_propagation':
is-void: true
imports:
- 'java.util'
- 'javax.jms'
input:
msgIndex: int
_args: Object[]
_attachments: ObjectAttachments
_context: InspectitContext
value-body: |
Message msg = (Message)_args[msgIndex];
Object propagationAlreadyPerformed = _attachments.attach(msg, "down_prop_read", Boolean.TRUE);
if(propagationAlreadyPerformed == null) {
Collection headerKeys = _context.getPropagationHeaderNames();
Map presentHeaders = new HashMap();
Iterator it = headerKeys.iterator();
while(it.hasNext()) {
String name = (String) it.next();
String nameWithoutHyphens = name.replaceAll("-","");
String value = msg.getStringProperty(nameWithoutHyphens);
if (value != null) {
presentHeaders.put(name, value);
}
}
_context.readDownPropagationHeaders(presentHeaders);
}

scopes:
's_jms_MessageListener_onMessage':
interfaces:
- name: 'javax.jms.MessageListener'
methods:
- name: 'onMessage'
advanced:
instrument-only-inherited-methods: true

's_jms_SessionAwareMessageListener_onMessage':
interfaces:
- name: 'org.springframework.jms.listener.SessionAwareMessageListener'
methods:
- name: 'onMessage'
advanced:
instrument-only-inherited-methods: true

's_jms_MessageProducer_send_arg0msg':
interfaces:
- name: 'javax.jms.MessageProducer'
methods:
- name: 'send'
arguments: [ 'javax.jms.Message' ]
- name: 'send'
arguments: [ 'javax.jms.Message', 'javax.jms.CompletionListener' ]
- name: 'send'
arguments: [ 'javax.jms.Message', int, int, long ]
- name: 'send'
arguments: [ 'javax.jms.Message',int, int, long, 'javax.jms.CompletionListener' ]

's_jms_MessageProducer_send_arg1msg':
interfaces:
- name: 'javax.jms.MessageProducer'
methods:
- name: 'send'
arguments: [ 'javax.jms.Destination', 'javax.jms.Message' ]
- name: 'send'
arguments: [ 'javax.jms.Destination', 'javax.jms.Message', 'javax.jms.CompletionListener' ]
- name: 'send'
arguments: [ 'javax.jms.Destination', 'javax.jms.Message', int, int, long ]
- name: 'send'
arguments: [ 'javax.jms.Destination', 'javax.jms.Message',int, int, long, 'javax.jms.CompletionListener' ]

's_jms_QueueSender_send_arg0msg':
interfaces:
- name: 'javax.jms.QueueSender'
methods:
- name: 'send'
arguments: [ 'javax.jms.Message' ]
- name: 'send'
arguments: [ 'javax.jms.Message', int, int, long ]

's_jms_QueueSender_send_arg1msg':
interfaces:
- name: 'javax.jms.QueueSender'
methods:
- name: 'send'
arguments: [ 'javax.jms.Queue', 'javax.jms.Message' ]
- name: 'send'
arguments: [ 'javax.jms.Queue', 'javax.jms.Message', int, int, long ]

's_jms_TopicPublisher_publish_arg0msg':
interfaces:
- name: 'javax.jms.TopicPublisher'
methods:
- name: 'publish'
arguments: [ 'javax.jms.Message' ]
- name: 'publish'
arguments: [ 'javax.jms.Message', int, int, long ]

s_jms_TopicPublisher_publish_arg1msg:
interfaces:
- name: 'javax.jms.TopicPublisher'
methods:
- name: 'publish'
arguments: [ 'javax.jms.Topic', 'javax.jms.Message' ]
- name: 'publish'
arguments: [ 'javax.jms.Topic', 'javax.jms.Message', int, int, long ]

data:
'jms_send_marker':
down-propagation: JVM_LOCAL
'jms_receive_marker':
down-propagation: JVM_LOCAL

rules:
'r_jms_send_detect_entry':
entry:
'jms_is_entry':
action: 'a_entrypoint_check'
constant-input:
'marker': 'jms_send_marker'

'r_jms_receive_detect_entry':
entry:
'jms_is_entry':
action: 'a_entrypoint_check'
constant-input:
'marker': 'jms_receive_marker'

'r_jms_send_extract_details':
include:
'r_jms_send_detect_entry': true
entry:
'jms_destination':
only-if-true: 'jms_is_entry'
action: 'a_jms_getDestination'
'jms_is_error':
only-if-true: 'jms_is_entry'
action: 'a_logic_isNotNull'
data-input:
'value': _thrown

'r_jms_receive_extract_details':
include:
'r_jms_receive_detect_entry': true
entry:
'jms_origin':
only-if-true: 'jms_is_entry'
action: 'a_jms_getDestination'
'jms_is_error':
only-if-true: 'jms_is_entry'
action: 'a_logic_isNotNull'
data-input:
'value': _thrown
34 changes: 34 additions & 0 deletions extensions/jms/jms-propagation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
inspectit:
instrumentation:
rules:
'r_jms_write_down_propagation_arg0':
scopes:
's_jms_MessageProducer_send_arg0msg': true
's_jms_QueueSender_send_arg0msg': true
's_jms_TopicPublisher_publish_arg0msg': true
post-entry:
do_propagation:
action: 'a_jms_write_down_propagation'
constant-input:
'msgIndex': 0

'r_jms_write_down_propagation_arg1':
scopes:
's_jms_MessageProducer_send_arg1msg': true
's_jms_QueueSender_send_arg1msg': true
's_jms_TopicPublisher_publish_arg1msg': true
post-entry:
do_propagation:
action: 'a_jms_write_down_propagation'
constant-input:
'msgIndex': 1

'r_jms_message_listener_read_down_propagation':
scopes:
's_jms_MessageListener_onMessage': true
's_jms_SessionAwareMessageListener_onMessage': true
pre-entry:
do_propagation:
action: 'a_jms_read_down_propagation'
constant-input:
'msgIndex': 0
60 changes: 60 additions & 0 deletions extensions/jms/jms-service-graph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
inspectit:
instrumentation:
rules:
'r_jms_servicegraph_send':
include:
'r_jms_send_extract_details': true
'r_servicegraph_prepare_down_propagation': true
'r_servicegraph_outbound_record_method': true
scopes:
's_jms_MessageProducer_send_arg0msg': true
's_jms_MessageProducer_send_arg1msg': true
's_jms_QueueSender_send_arg0msg': true
's_jms_QueueSender_send_arg1msg': true
's_jms_TopicPublisher_publish_arg0msg': true
's_jms_TopicPublisher_publish_arg1msg': true
entry:
'servicegraph_is_entry':
only-if-true: 'jms_is_entry'
action: 'a_entrypoint_check'
constant-input:
'marker': 'servicegraph_inbound_marker'
exit:
'servicegraph_target_external':
action: 'a_assign_value'
data-input:
'value': 'jms_destination'
'servicegraph_is_error':
action: 'a_assign_value'
data-input:
'value': 'jms_is_error'
'servicegraph_protocol':
action: 'a_assign_value'
constant-input:
'value': 'jms'

'r_jms_servicegraph_receive':
include:
'r_jms_receive_extract_details': true
'r_servicegraph_inbound_record_method': true
scopes:
's_jms_MessageListener_onMessage' : true
's_jms_SessionAwareMessageListener_onMessage': true
entry:
'servicegraph_is_entry':
action: 'a_assign_value'
data-input:
'value': 'jms_is_entry'
exit:
'servicegraph_origin_external':
action: 'a_assign_value'
data-input:
'value': 'jms_origin'
'servicegraph_is_error':
action: 'a_assign_value'
data-input:
'value': 'jms_is_error'
'servicegraph_protocol':
action: 'a_assign_value'
constant-input:
'value': 'jms'
58 changes: 58 additions & 0 deletions extensions/jms/jms-tracing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
inspectit:
instrumentation:
rules:

'r_jms_tracing_defaults':
tracing:
start-span: true
start-span-conditions:
only-if-true: 'jms_is_entry'
error-status: _thrown
attributes:
'java.exception': _thrown
'java.fqn': 'method_fqn'
entry:
'method_fqn':
action: 'a_method_getFQN'

'r_jms_tracing_send':
include:
'r_jms_tracing_defaults': true
'r_jms_send_extract_details': true
scopes:
's_jms_MessageProducer_send_arg0msg': true
's_jms_MessageProducer_send_arg1msg': true
's_jms_QueueSender_send_arg0msg': true
's_jms_QueueSender_send_arg1msg': true
's_jms_TopicPublisher_publish_arg0msg': true
's_jms_TopicPublisher_publish_arg1msg': true
tracing:
name: 'span_name'
attributes:
'jms.destination': 'jms_destination'
entry:
'span_name':
action: 'a_string_concat'
constant-input:
'a': "JMS: Send to "
data-input:
'b': 'jms_destination'

'r_jms_tracing_receive':
include:
'r_jms_tracing_defaults': true
'r_jms_receive_extract_details': true
scopes:
's_jms_MessageListener_onMessage': true
's_jms_SessionAwareMessageListener_onMessage': true
tracing:
name: 'span_name'
attributes:
'jms.origin': 'jms_origin'
entry:
'span_name':
action: 'a_string_concat'
constant-input:
'a': "JMS: Receive from "
data-input:
'b': 'jms_origin'
Loading