Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
add some graphite
Browse files Browse the repository at this point in the history
  • Loading branch information
clouserw committed Jun 21, 2011
1 parent 0085991 commit 740fa4f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
32 changes: 15 additions & 17 deletions apps/jetpack/models.py
Expand Up @@ -8,11 +8,9 @@
import markdown
import hashlib
import codecs

from copy import deepcopy

from django.core.exceptions import ObjectDoesNotExist, ValidationError

from django.db.models.signals import (pre_save, post_delete, post_save,
m2m_changed)
from django.db import models, transaction, IntegrityError
Expand All @@ -24,13 +22,14 @@
from django.conf import settings
from django.utils.translation import ugettext as _


from cuddlefish.preflight import vk_to_jid, jid_to_programid, my_b32encode
from ecdsa import SigningKey, NIST256p
from elasticutils import es_required
from pyes import djangoutils
from pyes.exceptions import NotFoundException as PyesNotFoundException

from statsd import statsd

from base.models import BaseModel
from jetpack.errors import (SelfDependencyException, FilenameExistException,
UpdateDeniedException, SingletonCopyException,
Expand Down Expand Up @@ -1161,9 +1160,8 @@ def build_xpi(self, modules=[], attachments=[], hashtag=None, rapid=False,

# XPI: Copy files from NFS to local temp dir
xpi_utils.sdk_copy(sdk_source, sdk_dir)
t1 = time.time()
log.debug("[xpi:%s] SDK copied (time %dms)" %
(hashtag, ((t1 - tstart) * 1000)))
t1 = (time.time() - tstart) * 1000
log.debug("[xpi:%s] SDK copied (time %dms)" % (hashtag, t1))

# TODO: check if it's still needed
self.export_keys(sdk_dir)
Expand All @@ -1184,9 +1182,9 @@ def build_xpi(self, modules=[], attachments=[], hashtag=None, rapid=False,
e_mod.export_code(lib_dir)
if not mod_edited:
mod.export_code(lib_dir)
t2 = time.time()
log.debug("[xpi:%s] modules exported (time %dms)" %
(hashtag, ((t2 - t1) * 1000)))
t2 = (time.time() * 1000) - t1
statsd.timing('xpi.build.modules', t2)
log.debug("[xpi:%s] modules exported (time %dms)" % (hashtag, t2))

# export atts with ability to use edited code (from attachments var)
# XPI: memory/database/NFS to local
Expand All @@ -1199,16 +1197,16 @@ def build_xpi(self, modules=[], attachments=[], hashtag=None, rapid=False,
e_att.export_code(data_dir)
if not att_edited:
att.export_file(data_dir)
t3 = time.time()
log.debug("[xpi:%s] attachments exported (time %dms)" %
(hashtag, ((t3 - t2) * 1000)))
#self.export_attachments(
# '%s/%s' % (package_dir, self.get_data_dir()))
t3 = (time.time() * 1000) - t2
statsd.timing('xpi.build.attachments', t3)
log.debug("[xpi:%s] attachments exported (time %dms)" % (hashtag, t3))

# XPI: copying to local from memory/db/files
self.export_dependencies(packages_dir, sdk=self.sdk)
t4 = time.time()
log.debug("[xpi:%s] dependencies exported (time %dms)" %
(hashtag, ((t4 - t3) * 1000)))
t4 = (time.time() * 1000) - t3
statsd.timing('xpi.build.dependencies', t4)
log.debug("[xpi:%s] dependencies exported (time %dms)" % (hashtag, t4))

# XPI: building locally and copying to NFS
return xpi_utils.build(sdk_dir, self.get_dir_name(packages_dir),
self.name, hashtag, tstart=tstart)
Expand Down
17 changes: 12 additions & 5 deletions apps/xpi/xpi_utils.py
Expand Up @@ -14,6 +14,7 @@
import zipfile

import commonware.log
from statsd import statsd

from django.http import Http404, HttpResponseServerError, HttpResponseForbidden
from django.conf import settings
Expand All @@ -35,6 +36,7 @@ def info_write(path, status, message, hashtag=None):

def sdk_copy(sdk_source, sdk_dir):
log.debug("Copying SDK from (%s) to (%s)" % (sdk_source, sdk_dir))
t1 = time.time()
if os.path.isdir(sdk_dir):
for d in os.listdir(sdk_source):
s_d = os.path.join(sdk_source, d)
Expand All @@ -44,6 +46,7 @@ def sdk_copy(sdk_source, sdk_dir):
shutil.copy(s_d, sdk_dir)
else:
shutil.copytree(sdk_source, sdk_dir)
statsd.timing('xpi.copy', t1 * 1000)


def build(sdk_dir, package_dir, filename, hashtag, tstart=None):
Expand Down Expand Up @@ -109,11 +112,15 @@ def build(sdk_dir, package_dir, filename, hashtag, tstart=None):
t3 = time.time()
copy_xpi_time = '%dms' % ((t3 - t2) * 1000)
build_time = '%dms' % ((t2 - t1) * 1000)
preparation_time = '%dms'% ((t1 - tstart) * 1000) if tstart else "n.d."

log.info(('[xpi:%s] Created xpi: %s (prep time: %s) (build time: %s) '
'(copy xpi time: %s)') % (
hashtag, xpi_targetpath, preparation_time, build_time, copy_xpi_time))
preparation_time = '%dms'% ((t1 - tstart) * 1000) if tstart else 0

statsd.timing('xpi.build.prep', t1)
statsd.timing('xpi.build.build', t2)
statsd.timing('xpi.build.copyresult', t3)
log.info('[xpi:%s] Created xpi: %s (prep time: %s) (build time: %s) '
'(copy xpi time: %s)' % (hashtag, xpi_targetpath,
preparation_time, build_time,
copy_xpi_time))

info_write(info_targetpath, 'success', response[0], hashtag)

Expand Down
2 changes: 2 additions & 0 deletions settings.py
Expand Up @@ -198,7 +198,9 @@

MIDDLEWARE_CLASSES = [
# Munging REMOTE_ADDR must come before ThreadRequest.
'commonware.response.middleware.GraphiteRequestTimingMiddleware',
'commonware.middleware.SetRemoteAddrFromForwardedFor',

'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down
2 changes: 1 addition & 1 deletion vendor
Submodule vendor updated 4 files
+3 −0 .gitmodules
+1 −0 flightdeck.pth
+1 −1 src/elasticutils
+1 −0 src/statsd

2 comments on commit 740fa4f

@zalun
Copy link

@zalun zalun commented on 740fa4f Jun 22, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to display that?

@clouserw
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it. You can go to graphite.mozilla.org if you want to play with the (terrible) UI, or wait a bit and I'll get something friendlier up

Please sign in to comment.