dependabot / dependabot-core

🤖 Dependabot's core logic for creating update PRs.
https://docs.github.com/en/code-security/dependabot
MIT License
4.65k stars 1k forks source link

Instrumentation #2504

Open jurre opened 4 years ago

jurre commented 4 years ago

It would be great to have a way to instrument dependabot-core, to figure out performance bottlenecks etc.

There are a few options we could consider:

Notifications

Introduce some sort of Notification pattern, so in or around a given method, we can do something like:

def my_method
  Dependabot.instrument("bundler.my_method") do
    # .. the code
end

We could introduce some convenience methods so we can tag a given method as needing instrumentation.

Then, in the environment where we run this code, we could do something like:

Dependabot::Instrumentation.subscribe("bundler.my_method") do |event|
  $statsd.timing("bundler.my_method", event.duration)
end

We could implement such an notification system ourselves, or include ActiveSupport

Allow setting a statsd/opentracing client

Alternatively we could inject a statsd or opentracing client into Dependabot, and ship with a noop implementation by default.

Dependabot.statsd = Datadog::Statsd.new

def my_method
  time = Benchmark.measure do
    # ...
  end
  Dependabot.statsd.timing("bundler.my_method", time)
end
jeffwidman commented 1 year ago

👍 for adding OpenTelemetry support (opentracing was deprecated in favor of opentelemtry).

abdulapopoola commented 6 months ago

@JamieMagee , I believe you already added the framework for OTel so this might be light lift?

JamieMagee commented 6 months ago

Yes, the combination of migrating to sentry-ruby, which supports OpenTelemetry, and adding OpenTelemetry configuration should make this easy to do.

I would think there are 2 steps: