Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include HISTORY.rst
include LICENSE
include README.rst
include djdt_flamegraph/flamegraph.pl
include djdt_flamegraph/static/djdt_flamegraph/djdt_flamegraph.js

recursive-include tests *
recursive-exclude * __pycache__
Expand Down
27 changes: 13 additions & 14 deletions djdt_flamegraph/djdt_flamegraph.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,12 @@
init();
</script>
</template>
<iframe id="djdt-flamegraph-iframe" style="width:100%;height:100%;" src="about:blank">

<iframe id="djdt-flamegraph-iframe" style="width:100%;height:100%;">
</iframe>
<script>
(function(){
var i = document.querySelector('#djdt-flamegraph-iframe');
var tpl = document.querySelector('#djdt-flamegraph-tpl');
i.contentWindow.document.write(tpl.innerHTML);
}())
</script>
"""

from django.templatetags.static import static

class FlamegraphPanel(Panel):
title = 'Flamegraph'
Expand All @@ -51,20 +46,24 @@ def enabled(self):

@property
def content(self):
ctx = {
return Template(template).render(Context({
'flamegraph': flamegraph.stats_to_svg(self.sampler.get_stats())
}
return Template(template).render(Context(ctx))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This doesnt appear to have changed at all? Why modify it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's a leftover from other attempts to fix the scripts not executing that i ended up removing.
I can remove it?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Restoring this chunk would be good.

Also I think the minimum supported version of djdt should be increased to 2.2 - that is what works for me.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ping @aleksanb , can you restore this, so that the changes needed are more clear and not distorted by unneeded changes.

}))

@property
def scripts(self):
scripts = super().scripts
scripts.append(static("djdt_flamegraph/djdt_flamegraph.js"))
return scripts

def enable_instrumentation(self):
self.sampler = Sampler()

def process_request(self, request):
self.sampler.start()
return super().process_request(request)

def process_response(self, request, response):
response = super().process_request(request)
self.sampler.stop()
return response


class Sampler(object):
Expand Down
5 changes: 5 additions & 0 deletions djdt_flamegraph/static/djdt_flamegraph/djdt_flamegraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function(){
const i = document.querySelector('#djdt-flamegraph-iframe');
const tpl = document.querySelector('#djdt-flamegraph-tpl');
i.contentWindow.document.write(tpl.innerHTML);
}())