Splunk AppDynamics

Getter Chain

Maria_Garcia
Path Finder

Hi team,

We have the following custom code created in order to monitor calls to IBM MQs:

...

private String component, process, activity, sentTo, origin, message, response;

public String init(String component, String process, String activity, String payload, String regex, String queueOrigin) {

That method returns a "message".

Then the following "get" methods have been created for each case, for example to capture the size of the message:

...

           public int getMessageSizeBytes(){

            return message.getBytes().length;

      }

...

How to use them as getter chains to capture those information on Data Collectors? How to capture the result of getMessageSizeBytes?

I mean, the first method returns a message, that is already captured but... how to obtain its size?

The method getMessageSizeBytes is already added on the code, but the getter chain is not capturing that value...

Which configuration should be used? Please kindly check attached image

Thanks!

Labels (1)
0 Karma

Peter_Holditch
Builder

Moco,

You need to define a data collector on a method that is called as part of the processing of the BT.

That data collector can access methods on any of:

  • the object instance on which the instrumented method is run
  • the object(s) passed to the instrumented method as parameters
  • the object returned from the instrumented method

The key here is that a data collector is passive - it needs to be placed on a method that will be run in the course of the processing of the BT in order that it can step in and collect the data you need.

Warm regards,

Peter

0 Karma

Maria_Garcia
Path Finder

Thanks Petter,

As you can see in the attached image, we are trying to define the getter chains on a method invocation data collector for the initial method "init"... is this configuration correct, please?

The input parameters and the return message are properly detected, however the value returned by the get size function is not properly obtained... do you know why?

Which getter chain expression shuld we use exactly?

Thanks a lot!  

0 Karma

Peter_Holditch
Builder

So when during the BT execution is your init method called?  Can you provide a snippet of the application code that shows the context of that call?

Warm regards,

Peter

0 Karma

Maria_Garcia
Path Finder

Hi,

Yes, init method is being captured in AppDynamics BTs.

In fact the returned message is properly displayed as data collector (please see attached image with all the parameters), using the "ReturnValue.toString()" configured as Method Data Invocation:

- Collection Data From: Return Value

- Operation on Invoked Object: Use toString()

But the issue heer is which getter chain expression should be used to capture the size of the message, calculated with

public int getMessageSizeBytes(){

            return message.getBytes().length;

      }.

Sorry, but I do not have access all the code, just that related to those method (please find it attached)

Thanks

0 Karma

Peter_Holditch
Builder

Ah, OK.  That validates that the collector is getting called, which is what I wanted to confirm.

I think the problem you're running in to is that the getter chain wants to get the data value as a string, and since your method returns an un-boxed int, it can't do the necessary type conversion.

It should work if you change your method to return the length as a String, or an an Integer (which has a toString method that could be used to yield a string result)

Warm regards,
Peter

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Public Class Order {

      public string ClOrdID

      {
           get;
            set;
       }

}

public Order SendOrder(Order ord) {}

What will be getter chain for collecting value of ClOrdID.  Remember its .net property and there is no getClordID() method defined explicitly. 

0 Karma

Alex_Fedotyev
Path Finder

For .NET properties, you can just use the property name and the agent will automatically use the get internally: ClOrdID

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

For .net property if i just use  ParamIndex_0.ClOrdID then value capture in Business transaction snapshot is showing just "[]" .. i sse data is collected but value [] does not make sense. Do i have to call toString()

0 Karma

Alex_Fedotyev
Path Finder

Can you attach some screenshots of configuration and what you see in snapshots?

I suspect if you see [...], that means that the method you instrumented might be called multiple times per transaction.

You don't need ToString(), agent does it internally anyway to serialized non-string types.

0 Karma

Bhushan_Shinde
New Member

Hi AppD team,

I'm working on few business use cases where requirement is to pull the value from request POST body of .Net web API.

Below is the sample code snapshot,

// POST api/wow
[RequestHandler]
public HttpResponseMessage Post([FromBody]dynamic requestInput)
{
try
{}

i need to get one of the body parameter value (string) of requestInput.

I'm doing this POC using Method Invocation Data Collectors and Information Points using Getter chain.

Can you guide me to achieve this task please.

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

1. private bool SendBulkOrders(List<Order> orders) {}

DataCollector for method SendBulkOrders collecting Parameter 0.

Getter chain: [0].BucketId

(If you have a class which has a property type of List, then you would need to do something like "MyProperty.[0].BucketId")

Above example does not work. getting error: [CANNOT EVALUATE: Error getting data from specified method paramter]   .. i am using  Getter chain: [0].BucketId  which ultimately tranlated into ParamIndex_0.[0].BucketId

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Another scenarios: How to achive it.

1) private bool SendBulkOrders(List<Order> orders) {}

how to collect data from parameter which is collection of data. In above example i want to cllect orders[0].BucketId  

2) private bool SendObject(Object sender) {}

In above example, i want to typecast sender to Employee type and collect employe id. like ((Employe)sender).EmpId

0 Karma

Alex_Fedotyev
Path Finder

Do you have a way to try these?

I think following should just work:

1. private bool SendBulkOrders(List<Order> orders) {}

DataCollector for method SendBulkOrders collecting Parameter 0.

Getter chain: [0].BucketId

(If you have a class which has a property type of List, then you would need to do something like "MyProperty.[0].BucketId")

2. private bool SendObject(Object sender) {}

Again,DataCollector for method SendObject collecting Parameter 0.

Getter chain: EmpId

Internally agent should be aware of the runtime type of the parameter, therefore I don't think you need to cast it in the getter chain.

Let me know if this doesn't work, I'll look up further.

Thanks,

-Alex

PS: If you leave the medhod body empty, .NET may optimize your method... in that case it is a good idea to add couple attributes like explained here: https://stackoverflow.com/questions/38632939/disable-compiler-optimisation-for-a-specific-function-o...

0 Karma

Maria_Garcia
Path Finder

Hi,

Yes, init method is being captured in AppDynamics BTs.

In fact the returned message is properly displayed as data collector (please see attached image with all the parameters), using the "ReturnValue.toString()" configured as Method Data Invocation:

- Collection Data From: Return Value

- Operation on Invoked Object: Use toString()

But the issue heer is which getter chain expression should be used to capture the size of the message, calculated with

public int getMessageSizeBytes(){

            return message.getBytes().length;

      }.

Sorry, but I do not have access all the code, just that related to those method (please find it attached)

Thanks

0 Karma
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Customers Increasingly Choose Splunk for Observability

For the second year in a row, Splunk was recognized as a Leader in the 2024 Gartner® Magic Quadrant™ for ...