Skip to content

Commit f22c4de

Browse files
committed
Update/expand context methods for client recommendations
1 parent 5c74399 commit f22c4de

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

docs/developer/client/index.rst

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,35 @@ The client should send the following upstream for ``tags``::
544544
],
545545
}
546546

547-
If your platform supports it, block level context should also be available::
547+
You should also provide relevant contextual interfaces. These should last for the lifecycle of a request, and the general interface is "bind some kind of context", and then at the end of a request lifecycle, clear any present context.
548+
549+
This interface consists of *_context methods, as well as a "clear context" method. The following is an example API which is implemented in most clients:
550+
551+
::
552+
553+
# Bind sentry.interfaces.User
554+
client.user_context({
555+
'email': 'foo@example.com',
556+
})
557+
558+
# Merge in additional tag context
559+
client.tags_context({
560+
'key': 'value',
561+
})
562+
563+
# Merge in additional extra context
564+
client.extra_context({
565+
'key': 'value',
566+
})
567+
568+
# Clear context
569+
client.context.clear()
570+
571+
Some additional examples of context helpers which might be relevant:
572+
573+
- http_context(data) -- bind sentry.interfaces.Http
574+
- wsgi_context(env) -- bind http_context based on a wsgi environment
548575

549-
with client.context({'tags': {'foo': 'bar'}}):
550-
# ...
551576

552577
Variable Size
553578
-------------

0 commit comments

Comments
 (0)