Skip to content

Commit

Permalink
Merge pull request #20051 from code-dot-org/revert-20028-revert-19998…
Browse files Browse the repository at this point in the history
…-mark-red-green-dtts

Revert "Revert "log auto and manual DTT starts, green DTTs and red DTTs""
  • Loading branch information
Erin007 committed Jan 16, 2018
2 parents cc2dc64 + a36f122 commit 9e440e9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions aws/ci_build
Expand Up @@ -32,6 +32,7 @@ require 'cdo/infra_production_topic'
require 'cdo/infra_test_topic'
require 'cdo/rake_utils'
require 'cdo/only_one'
require 'cdo/metrics_helper'

STARTED = 'build-started'.freeze
S3_LOGS_BUCKET = 'cdo-build-logs'.freeze
Expand Down Expand Up @@ -181,6 +182,7 @@ def mark_dtt_green

DevelopersTopic.set_dtt 'yes'
InfraTestTopic.set_green_commit test_branch_sha
Metrics.write_metric('dtt_green', test_branch_sha, Metrics::AUTOMATIC)
end

def emit_deploy_metric(deployment_stage, successful)
Expand Down
2 changes: 2 additions & 0 deletions bin/cron/deploy_to_test
Expand Up @@ -6,6 +6,7 @@ require 'cdo/developers_topic'
require 'cdo/github'
require 'cdo/infra_test_topic'
require 'cdo/only_one'
require 'cdo/metrics_helper'

TOPIC_DTT_IN_PROGRESS = 'no (robo-DTT in progress)'.freeze
TOPIC_DTT_FAILED = 'no (robo-DTT failed)'.freeze
Expand Down Expand Up @@ -35,6 +36,7 @@ def main
"robo-DTT created and merged <a href=\"#{GitHub.url(pr_number)}\">PR#{pr_number}</a>",
color: 'green'
)
Metrics.write_metric('dtt_start', GitHub.sha('test'), Metrics::AUTOMATIC)
rescue Exception => e
ChatClient.message(
'infra-test',
Expand Down
8 changes: 6 additions & 2 deletions bin/dotd
Expand Up @@ -15,6 +15,7 @@ require_relative '../lib/cdo/infra_test_topic'
require_relative '../lib/cdo/infra_production_topic'
require_relative '../lib/cdo/github'
require_relative '../lib/cdo/honeybadger'
require_relative '../lib/cdo/metrics_helper'
include CdoCli

LOG_FILE = "#{Dir.tmpdir}/dotd.log".freeze
Expand Down Expand Up @@ -64,10 +65,11 @@ end

# Marks the most recent DTT red, updating Slack#developers topic to allow a new
# test run, but leaving the Slack#infra-test topic with the hash of the previous
# green run
# green run. Inserts a 'dtt_red' row into the metrics table.
def mark_dtt_red
DevelopersTopic.set_dtt 'yes'
InfraTestTopic.set_red_commit GitHub.sha('test')
Metrics.write_metric('dtt_red', GitHub.sha('test'), Metrics::MANUAL)

puts <<-EOS.unindent
Expand All @@ -78,10 +80,11 @@ def mark_dtt_red
end

# Marks the most recent DTT green, updating Slack#infra-test and Slack#developers topics
# appropriately.
# appropriately. Inserts a 'dtt_green' row into the metrics table.
def mark_dtt_green
DevelopersTopic.set_dtt 'yes'
InfraTestTopic.set_green_commit GitHub.sha('test')
Metrics.write_metric('dtt_green', GitHub.sha('test'), Metrics::MANUAL)

puts <<-EOS.unindent
Expand Down Expand Up @@ -257,6 +260,7 @@ def dotd_menu(dotd_name)
EOS
@logger.info 'manually DTTs from staging'
DevelopersTopic.set_dtt 'no (manual DTT in progress)'
Metrics.write_metric('dtt_start', GitHub.sha('test'), Metrics::MANUAL)
end
menu.choice(:G) {mark_dtt_green}
menu.choice(:R) {mark_dtt_red}
Expand Down
23 changes: 22 additions & 1 deletion lib/cdo/metrics_helper.rb
Expand Up @@ -4,7 +4,15 @@ module Metrics
DEVINTERNAL_DB = CDO.devinternal_db_writer ?
sequel_connect(CDO.devinternal_db_writer, CDO.devinternal_db_writer) : nil

# Insert data into the metrics table.
# Values for DTT metrics.
AUTOMATIC = 0
MANUAL = 1

# Insert new row into the metrics table.
# @param name [String] The name of the metric.
# @param metadata [String] Data relevant to the specific metric. For example, the commit hash for DTT metrics.
# @param value [Float] Numerical value relevant to the specific metric. See constants above for examples.
# @param timestamp [Datetime] Only used if we want to explicitly set the created_at value for a particular metric.
def self.write_metric(name, metadata, value, timestamp=nil)
if DEVINTERNAL_DB
dataset = DEVINTERNAL_DB[:metrics]
Expand All @@ -16,3 +24,16 @@ def self.write_metric(name, metadata, value, timestamp=nil)
dataset.insert(data)
end
end

# Summary of the data currently being logged in the metrics table:
# -----------------------------------------------------------------------------
# | name | metadata | value |
# -----------------------------------------------------------------------------
# | dtt_start | commit hash | 0 - if automatic |
# | | | 1 - if manual |
# |----------------------------------------------------------------------------|
# | dtt_green | commit hash | 0 - if automatic |
# | | | 1 - if manual |
# |----------------------------------------------------------------------------|
# | dtt_red | commit hash | 1 - always manual |
# |----------------------------------------------------------------------------|

0 comments on commit 9e440e9

Please sign in to comment.