structlog-sentry-lambda
Description
This repository is a fork of https://github.com/TeoZosa/structlog-sentry-logger and all credits for this solution should go to @TeoZosa !!!
Use this ONLY if you are planning to integrate this into AWS Lambda or AWS Fargate.
For any other use-case, check the original repository.
Notes
Sentry SDK Initialization is NOT done within this library.
If you're going to use this library, you need to ensure that the Sentry SDK is properly initialized before importing the library.
Example for a standard AWS Lambda function:
filename = libraries/sentry.py
import os
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN'),
integrations= [AwsLambdaIntegration(timeout_warning=True)],
environment=os.environ.get('Workspace'),
send_default_pii=True,
traces_sample_rate=0.0,
release=os.environ.get('SENTRY_RELEASE')
)
filename = libraries/logger.py
import simplejson as json
import structlog_sentry_lambda
SENTRY_LOGGER = structlog_sentry_lambda.get_logger()
logger = SENTRY_LOGGER.bind()
def debug(log_message):
logger.debug(json.dumps(log_message, sort_keys=True, default=str))
def error(log_message):
logger.error(json.dumps(log_message, sort_keys=True, default=str))
def exception(log_message):
logger.exception(json.dumps(log_message, sort_keys=True, default=str))
def warning(log_message):
logger.warning(json.dumps(log_message, sort_keys=True, default=str))
def info(log_message):
logger.info(json.dumps(log_message, sort_keys=True, default=str))
def main(log_message):
logger.info(json.dumps(log_message, sort_keys=True, default=str))
def log(log_message):
logger.info(json.dumps(log_message, sort_keys=True, default=str))
filename = index.py
import sys
sys.path.append('../libraries/')
from libraries import sentry
from libraries import logger
def main(event, context):
logger.info(event)
logger.error("Trigger an alert in Sentry")
return True
Metadata
Release files for structlog-sentry-lambda 1.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| structlog-sentry-lambda-1.4.2.tar.gz | 14.2 kB | Without provenance | Details for structlog-sentry-lambda-1.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| structlog_sentry_lambda-1.4.2-py3-none-any.whl | Python 3 | none | any | Details for structlog_sentry_lambda-1.4.2-py3-none-any.whl |
Total release size: 27.9 kB
Release files / structlog-sentry-lambda-1.4.2.tar.gz
| Download URL | structlog-sentry-lambda-1.4.2.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6d2ea7e9f139e4d0d305df647919802c9560023c2a89833a188b0c9b5c4ad76
|
|
BLAKE2b-256 checksum How to use checksums |
2f8a77ddfc180b73c42bf3d1fcc4c6c7f47cf836b51df79cdd241bd195240eb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / structlog_sentry_lambda-1.4.2-py3-none-any.whl
| Download URL | structlog_sentry_lambda-1.4.2-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5983692ccc77748ab16cb4d95f6776f22fe98d6c388735cdefde806748781f0b
|
|
BLAKE2b-256 checksum How to use checksums |
5f5becc51431478beadfe4d74cba0890f5a00d7a499ea5653dbf75966c5ee5a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for structlog-sentry-lambda 1.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.