Skip to content

Conversation

@groovecoder
Copy link
Member

No description provided.

emails/views.py Outdated
relay_address.user.email.encode('utf-8')
).hexdigest(),
})
logger.info(log_string)
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems like ti should work, but the Fields shows as an empty {} ?

{"Timestamp": 1584630352479602944, "Type": "events", "Logger": "fx-private-relay", "Hostname": "groovetop", "EnvVersion": "2.0", "Severity": 6, "Pid": 98734, "Fields": {}}

Copy link

Choose a reason for hiding this comment

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

What happens if you pass in the dict directly instead of json dumping it first?

Copy link
Member Author

Choose a reason for hiding this comment

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

    logger.info({
        'event_type': 'email_relay',
        'relay_address_id': relay_address.id,
        'relay_address': sha256(local_portion.encode('utf-8')).hexdigest(),
        'real_address': sha256(
            relay_address.user.email.encode('utf-8')
        ).hexdigest(),
    })

has the same result. :( Fields comes up empty:

{"Timestamp": 1584632026345210112, "Type": "events", "Logger": "fx-private-relay", "Hostname": "groovetop", "EnvVersion": "2.0", "Severity": 6, "Pid": 98998, "Fields": {}}

Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I filed mozilla-services/python-dockerflow#40 for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unless/until mozilla-services/python-dockerflow#40 is fixed, I updated this to include a json: prefix so the log formatter won't skip it.

If the fraud pipeline log ingestion can parse this, I think we can merge this as-is, and if that up-stream issue is fixed, I'll update the code here later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Output is now:

{"Timestamp": 1584716908799840000, "Type": "events", "Logger": "fx-private-relay", "Hostname": "groovetop", "EnvVersion": "2.0", "Severity": 6, "Pid": 7487, "Fields": {"msg": "json: {\"event_type\": \"email_relay\", \"relay_address_id\": 18, \"relay_address\": \"cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90\", \"real_address\": \"f46fbc15047cae1e3b8f098d125372f713e99d974f57d7c0e7d8a1de691c1733\"}"}}

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, learned I can pass extra={} in the logger.info call to make the dictionary values show up in Fields ...

{"Timestamp": 1584720542840398080, "Type": "events", "Logger": "fx-private-relay", "Hostname": "groovetop", "EnvVersion": "2.0", "Severity": 6, "Pid": 9438, "Fields": {"relay_address_id": 18, "relay_address": "cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90", "real_address": "f46fbc15047cae1e3b8f098d125372f713e99d974f57d7c0e7d8a1de691c1733", "msg": "email_relay"}}

@groovecoder groovecoder force-pushed the add-relay-event-logging-81 branch from 817366f to d3206d2 Compare March 20, 2020 15:06
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