Comments (6)
To be more specific, we don't care if there is only a "single transaction trace node representing the entire batch". What we really want is for the basic details about each request to be visible in the "drilldown"/"parameters"/"key" area. I'm currently looking at new_relic/agent/instrumentation/typhoeus
and new_relic/agent/http_clients/typhoeus_wrappers
to try and grok how they work.
from newrelic-ruby-agent.
Hi there!
The root problem here is that the agent is not designed to handle tracing of asynchronous events that potentially overlap in time and finish in a different order than they start, like the individual requests within a Hydra session. Solving that problem would involve a re-architecting of much of the Ruby agent.
That said, it sounds like you don't really need to solve that fundamental issue to get what you're after. You might be able to achieve what you're after by just attaching a parameter to the current transaction trace node that contains the set of URLs hit in a Hydra block. This won't make the requests show up on the Externals tab in the UI, but it will at least let you see what is happening during individual transaction traces.
To accomplish that, you'll want to start with this method in the Typhoeus instrumentation, probably making a separate case for when request_is_hydra_enabled? returns true. In that separate case, you'll want to use notice_extra_data to attach extra data onto the transaction trace node representing the Hydra block. The problem is that you'll only get the requests one-at-a-time, and notice_extra_data
will overwrite the previous value that you pass to it if you call it again inside the same transaction trace node. There might be a creative way around that, such as including a number in the key name (e.g. hydra_url[N]
where N is the 'index' of the request in the Hydra block). For that to work, you'd need a place to stash a counter on a per-Hydra-block basis, which I don't know off the top of my head if that's easy to find or not.
Let us know if this doesn't make sense, or if you run into trouble along the way - this does seems like a useful feature to add. Thanks!
from newrelic-ruby-agent.
Thanks! That does make sense, and is exactly what we need. Since we're already alias method chaining Hydra#run
and the request has a reference back to its hydra (request.hydra
), it probably makes sense for the Hydra instance to temporarily store an array of the requests (or a counter). After run_without_newrelic
, we can process our requests array and attach it to the trace.
Some questions about notice_extra_data
:
notice_extra_data
is a private method onNewRelic::Agent::TransactionSampler
. How should I access it from the monkeypatchedHydra
(which hasNewRelic::Agent::MethodTracer
included) or from anywhere else?- Are there any magic
key
values to avoid? I see that:sql
is special cased in a few places. Will using arbitrary keys work out okay? - What will the web UI's transaction trace look like if I attach multiple keys e.g.
"hydra_req[0]"
through"hydra_req[n]"
(where n might be >= 1000)? I could also roll up the entire batch of requests into a single message although that would be more likely to hitMAX_DATA_LENGTH
. - Speaking of
MAX_DATA_LENGTH
, will callingnotice_extra_data
thousands of times run into data size issues? - Is it okay to give a
duration
of 0.0 or nil? Recording an accurate duration is more work than I want to do right now. :)
from newrelic-ruby-agent.
Great questions! I think you're right that it probably makes sense to stash the counter on the request.hydra
instance.
- Re:
notice_extra_data
being a private method: sorry I missed that. I'd suggest adding a public wrapper method like notice_sql, called something likenotice_http_request_url
that callsnotice_extra_data
underneath. - Re: key values to avoid: I believe the only two currently used are
:sql
and:key
. - Re: how the UI will handle this - I honestly don't know. I suspect it will show up, but it may not be formatted in a particularly pretty way. I suspect that you may bump up against some limits in the UI if you're really talking about displaying the URLs 1000s of outgoing requests within a single transaction, but the quickest way to answer that question is probably just to try it :)
- Re:
MAX_DATA_LENGTH
- that limit is applied on a per-key basis, so you actually should be OK if you use separate keys (it would be an issue if you were to aggregate everything together into one key, though). - Re: a
duration
of 0 ornil
- don't passnil
, but 0 should be fine. It looks likeduration
is only used to determine whether to capture a backtrace for the transaction trace node, which you probably don't want.
from newrelic-ruby-agent.
For the notice_extra_data
wrapper, I'm still not sure how to get to the appropriate NewRelic::Agent::TransactionSampler
instance. Is there a global/singleton somewhere, or a local reference created by NewRelic::Agent::MethodTracer
?
from newrelic-ruby-agent.
NewRelic::Agent.instance.transaction_sampler
is the usual approach for getting the TransactionSampler
instance.
from newrelic-ruby-agent.
Related Issues (20)
- Implement a Dimensional Metrics API HOT 1
- Spec: Add thread.id to Span events HOT 1
- Spec: Truncate custom event attributes HOT 2
- Spec: Add stack trace attribute to datastore segments HOT 1
- Spec: Add support for json logs HOT 1
- Elasticsearch: Instrumentation adds potentially dangerous `GET _cluster/health` request to every initial request HOT 11
- Refactor GuidGenerator to use SecureRandom (Fly backport) HOT 1
- [Spike] Ruby Agent - APM missing information for creation of APM to Cloud service relationships HOT 2
- Explore options for AWS Lambda instrumentation HOT 4
- [Spike] Add support for OpenAI Instrumentation HOT 2
- Add support for Bedrock (AI SDK) instrumentation HOT 1
- Consolidate "Unknown" constant values HOT 1
- Remove the Ruby/Thread + other spans HOT 1
- Retire deprecated way of creating deployment markers HOT 1
- Report Sidekiq jobs that call other jobs HOT 2
- Add Tests for Falcon HOT 1
- Memory Leak for HTTPX Integration HOT 7
- Prioritize the list of dispatchers based on reasonable assumptions for users on the latest agent version HOT 1
- Refactor local_environment.rb methods HOT 3
- Fix stoat prerelease automation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from newrelic-ruby-agent.