Skip to content

Conversation

@daibhin
Copy link
Contributor

@daibhin daibhin commented Jun 9, 2025

We could be doing a better job at instrumenting Django requests with path and user info

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Enhanced Django integration with additional request context capture and broader version compatibility, focusing on user and path information extraction for better error tracking.

  • Expanding version support to Django 1.8+ introduces potential security risks, should verify security implications for older versions
  • Header lookup change from lowercase to capitalized (e.g., 'Traceparent') may break existing implementations
  • Added valuable request context (request.path, user ID, email) for better error diagnostics
  • Consider privacy implications of automatically capturing user email addresses in error reports
  • Tests now use Django's RequestFactory instead of mocks, providing more realistic coverage

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +81 to +82
traceparent = headers.get("Traceparent")
tracestate = headers.get("Tracestate")
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Header case sensitivity change may break existing integrations. HTTP headers should be case-insensitive per RFC 2616. Use case-insensitive lookup like .get('traceparent') or .get('Traceparent')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests were failing with traceparent so I went with the capitalized version which works (even when specified as traceparent in the request)

# Extract traceparent and tracestate headers
traceparent = headers.get("traceparent")
tracestate = headers.get("tracestate")
traceparent = headers.get("Traceparent")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Django has been normalizing header keys since 2.2 (source: ChatGPT)

@daibhin daibhin requested review from a team, hpouillot and oliverb123 June 9, 2025 11:04
@daibhin daibhin mentioned this pull request Jun 9, 2025
@daibhin daibhin merged commit f17ebfa into master Jun 9, 2025
6 checks passed
@daibhin daibhin deleted the dn-chore/integration-context branch June 9, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants