nrconfig icon indicating copy to clipboard operation
nrconfig copied to clipboard

Error when instrumenting IList

Open tribet84 opened this issue 10 years ago • 7 comments

I get the following code when generating the following instrumentation for an IList parameter method:

  <match assemblyName="Assembly" className="MyNameSpace">
    <exactMethodMatcher methodName="ProcessShifts" parameters="System.Collections.Generic.IList`1&lt;MyNameSpace.MyClass&gt;" />
  </match>

tribet84 avatar Dec 14 '15 14:12 tribet84

Do you have a quick test-case class and expected output I can unit test against? Or is it actually raising an error?

To be sure, I've not used New Relic for a while but the above looks like what I'd expect for a method that looks like

 public void ProcessShifts(IList<MyClass> shifts) { }

for example.

Pablissimo avatar Dec 17 '15 21:12 Pablissimo

Exactly, that's the method I'm creating the instrumentation for.

The problem is those strange characters: "`1&lt"

tribet84 avatar Dec 20 '15 13:12 tribet84

That's how New Relic's custom profiler used to require generics be specified - it's a mad combination of the backtick notation you sometimes see in reflection (like List`1) and standard generic notation, all HTML encoded.

I take it then that the method isn't getting instrumented when you actually run it? It's possible New Relic changed how the instrumentation files are parsed, will be Christmas before I can replicate if that's the case though.

Pablissimo avatar Dec 20 '15 13:12 Pablissimo

From a support ticket I opened in Jan 2013(!) about how to instrument methods with generic parameters:

image image

Pablissimo avatar Dec 20 '15 14:12 Pablissimo

I've tried this approach but I can't get it working. I'll open another ticket, let's see if I'm more lucky

tribet84 avatar Jan 11 '16 14:01 tribet84

Sounds like they've changed how that gets specified then, as once upon a time it definitely worked. As a quick test, try removing the whole parameters attribute from the match element, so something like

<match assemblyName="Assembly" className="MyNameSpace">
    <exactMethodMatcher methodName="ProcessShifts" />
  </match>

In theory that'll just match anything with that name irrespective of the parameters (which might be more broad than you want, but that NRConfig has to fall back to in some situations).

Pablissimo avatar Jan 11 '16 15:01 Pablissimo

This is an old thread, but I ran into the same problem. What I had to do was use [ ] instead of the < > encoded. So my final looked like: System.Collections.Generic.List'1[...]

instead of: System.Collections.Generic.List'1&lt...&gt

to track down the problem, I followed these steps and checked the logs: https://discuss.newrelic.com/t/relic-solution-building-custom-instrumentation-tracer-factories-from-net-agent-log-files/40648/2

mattmaslin avatar Dec 20 '16 20:12 mattmaslin