8000 Django integration: connect Javascript SDK · Issue #1171 · getsentry/sentry-python · GitHub
[go: up one dir, main page]

Skip to content
Django integration: connect Javascript SDK #1171
Closed
@danielmanser

Description

@danielmanser

I'm completely stuck with connecting the Python SDK (I'm using Django) and the Javascript SDK. I've installed sentry-python and it sends events to my onPrem Sentry installation. Now I want to connect it with the Frontend using Sentry SDK.

I followed the docs and I think I need to add the trace_id as a <meta> tag in my template. Either I'm too dumb or the docs could be improved, but I've spent 3+hrs trying to get it done with no success.

Environment

How do you use Sentry?
Sentry onPrem, version 21.8.0, installed with the recommended Docker service using install.sh. Sentry seems to work, I can receive errors.

Which SDK and version?
Backend: Python 3.8.5, Django 3.2.6 using sentry-sdk, version 1.3.1
Frontend: Basic HTML, Bootstrap, nothing fancy

Python virtual environment:

asgiref==3.4.1
certifi==2021.5.30
Django==3.2.6
django-appconf==1.0.4
django-compressor==2.4.1
django-debug-toolbar==3.2.2
django-extensions==3.1.3
django-honeypot==1.0.1
psycopg2-binary==2.9.1
pytz==2021.1
rcssmin==1.0.6
rjsmin==1.1.0
sentry-sdk==1.3.1
six==1.16.0
sqlparse==0.4.1
urllib3==1.26.6

Steps to Reproduce

  1. Set up the Django integration following the official docs. Unhandled errors in Django are working and being sent to my Sentry instance, so I guess this part is not in question.
  2. Following Connecting Services, I decided it would be easiest to add a <meta> tag in my Django template, so I followed this:
<meta name="sentry-trace" content="{{ span.toSentryTrace() }}" />

I understand that the docs are not Django-specific and I can't call a function within a template in Django. So I've tried a lot of different things, but I don't seem to have the trace_id available in my template, nor in the Python environment.

Do I need to add it using a custom template tag? Or is there a middleware I'm not aware of? I've googled for "Django Sentry trace_id" and a lot of other things, searched Github for examples, but didn't find anything that worked.

How do I get that to work? I suspect other Django developers are struggling with that as well, and I hoped it was in the documentation, especially because Django is listed as an integration. I'm willing to contribute this to the docs if appreciated and someone can tell me a recommended way :-)

Expected Result

Docs including best-practice Instructions for connecting Django templates.

Actual Result

🙇‍♂️

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0