Comments (4)
Hi @mhaylock!
You're completely right that DelayedJobSampler#setup
is dead code. This is one of the older and crustier parts of the agent's code, and it looks like that method is a left-over from a half-finished change to the sampler to record DJ queue length metrics by queue.
We'd like to fix this, but to be frank, it's unlikely to happen in the near future - momentum in the community seems to be shifting away from DelayedJob and towards Sidekiq and Resque, and the wide variety of backends that can be used with DJ multiplied by the numerous (often quite divergent) versions of DJ that are in use makes testing a feature like this quite time-consuming. (Not to mention the fact that anything we did implement in this regard would likely not be useful for your unsupported version of DJ.)
Your best bet for the moment is probably to write a custom sampler. The basic idea here is to subclass NewRelic::Agent::Sampler
, and override the poll
method (and possibly initialize
if you have setup work to do). From your overridden poll
method, you'll want to use our custom metric recording APIs to record your metrics. Here's a simple example:
class MySampler < NewRelic::Agent::Sampler
def initialize(*args)
# Do any initialization work here
super
end
def poll
sampled_value = ... # derive your measurement here
NewRelic::Agent.record_metric('Custom/my/metric', sampled_value)
end
end
Your sampler will be automatically instantiated by the agent (by virtue of it inheriting from the NewRelic::Agent::Sampler
class), and it's poll
method will be called every minute, just before the agent transmits data to New Relic.
Let us know how this goes and if you run into any trouble with your custom sampler, we'll be happy to help. Sorry for the disappointing answer re: the built-in DelayedJob sampler, but I didn't want to give you any false hope about it working for your usage in the future.
from newrelic-ruby-agent.
Thank you for your response @benweint, I’ve gone ahead and tried to implement a custom sampler, but I seem to have a bit of a chicken and egg problem - the samplers are loaded when newrelic_rpm boots, but I can’t define a subclass of NewRelic::Agent::Sampler
before newrelic_rpm has loaded.
Is there a supported way to include newrelic_rpm without booting it first, or do you have another suggestion for getting my subclass of NewRelic::Agent::Sampler
defined at the right moment?
from newrelic-ruby-agent.
Actually nevermind @benweint, this was an issue with newrelic_rpm version 3.7.2.192, but not with the recently released 3.8.0.218 - due to this change to the way the agent is loaded when the dispatched is for delayed_job.
A solution that did work with 3.7.2.192 was to call NewRelic::Agent.instance.add_harvest_sampler(CustomDelayedJobSampler)
after defining CustomDelayedJobSampler
.
from newrelic-ruby-agent.
I’ll close now as I have a working solution for our situation.
from newrelic-ruby-agent.
Related Issues (20)
- Add Errors Inbox metadata configuration content to generated doc HOT 3
- [Spike] k8s & container integration HOT 1
- [Spike] Support FM/SA configuration HOT 1
- API driven noticed errors display as `expected: true`, and observed errors should too HOT 2
- Stripe integration Causes Cardinality Explosion HOT 6
- CI: address issues that stemmed from Rack hitting v3.1.x HOT 1
- CI: Investigate, address Grape v2.1 failures HOT 1
- Spike: Instrument `start_transaction.active_record` HOT 1
- Failed to get cluster name for elasticsearch during health check routine HOT 5
- Avoid deprecated Bundler method all_specs HOT 2
- Replace API key with access token in artifactory HOT 1
- [Spike] Agent2Query test definition discovery HOT 1
- Rails v8.0 / Browser Monitoring incompatibility - Rails has changed how it handles streamed renders HOT 1
- Update newrelic.yml generator with new security configs HOT 1
- Update `config.rake` with new Security configs HOT 2
- Create instrumentation for rdkafka HOT 1
- Create instrumentation for ruby-kafka HOT 1
- Create Kakfa service to use for both test apps HOT 1
- Create test app for rdkafka gem HOT 1
- Create test app using ruby-kafka 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.