Skip to content

Commit

Permalink
Enable sentry in updater_script_vnext (#1255)
Browse files Browse the repository at this point in the history
This is the second step towards monitoring the updater. Useful in debugging of issues and general analytics. It follows what the GitHub hosted version has.

OpenTelemetry was setup in #1254. Next step is to connect the error handler.
  • Loading branch information
mburumaxwell authored Jul 29, 2024
1 parent 0bfee34 commit 4ae374b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg ECOSYSTEM=${{ matrix.suite.ecosystem }} \
--build-arg BASE_VERSION=${{ steps.docker-base-version.outputs.version }} \
--build-arg DEPENDABOT_UPDATER_VERSION=${{ steps.gitversion.outputs.nuGetVersionV2 }} \
--label com.github.image.run.id=${{ github.run_id }} \
--label com.github.image.run.number=${{ github.run_number }} \
--label com.github.image.job.id=${{ github.job }} \
Expand Down
4 changes: 4 additions & 0 deletions updater/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG ECOSYSTEM
ARG BASE_VERSION=latest
ARG DEPENDABOT_UPDATER_VERSION=unknown

# The Dependabot docker images in https://github.com/dependabot/dependabot-core are no longer versioned like the Ruby Gems; instead they are versioned by the commit SHA of the release tag.
# In production, the build pipeline automatically calculates BASE_VERSION to match the dependabot-omnibus version set in updater/Gemfile (see .github/workflows/updater.yml).
Expand All @@ -25,6 +26,9 @@ RUN bundle config set --local path 'vendor' && \
COPY --chown=dependabot:dependabot LICENSE $DEPENDABOT_HOME
COPY --chown=dependabot:dependabot updater $DEPENDABOT_HOME/dependabot-updater

# Add ENV
ENV DEPENDABOT_UPDATER_VERSION=$DEPENDABOT_UPDATER_VERSION

# ENTRYPOINT IS USED instead of CMD so as to avoid adding
# 'bin/run.sh' before the file name when running the image
ENTRYPOINT ["bin/run.sh"]
13 changes: 13 additions & 0 deletions updater/lib/tinglesoftware/dependabot/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

require "json"
require "logger"
require "sentry-ruby"

require "dependabot"
require "dependabot/logger"
require "dependabot/logger/formats"
require "dependabot/simple_instrumentor"
require "dependabot/opentelemetry"
require "dependabot/sentry"
require "dependabot/environment"

ENV["DEPENDABOT_JOB_ID"] = Time.now.to_i.to_s unless ENV["DEPENDABOT_JOB_ID"]
Expand All @@ -18,6 +20,17 @@
logger.formatter = Dependabot::Logger::BasicFormatter.new
end

# TODO: connect error handler to the job, operation, or service so that the errors can be reported to Sentry here
Sentry.init do |config|
config.dsn = "https://0abd35cde5ca89c8dbcfb766a5f5bc50@o4507686465830912.ingest.us.sentry.io/4507686484508672"
config.release = ENV.fetch("DEPENDABOT_UPDATER_VERSION", "unknown")
config.logger = Dependabot.logger

config.before_send = ->(event, hint) { Dependabot::Sentry.process_chain(event, hint) }
config.propagate_traces = false
config.instrumenter = ::Dependabot::OpenTelemetry.should_configure? ? :otel : :sentry
end

Dependabot::SimpleInstrumentor.subscribe do |*args|
name = args.first
payload = args.last
Expand Down

0 comments on commit 4ae374b

Please sign in to comment.