Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry doesn't group logging properly #773

Closed
memee opened this issue Feb 8, 2013 · 6 comments
Closed

Sentry doesn't group logging properly #773

memee opened this issue Feb 8, 2013 · 6 comments

Comments

@memee
Copy link

memee commented Feb 8, 2013

Sentry should group messages logged in this code. The only variable is bundle.obj.order_number.
Instead it creates different groups based on bundle.obj.order_number

from __future__ import unicode_literals

[...]

try:
    fault_service = msg.FaultService.objects.get(
        header__order_number=bundle.obj.fault_number
    )
except msg.FaultService.DoesNotExist:
    logger.warning(
        "Couldn't find FaultService for FaultResource with "
        "order_number = %s" % bundle.obj.order_number
    )
    return None
else:
    return fault_service.pk
@dcramer
Copy link
Member

dcramer commented Feb 8, 2013

Is this getsentry.com, if not, what version of Sentry?

On Thursday, February 7, 2013 at 10:37 PM, memee wrote:

Sentry should group messages logged in this code. The only variable is bundle.obj.order_number.
Instead it creates different groups based on bundle.obj.order_number
from future import unicode_literals [...] try: fault_service = msg.FaultService.objects.get( header__order_number=bundle.obj.fault_number ) except msg.FaultService.DoesNotExist: logger.warning( "Couldn't find FaultService for FaultResource with " "order_number = %s" % bundle.obj.order_number ) return None else: return fault_service.pk (http://fault_service.pk)


Reply to this email directly or view it on GitHub (#773).

@memee
Copy link
Author

memee commented Feb 8, 2013

Sentry 5.3.3

@dcramer
Copy link
Member

dcramer commented Feb 8, 2013

Actually reading this more, the default behavior for a non-exception is to group by message.

In this case, you'd want to change your call from:

logging.warning('foo bar %s' % 'baz')

To be the logging format capable:

logging.warning('foo bar %s', 'baz')

Sentry will handle the grouping of this like you're expecting

On Friday, February 8, 2013 at 1:31 AM, memee wrote:

Sentry 5.3.3


Reply to this email directly or view it on GitHub (#773 (comment)).

@memee
Copy link
Author

memee commented Feb 8, 2013

Thank you, it worked.

@dcramer dcramer closed this as completed Feb 10, 2013
@marjanmo
Copy link

Nice solution, thanks! However, is there a way to also aggregate/group messages, created with .format() method opposed to %s?

@dcramer
Copy link
Member

dcramer commented Sep 12, 2017

@marjanmo not automatically as that is not supported by the python logging module. You should simply use the supported API if you want that behavior.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants