Skip to content

Commit

Permalink
initial working code
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed May 12, 2008
0 parents commit 3c2e875
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
35 changes: 35 additions & 0 deletions djangodblog/__init__.py
@@ -0,0 +1,35 @@
from models import Error, ErrorBatch

import traceback
import socket
import warnings
import md5

class DBLogMiddleware(object):
def process_exception(self, request, exception):
server_name = socket.gethostname()
tb_text = traceback.format_exc()
class_name = exception.__class__.__name__
checksum = md5.new(tb_text).hexdigest()

defaults = dict(
class_name = class_name,
message = exception.message,
url = request.build_absolute_uri(),
server_name = server_name,
traceback = tb_text,
)

try:
Error.objects.create(**defaults)
batch, created = ErrorBatch.objects.get_or_create(
class_name = class_name,
server_name = server_name,
checksum = checksum,
defaults = defaults
)
if not created:
batch.times_seen += 1
batch.save()
except Exception, exc:
warnings.warn(unicode(exc))
36 changes: 36 additions & 0 deletions djangodblog/models.py
@@ -0,0 +1,36 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _

import datetime

class ErrorBatch(models.Model):
class_name = models.CharField(_('Type'), max_length=128)
message = models.TextField()
traceback = models.TextField()
times_seen = models.PositiveIntegerField(default=1)
last_seen = models.DateTimeField(default=datetime.datetime.now)
first_seen = models.DateTimeField(default=datetime.datetime.now)
url = models.URLField(verify_exists=False, null=True, blank=True)
server_name = models.CharField(max_length=128, db_index=True)
checksum = models.CharField(max_length=32, db_index=True)

class Admin:
list_display = ('class_name', 'message', 'last_seen', 'times_seen', 'url', 'server_name')
list_filter = ('class_name', 'times_seen', 'server_name')
ordering = ('-last_seen',)

class Meta:
unique_together = (('class_name', 'server_name', 'checksum'),)

class Error(models.Model):
class_name = models.CharField(_('type'), max_length=128)
message = models.TextField()
traceback = models.TextField()

This comment has been minimized.

Copy link
@JTCunning

JTCunning Nov 7, 2019

Contributor

TOAST is really going to love dealing with this.

datetime = models.DateTimeField(default=datetime.datetime.now)
url = models.URLField(verify_exists=False, null=True, blank=True)
server_name = models.CharField(max_length=128, db_index=True)

class Admin:
list_display = ('class_name', 'message', 'datetime', 'url', 'server_name')
list_filter = ('class_name', 'datetime', 'server_name')
ordering = ('-datetime',)

27 comments on commit 3c2e875

@dcramer
Copy link
Member Author

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@wong2
Copy link

@wong2 wong2 commented on 3c2e875 Jun 24, 2016

Choose a reason for hiding this comment

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

absolutely

@jezdez
Copy link

@jezdez jezdez commented on 3c2e875 May 16, 2017

Choose a reason for hiding this comment

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

@dcramer Nice!

@mattrobenolt
Copy link
Contributor

Choose a reason for hiding this comment

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

👋

@joshuarli
Copy link
Member

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@petercunha
Copy link

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@dcramer
Copy link
Member Author

@dcramer dcramer commented on 3c2e875 Nov 6, 2019

Choose a reason for hiding this comment

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

$ cloc src
    3761 text files.
    3626 unique files.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.80/libexec/bin/cloc line 9051.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.80/libexec/bin/cloc line 9051.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.80/libexec/bin/cloc line 9051.
     577 files ignored.

github.com/AlDanial/cloc v 1.80  T=11.37 s (280.5 files/s, 67972.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PO File                         67          88514         118280         215919
Python                        1484          30868          21031         117224
JSX                            814          10696           4121          75093
TypeScript                     355           6189           3372          37120
JSON                            82              0              0          18504
LESS                            40           2117            572          12361
HTML                           121            741              2           5423
Lua                              5            260            226           1533
JavaScript                     212             99            542           1117
CSS                              4             67             55            549
Markdown                         2             50              0            151
Bourne Shell                     1              6              0             57
XML                              2              0              0             16
-------------------------------------------------------------------------------
SUM:                          3189         139607         148201         485067
-------------------------------------------------------------------------------

@joshuarli
Copy link
Member

@joshuarli joshuarli commented on 3c2e875 Nov 7, 2019

Choose a reason for hiding this comment

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

@dcramer 🤔

Oh, it's the translation files.

$ loc src
--------------------------------------------------------------------------------
 Language             Files        Lines        Blank      Comment         Code
--------------------------------------------------------------------------------
 Python                1593       169803        31017         7435       131351
 Jsx                    815        89938        10700         4264        74974
 Typescript JSX         353        46257         6155         3144        36958
 JSON                    86        18528            0            0        18528
 Less                    40        15050         2117          572        12361
 Plain Text              75        10728          149            0        10579
 HTML                   121         6166          741            2         5423
 Lua                      5         2019          260          214         1545
 JavaScript              19         1070           86           91          893
 CSS                      2          661           66           51          544
 reStructuredText         9          351           89            0          262
 TypeScript               2          424           34          227          163
 Markdown                 2          201           50            0          151
 Bourne Shell             1           63            6            0           57
 XML                      2           16            0            0           16
--------------------------------------------------------------------------------
 Total                 3125       361275        51470        16000       293805
--------------------------------------------------------------------------------

@mattrobenolt
Copy link
Contributor

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@dashed
Copy link
Member

@dashed dashed commented on 3c2e875 May 12, 2020

Choose a reason for hiding this comment

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

Alberto was here.

@dashed
Copy link
Member

@dashed dashed commented on 3c2e875 May 12, 2020

Choose a reason for hiding this comment

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

@joshuarli how many lines of code now?

@dcramer
Copy link
Member Author

Choose a reason for hiding this comment

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

➜  ~/D/sentry (master) ✔ cloc src
    3829 text files.
    3705 unique files.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.84/libexec/bin/cloc line 9879.
Complex regular subexpression recursion limit (32766) exceeded at /usr/local/Cellar/cloc/1.84/libexec/bin/cloc line 9879.
     212 files ignored.

github.com/AlDanial/cloc v 1.84  T=16.43 s (220.5 files/s, 60958.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PO File                         49         124622         161779         299824
Python                        1590          32902          23073         125975
TypeScript                    1011          13763           6437          86091
JSX                            504           7818           3245          55437
JSON                            90              0              0          28002
LESS                           107           2884           2017          17450
HTML                           118            804              0           5081
Lua                              5            260            226           1533
SVG                            125             18             10            917
JavaScript                       6             53             43            451
reStructuredText                 9             86              5            256
Markdown                         4             58              0            180
Bourne Shell                     1              6              0             57
XML                              2              0              0             16
YAML                             1              0              0             14
-------------------------------------------------------------------------------
SUM:                          3622         183274         196835         621284
-------------------------------------------------------------------------------

@dashed
Copy link
Member

@dashed dashed commented on 3c2e875 May 13, 2020

Choose a reason for hiding this comment

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

Wow. That's a lot of TypeScript code.

@billyvg
Copy link
Member

Choose a reason for hiding this comment

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

From less than 100 lines of typescript to more than 70,000. Crazy.

@evanpurkhiser
Copy link
Member

@evanpurkhiser evanpurkhiser commented on 3c2e875 May 12, 2021

Choose a reason for hiding this comment

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

From more than 70,000 lines of python2.7 to less than 100. Crazy.

@dcramer
Copy link
Member Author

Choose a reason for hiding this comment

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

➜  ~/s/sentry cloc src
    4304 text files.
    4263 unique files.
     358 files ignored.

github.com/AlDanial/cloc v 1.74  T=124.21 s (32.5 files/s, 9449.8 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PO File                         49         141548         185897         339075
TypeScript                    1883          29387          12322         198041
Python                        1842          35685          28062         145043
JSON                            43              2              0          30786
LESS                            72           1714           1475          10457
HTML                           134            886              3           5839
JavaScript                       6             33             39           5131
Lua                              5            260            226           1533
Markdown                         4             58              0            180
Bourne Shell                     1              6              0             57
YAML                             1              0              0             19
XML                              2              0              0             16
CSS                              1              0              0              1
-------------------------------------------------------------------------------
SUM:                          4043         209579         228024         736178
-------------------------------------------------------------------------------

@joshuarli
Copy link
Member

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 700,000. Crazy.

@wedamija
Copy link
Member

Choose a reason for hiding this comment

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

From less than 100 ingest requests per second to more than 70,000. Crazy.

@kamilogorek
Copy link
Contributor

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@joshuarli
Copy link
Member

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 1,000,000. Crazy.

josh@thanks-again-tim-apple sentry master $ scc --binary --no-cocomo --no-complexity
───────────────────────────────────────────────────────────────────────────────
Language                     Files       Lines     Blanks    Comments      Code
───────────────────────────────────────────────────────────────────────────────
Python                        3803      505222      53520       20407    431295
TypeScript                    2694      372901      43287       18431    311183
JSON                           566      137496         15           0    137481
JSX                            457       73098       9934        1539     61625
JavaScript                     273       24390       1327         504     22559
SVG                            151       12888         13           0     12875
HTML                           150        6865        919           4      5942
Plain Text                     116       11952        445           0     11507
LESS                            67       12416       1607        1370      9439
YAML                            39        2869        286         291      2292
Shell                           14         775         97         118       560
Markdown                        11         432        108           0       324
ReStructuredText                 8         321         76           0       245
Lua                              6        2077        240         289      1548
TypeScript Typings               6         281         32          28       221
XML                              6         112          5           0       107
License                          5         381         74           0       307
gitignore                        4          60          0           0        60
Go Template                      3         233         26           0       207
Dockerfile                       2         174         22          32       120
Makefile                         2         206         45           3       158
Autoconf                         1           8          0           0         8
BASH                             1          33         11           1        21
Docker ignore                    1           8          1           1         6
TOML                             1          50          6          15        29
ignore                           1           0          0           0         0
───────────────────────────────────────────────────────────────────────────────
Total                         8388     1165248     112096       43033   1010119
───────────────────────────────────────────────────────────────────────────────
Processed 52788547 bytes, 52.789 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

@whoami15
Copy link

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 1,000,001. Crazy.

@chadwhitacre
Copy link
Member

Choose a reason for hiding this comment

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

From less than 100 lines of code to almost certaainly close to a million. Crazy.

$ cloc src
    3299 text files.
    3250 unique files.                                          
     137 files ignored.

github.com/AlDanial/cloc v 1.96  T=4.78 s (679.7 files/s, 300280.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PO File                         49         210176         292096         507971
Python                        2722          56508          42639         271257
JSON                           124              2              0          26194
Text                            81            315              0          12217
HTML                           149            923              7           6230
JavaScript                       6             33             39           5131
Lua                              7            269            267           1563
Markdown                        11            198              0            919
reStructuredText                 8             76              0            245
TypeScript                       1             36             34            200
SVG                             87              6              0            162
YAML                             1              0              0             23
XML                              2              0              0             16
CSS                              2              0              1              2
-------------------------------------------------------------------------------
SUM:                          3250         268542         335083         832130
-------------------------------------------------------------------------------
$
$ scc --binary --no-cocomo --no-complexity
───────────────────────────────────────────────────────────────────────────────
Language                     Files       Lines     Blanks    Comments      Code
───────────────────────────────────────────────────────────────────────────────
Python                        4640      693064      66892       27814    598358
TypeScript                    3367      495675      56059       23063    416553
JSON                           624      153328         27           0    153301
JSX                            323       57768       7999        1357     48412
JavaScript                     162       11151        417         552     10182
HTML                           149        7160        923           7      6230
SVG                            148        2106         12           1      2093
Plain Text                     122       13033        588           0     12445
LESS                            57       11455       1476        1322      8657
YAML                            52        4076        397         452      3227
Markdown                        16        1307        250           0      1057
Shell                           15         766        107         109       550
ReStructuredText                 8         321         76           0       245
License                          7         425         81           0       344
Lua                              7        2099        244         292      1563
XML                              6         112          5           0       107
TypeScript Typings               5         312         37          10       265
Go Template                      3         222          0           0       222
Dockerfile                       2         146         22          18       106
Autoconf                         1           8          0           0         8
BASH                             1          36         11           1        24
Docker ignore                    1           8          1           1         6
Makefile                         1         212         42           3       167
TOML                             1          50          7          13        30
gitignore                        1          58          0           0        58
───────────────────────────────────────────────────────────────────────────────
Total                         9719     1454898     135673       55015   1264210
───────────────────────────────────────────────────────────────────────────────
Processed 84737858 bytes, 84.738 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

$
$ scc --binary --no-cocomo --no-complexity src
───────────────────────────────────────────────────────────────────────────────
Language                     Files       Lines     Blanks    Comments      Code
───────────────────────────────────────────────────────────────────────────────
Python                        2884      370465      34732       22182    313551
HTML                           149        7160        923           7      6230
JSON                           124       26196          2           0     26194
Plain Text                      92       15174        323           0     14851
SVG                             87         168          6           0       162
Markdown                        11        1117        198           0       919
ReStructuredText                 8         321         76           0       245
Lua                              7        2099        244         292      1563
JavaScript                       6        5203         27          44      5132
License                          4         279         46           0       233
Go Template                      3         222          0           0       222
CSS                              2           3          0           1         2
XML                              2          16          0           0        16
TypeScript                       1         270         36          34       200
YAML                             1          23          0           0        23
───────────────────────────────────────────────────────────────────────────────
Total                         3381      428716      36613       22560    369543
───────────────────────────────────────────────────────────────────────────────
Processed 17284935 bytes, 17.285 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

$

@adnathanail
Copy link

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@AvicennaJr
Copy link

Choose a reason for hiding this comment

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

Interesting fr

@wobsoriano
Copy link

Choose a reason for hiding this comment

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

Happy 16th anniversary!

@dustindoiron
Copy link

Choose a reason for hiding this comment

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

From less than 100 lines of code to more than 70,000. Crazy.

@chadwhitacre
Copy link
Member

@chadwhitacre chadwhitacre commented on 3c2e875 May 14, 2024

Choose a reason for hiding this comment

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

Whoa! Thanks for noticing @wobsoriano @dustindoiron ! And here we thought no-one loved us. 🥹

2**4 💃

$ cloc src
    3823 text files.
    3772 unique files.                                          
     143 files ignored.

github.com/AlDanial/cloc v 1.96  T=4.92 s (767.4 files/s, 317887.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PO File                         49         210176         292096         507971
Python                        3291          73525          54127         367821
JSON                            46              0              0          29557
Text                            91            362              0           8881
HTML                           167           1025              8           6988
JavaScript                       5             33             40           5137
Lua                              7            270            267           1566
Markdown                        16            349              0           1559
reStructuredText                 9             87              0            265
TypeScript                       1             44             47            226
SVG                             85              0              0             91
YAML                             1              0              0             23
XML                              2              0              0             16
CSS                              2              0              1              2
-------------------------------------------------------------------------------
SUM:                          3772         285871         346586         930103
-------------------------------------------------------------------------------
$ scc --binary --no-cocomo --no-complexity
───────────────────────────────────────────────────────────────────────────────
Language                     Files       Lines     Blanks    Comments      Code
───────────────────────────────────────────────────────────────────────────────
Python                        5703      955257      87127       36385    831745
TypeScript                    5151      781458      85338       30853    665267
JSON                           651      163777         23           0    163754
HTML                           167        8021       1025           8      6988
SVG                            165        1001          0           1      1000
Plain Text                     138       13259        638           0     12621
LESS                            57       11429       1486        1324      8619
YAML                            51        4007        353         479      3175
JavaScript                      45        3631        316         545      2770
Markdown                        22        2162        422           0      1740
Shell                           11         566         86          71       409
ReStructuredText                 9         352         87           0       265
Lua                              7        2103        245         292      1566
License                          6         321         54           0       267
XML                              6         104          3           0       101
TypeScript Typings               5         321         40          14       267
Go Template                      3         251          0           0       251
BASH                             2         249         37          28       184
Autoconf                         1           8          0           0         8
CSS                              1           1          0           0         1
Docker ignore                    1           9          1           1         7
Dockerfile                       1          96         11          14        71
Makefile                         1         220         39          15       166
TOML                             1         707         14          25       668
gitignore                        1          64          0           0        64
───────────────────────────────────────────────────────────────────────────────
Total                        12206     1949374     177345       70055   1701974
───────────────────────────────────────────────────────────────────────────────
Processed 98507996 bytes, 98.508 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────
$ scc --binary --no-cocomo --no-complexity src
───────────────────────────────────────────────────────────────────────────────
Language                     Files       Lines     Blanks    Comments      Code
───────────────────────────────────────────────────────────────────────────────
Python                        3519      495540      44556       28601    422383
HTML                           167        8021       1025           8      6988
Plain Text                     102       11885        370           0     11515
SVG                             86          92          0           0        92
JSON                            46       29557          0           0     29557
Markdown                        16        1908        349           0      1559
ReStructuredText                 9         352         87           0       265
Lua                              7        2103        245         292      1566
JavaScript                       5        5210         27          45      5138
License                          4         279         46           0       233
Go Template                      3         251          0           0       251
CSS                              2           3          0           1         2
XML                              2          16          0           0        16
TypeScript                       1         317         44          47       226
YAML                             1          23          0           0        23
───────────────────────────────────────────────────────────────────────────────
Total                         3970      555557      46749       28994    479814
───────────────────────────────────────────────────────────────────────────────
Processed 21168752 bytes, 21.169 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

Please sign in to comment.