예제 #1
0
def init(dsn: str = None, context: dict = None):
    if not dsn:
        dsn = config("SENTRY_DSN")
    sentry_sdk.init(dsn=dsn, integrations=[AwsLambdaIntegration()])
    if context:
        with sentry_sdk.configure_scope() as scope:
            _set_tags(scope, context)
예제 #2
0
def initialize_sentry() -> None:
    """Initialize Sentry monitoring.

    To enable Sentry, please define
    settings "project.sentry_dsn" or
    environment SENTRY_ENDPOINT.

    """
    endpoint = settings["project.sentry_dsn"]
    if not endpoint:
        logger.warning("Sentry not initialized.")
        return

    toml_path = Path().cwd().joinpath("pyproject.toml")
    with open(str(toml_path), "r") as file:
        data = Cut(toml.load(file))
        current_version = data["tool.poetry.version"]

    try:
        sentry_sdk.init(
            dsn=endpoint,
            integrations=[AwsLambdaIntegration()],
            environment=settings.stela_options.current_environment,
            release=current_version,
        )
        logger.info("Sentry initialized.")
    except BadDsn as error:
        logger.error(f"Error when initializing Sentry: {error}")
예제 #3
0
def init_sentry(cli=False):
    if cli:
        return

    sentry_sdk.init(
        dsn="https://[email protected]/2153273",
        integrations=[AwsLambdaIntegration()],
    )
예제 #4
0
def sentry_init():  # pragma: no cover
    try:
        import sentry_sdk
        from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
    except ImportError:
        pass
    else:
        # The Sentry DSN is set in the SENTRY_DSN environmental variable
        sentry_sdk.init(integrations=[AwsLambdaIntegration()])
예제 #5
0
def init_sentry():
    sentry_sdk.init(
        dsn=settings.sentry_dsn,
        integrations=[AwsLambdaIntegration()],
        traces_sample_rate=1.0,  # adjust the sample rate in production as needed
        environment=settings.environment,
        release=settings.vcs_rev,
        send_default_pii=True,
    )
예제 #6
0
def init():
    Config.init()
    registry.initialize()

    sentry_sdk.init(
        dsn=Config.Constants.SENTRY_DSN,
        environment=Config.Constants.SENTRY_ENVIRONMENT,
        integrations=[AwsLambdaIntegration()],
        traces_sample_rate=1.0,  # adjust the sample rate in production as needed
    )
예제 #7
0
def initialise_sentry():
    global sentry_initialised
    if os.environ.get("SENTRY_DSN", "") and not sentry_initialised:
        sentry_sdk.init(
            os.environ.get("SENTRY_DSN"),
            integrations=[
                AwsLambdaIntegration(),
                FlaskIntegration(),
                AioHttpIntegration(),
            ],
            traces_sample_rate=0.01,
        )
        sentry_initialised = True
예제 #8
0
def configure_sentry():
    if not has_sentry:
        return

    secret_id = os.getenv('SENTRY_DSN_SECRET_ID')
    if not secret_id:
        return

    # Pull from secrets manager
    secrets_manager = boto3.client('secretsmanager')
    dsn = secrets_manager.get_secret_value(secret_id)['SecretString']
    if dsn:
        sentry_sdk.init(
            dsn=dsn,
            integrations=[AwsLambdaIntegration()],
            environment=os.getenv('Stage')
        )
예제 #9
0
def init_monitoring():
    dsn = environ.get(MONITORING_DSN)
    env = environ.get(OPERATING_ENV)

    if not dsn:
        warning(f'DSN not found in envronment under key {MONITORING_DSN}')
        return

    info(f'Configuring monitoring via DSN: {dsn}')
    init(
        dsn=dsn,
        integrations=[AwsLambdaIntegration()],
        release=f'v{version}',
        send_default_pii=False,
        traces_sample_rate=0.50,
        environment=env,
        _experiments={'auto_enabling_integrations': True},
    )
예제 #10
0
def create_app(config_object=None):
    """
    FLASK_ENV=development FLASK_APP=apis.subscriptions.app flask run
    """
    if config_object is None:
        config_object = Config
    app = Flask(__name__)
    app.config.from_object(config_object)
    SENTRY_DSN = app.config.get("SENTRY_DSN")
    if SENTRY_DSN:
        import sentry_sdk
        from sentry_sdk.integrations.flask import FlaskIntegration
        from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
        sentry_sdk.init(SENTRY_DSN, integrations=[FlaskIntegration(), AwsLambdaIntegration()])
    app.register_blueprint(index.blueprint)
    app.register_blueprint(subscriptions.blueprint)
    handlers.register(app)
    return app
예제 #11
0
def run(event, context):
    """ run the process to retrieve and process web kiosk metadata """
    if config != {}:
        sentry_error_dsn = config['sentry']['dsn']
        sentry_environment = config['sentry']['environment']
        init(sentry_error_dsn,
             environment=sentry_environment,
             integrations=[AwsLambdaIntegration()])
        web_kiosk_class = process_web_kiosk_metadata(config)
        xml_as_string = web_kiosk_class.get_snite_composite_mets_metadata()
        if xml_as_string > '':
            clean_up_as_we_go = True
            web_kiosk_class.process_snite_composite_mets_metadata(
                clean_up_as_we_go)
        else:
            print('Nothing to process')
    else:
        print('No configuration defined.  Unable to continue.')
    return event
예제 #12
0
def create_app(config_object=None):
    """
    FLASK_ENV=development FLASK_APP=apis.document.app flask run --port=5003
    """
    if config_object is None:
        config_object = Config
    app = Flask(__name__)
    app.request_class = BigMemoryRequest
    app.config.from_object(config_object)
    SENTRY_DSN = app.config.get("SENTRY_DSN")
    if SENTRY_DSN:
        import sentry_sdk
        from sentry_sdk.integrations.flask import FlaskIntegration
        from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
        sentry_sdk.init(SENTRY_DSN, integrations=[FlaskIntegration(), AwsLambdaIntegration()])
    app.register_blueprint(index.blueprint)
    app.register_blueprint(documents.blueprint)
    handlers.register(app)
    register_specs(app, spec, views=('document_post', 'document_fetch',))
    return app
예제 #13
0
def create_app(config_object=None):
    """
    FLASK_ENV=development FLASK_APP=message_api.app flask run --port=5001
    """
    if config_object is None:
        config_object = Config
    app = Flask(__name__)
    app.config.from_object(config_object)
    SENTRY_DSN = app.config.get("SENTRY_DSN")
    if SENTRY_DSN:
        import sentry_sdk
        from sentry_sdk.integrations.flask import FlaskIntegration
        from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
        sentry_sdk.init(
            SENTRY_DSN,
            integrations=[FlaskIntegration(),
                          AwsLambdaIntegration()])
    app.register_blueprint(index.blueprint)
    app.register_blueprint(message.blueprint)
    handlers.register(app)
    register_specs(app,
                   spec,
                   views=('message_retrieve', 'message_patch', 'message_post'))
    return app
def init(run_id=None):
    '''
    1. Init sentry exception tracking
    2. Improve default log formatting
    3. Silence noise logger(s)

    :param run_id: Parameter can be provided as reference to find all logs
    that belong to a single run of a serverless function
    '''
    sentry_config = _config.get_config().get('sentry')
    if not sentry_config:
        return

    sentry_key = sentry_config['key']
    sentry_project = sentry_config['project']

    if not run_id:
        run_id = _generate_id()

    log_format = '%(levelname)s:\n%(name)s:{}: %(message)s'.format(run_id)
    if _config.get_env() in ['staging', 'production']:
        log_format = log_format.replace('\n', '\r')
    logging.basicConfig(level=logging.INFO, format=log_format)

    # silence botocore logs
    logging.getLogger('botocore').setLevel(logging.WARNING)


    if _config.get_env() in ['staging', 'production']:
        log_format = log_format.replace('\n', '\r')
    logging.basicConfig(level=logging.INFO, format=log_format)

    sentry_sdk.init(
        dsn="https://{key}@sentry.io/{project}".format(key=sentry_key, project=sentry_project),
        integrations=[AwsLambdaIntegration()]
    )
예제 #15
0
import logging
from logging.config import dictConfig

import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

from intergov.conf import env_bool, env

SENTRY_DSN = env('SENTRY_DSN', default=None)

if SENTRY_DSN:  # pragma: no cover
    sentry_sdk.init(
        dsn=SENTRY_DSN,
        integrations=[LoggingIntegration(),
                      AwsLambdaIntegration()])

    with sentry_sdk.configure_scope() as scope:
        scope.set_tag("service", "intergov")
        scope.set_tag("country", env("ICL_APP_COUNTRY", default=""))

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(asctime)-15s %(levelname)s [%(name)s] %(message)s'
        }
    },
    'handlers': {
        'console': {
예제 #16
0
# /**
# *******************************************************************************
# * File name   : network_error_wrong_address.py
# * Description : This file contains code that instruments calling APIs of a
# *               Flask App and producing Network Connection error using wrong
# *               IP Address.
# *******************************************************************************
# **/

# Import Sentry library
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
import requests

# Configure Sentry SDK
sentry_sdk.init(dsn="<your DSN>", integrations=[AwsLambdaIntegration()])

# Constants
CORRECT_PORT = "80"
WRONG_IP = "192.0.2.1"  # Dummy IP which does not exist
WRONG_URL = "http://" + WRONG_IP + ":" + CORRECT_PORT
API = "/test"  # Dummy API


def lambda_handler(event, context):
    """Lambda function which does REST API calls ond returns url.

    Args:
        event (dict): Parameter to pass in event data to the handler.
        context (bootstrap.LambdaContext): Parameter to provide runtime information to the handler.
예제 #17
0
def _init_sentry():
    if 'SENTRY_DSN' in os.environ:
        sentry_sdk.init(dsn=os.environ['SENTRY_DSN'], integrations=[AwsLambdaIntegration()])
# AWS Lambda Handler
#
# Use Dockerfile.lambda to package/upload (see the instructions in the Dockerfile)
#
import json, os
import boto3, botocore

# TODO setup sentry and add to AWS Lambda Env
if "SENTRY_DSN" in os.environ:
    import sentry_sdk
    from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
    sentry_sdk.init(dsn=os.environ["SENTRY_DSN"],
                    integrations=[AwsLambdaIntegration(timeout_warning=True)])


def lambda_handler(event, context, local_output=False):
    # ALWAYs store token in env, not in code!
    salesforce_token = os.environ.get("SALESFORCE_TOKEN", None)

    if salesforce_token:
        pass  #TODO query salesforce
    else:
        data = json.loads(open("data/211sample.json").read())

    # TODO process Data
    result = [o for o in data if o['service']['Service_Status__c'] == "Active"]

    # TODO push to S3 location
    output_filename = "sandiego-foodmap-data.json"

    if local_output:
예제 #19
0
import boto3
import logging
import datetime
import os
from slugify import slugify
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

sentry_sdk.init(dsn=os.environ.get('SENTRY_DSN'), integrations=[AwsLambdaIntegration()])

from ..utils.common_db_utils import chunks, BATCH_WRITE_CHUNK_SIZE
from common.utils.idea_utils import sanitize_idea_content, prepare_idea_tags_for_put_request, \
    prepare_idea_tags_for_delete_request, strip_html


# logger = logging.getLogger()
# logger.setLevel(logging.INFO)


def endpoint(event, lambda_context):
    ctx = event.get('ctx')
    arguments = ctx.get('arguments')
    title = arguments.get('title')
    slug = slugify(title)
    content = sanitize_idea_content(arguments.get('content', None))
    stripped_content = None
    if content:
        stripped_content = strip_html(content)

    idea_id = arguments.get('ideaId', None)
    idea_owner_id = arguments.get('ideaOwnerId', None)
예제 #20
0
    def init_logger(self):
        """
        Initialize the logger.  Call exactly once.
        """

        log_formatter = BalsaFormatter(self.log_formatter_string)

        assert self.name is not None
        assert self.author is not None
        self.handlers = {}
        if self.is_root:
            self.log = logging.getLogger()
        else:
            self.log = logging.getLogger(self.name)
        if not self.propagate:
            self.log.propagate = False

        # set the root log level
        if self.verbose:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.INFO)

        if self.log.hasHandlers():
            self.log.info("Logger already initialized.")

        # use turn off file logging, e.g. for cloud environments where it's not recommended and/or possible to write to the local file system
        if self.use_file_logging:
            # create file handler
            if self.log_directory is None:
                self.log_directory = Path(
                    appdirs.user_log_dir(self.name, self.author))

            if self.log_directory is not None:

                if isinstance(self.log_directory, str):
                    self.log_directory = Path(self.log_directory)

                self.log_directory.mkdir(parents=True, exist_ok=True)
                if self.delete_existing_log_files:
                    # need to glob since there are potentially many files due to the "rotating" file handler
                    for file_path in Path.glob(self.log_directory,
                                               f"*{self.log_extension}"):
                        try:
                            file_path.unlink()
                        except OSError:
                            pass

                if self.instance_name is None:
                    file_name = f"{self.name}{self.log_extension}"
                else:
                    file_name = f"{self.name}_{self.instance_name}{self.log_extension}"
                self.log_path = Path(self.log_directory, file_name)

                file_handler = logging.handlers.RotatingFileHandler(
                    self.log_path,
                    maxBytes=self.max_bytes,
                    backupCount=self.backup_count)
                file_handler.setFormatter(log_formatter)
                if self.verbose:
                    file_handler.setLevel(logging.DEBUG)
                else:
                    file_handler.setLevel(logging.INFO)
                self.log.addHandler(file_handler)
                self.handlers[HandlerType.File] = file_handler
                self.log.info(
                    f'log file path : "{self.log_path}" ("{self.log_path.absolute()}")'
                )

        if self.gui:
            # GUI will only pop up a dialog box - it's important that GUI apps not try to output to stdout or stderr
            # since that would likely cause a permissions error.
            dialog_box_handler = DialogBoxHandler(self.rate_limits)
            if self.verbose:
                dialog_box_handler.setLevel(logging.WARNING)
            else:
                dialog_box_handler.setLevel(logging.ERROR)
            self.log.addHandler(dialog_box_handler)
            self.handlers[HandlerType.DialogBox] = dialog_box_handler

            self.set_std()  # redirect stdout and stderr to log
        else:
            console_handler = logging.StreamHandler()
            # prefix for things like "\n" or "\r"
            console_handler.setFormatter(
                BalsaFormatter(
                    f"{self.log_console_prefix}{self.log_formatter_string}"))
            if self.verbose:
                console_handler.setLevel(logging.INFO)
            else:
                console_handler.setLevel(logging.WARNING)
            self.log.addHandler(console_handler)
            self.handlers[HandlerType.Console] = console_handler

        string_list_handler = BalsaStringListHandler(
            self.max_string_list_entries)
        string_list_handler.setFormatter(log_formatter)
        string_list_handler.setLevel(logging.INFO)
        self.log.addHandler(string_list_handler)
        self.handlers[HandlerType.StringList] = string_list_handler

        # setting up Sentry error handling
        # For the Client to work you need a SENTRY_DSN environmental variable set, or one must be provided.
        if self.use_sentry:

            if self.sentry_max_string_len is not None:
                sentry_sdk.utils.MAX_STRING_LENGTH = self.sentry_max_string_len

            sample_rate = 0.0 if self.inhibit_cloud_services else 1.0
            integrations = []
            if self.use_sentry_django:
                from sentry_sdk.integrations.django import DjangoIntegration

                integrations.append(DjangoIntegration())
            if self.use_sentry_flask:
                from sentry_sdk.integrations.flask import FlaskIntegration

                integrations.append(FlaskIntegration())
            if self.use_sentry_lambda:
                from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

                integrations.append(AwsLambdaIntegration())
            if self.use_sentry_sqlalchemy:
                from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration

                integrations.append(SqlalchemyIntegration())
            if self.use_sentry_celery:
                from sentry_sdk.integrations.celery import CeleryIntegration

                integrations.append(CeleryIntegration())

            if self.sentry_dsn is None:
                if (sentry_dsn := self.get_sentry_dsn_via_env_var()) is None:
                    raise ValueError(
                        "Missing Sentry DSN - either set as an environmental variable or a parameter to the Balsa constructor"
                    )
                else:
                    sentry_sdk.init(
                        dsn=sentry_dsn,
                        sample_rate=sample_rate,
                        integrations=integrations,
                    )
            else:
                sentry_sdk.init(
                    dsn=self.sentry_dsn,
                    sample_rate=sample_rate,
                    integrations=integrations,
                )
예제 #21
0
        storage,
    )
    from common.serverless import utils
    from common.serverless.error_handling import pubsub_function
    from tess import Tesseract

    # only initialize sentry on serverless
    # pylint: disable=import-error
    import sentry_sdk
    from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
    from sentry_sdk.integrations.redis import RedisIntegration

    # pylint: enable=import-error

    sentry_sdk.init(
        dsn=env("SENTRY_DSN"), integrations=[AwsLambdaIntegration(), RedisIntegration()]
    )


REDIS = utils.get_redis()

OCR_TOPIC = publisher.topic_path(
    "documentcloud", env.str("OCR_TOPIC", default="ocr-extraction-dev")
)
TEXT_POSITION_EXTRACT_TOPIC = publisher.topic_path(
    "documentcloud",
    env.str("TEXT_POSITION_EXTRACT_TOPIC", default="text-position-extraction"),
)
TEXT_POSITION_BATCH = env.int(
    "TEXT_POSITION_BATCH", 3
)  # Number of pages to pull text positions from with each function
예제 #22
0
import json
import boto3
import datetime
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
# Automatically report all uncaught exceptions
sentry_sdk.init(dsn="url_sentry", integrations=[AwsLambdaIntegration()])


# from the type create a json, that is the config file, the json file upload on s3 will trigger the activation of the creation of the video through the video lambda function
def create_json(type, time):  #type è uno dei valori (settimana,mese,year)
    json_dict = {}
    json_dict["info_video"] = {}
    if type == 'year':
        json_dict["year"] = str(time.year)
        json_dict["fps"] = "10"
        json_dict["grayscale"] = "0"
        json_dict["frame_width"] = "1280"
        json_dict["frame_height"] = "720"
        json_dict["info_video"]["name"] = "year"
        json_dict["info_video"]["format"] = "H264"
        json_dict["info_video"]["extension"] = "mp4"

    elif type == 'month':
        end = time
        delta = datetime.timedelta(days=end.day - 1)
        begin = end - delta
        json_dict["begin_date"] = begin.strftime('%Y-%m-%d')
        json_dict["end_date"] = end.strftime('%Y-%m-%d')
        json_dict["fps"] = "3"
        json_dict["grayscale"] = "0"
예제 #23
0
def setup_sentry():
  sentry_sdk.init(
    dsn="https://[email protected]/1443649",
    integrations=[AwsLambdaIntegration()]
  )
예제 #24
0
class InstanceRefreshInProgress(LambdaError):
    pass


AUTO_SCALING_GROUP_NAME = environ['AUTO_SCALING_GROUP_NAME']
DESCRIBE_INSTANCE_REFRESHES_MAX_RECORDS = int(
    environ['DESCRIBE_INSTANCE_REFRESHES_MAX_RECORDS'])
FINISHED_INSTANCE_REFRESH_STATES = ('Cancelled', 'Failed', 'Successful')
LOGGING_LEVEL = environ.get('LOGGING_LEVEL', logging.INFO)
REFRESH_INSTANCE_WARMUP = int(environ['REFRESH_INSTANCE_WARMUP'])
REFRESH_MIN_HEALTHY_PERCENTAGE = int(environ['REFRESH_MIN_HEALTHY_PERCENTAGE'])
SSM_PARAMETER_NAME = environ['SSM_PARAMETER_NAME']
SENTRY_DSN = environ.get('SENTRY_DSN')

if SENTRY_DSN:
    sentry_sdk.init(SENTRY_DSN, integrations=[AwsLambdaIntegration()])

logging.config.dictConfig({
    'version': 1,
    'formatters': {
        'default': {
            'format': '[%(asctime)s] <%(levelname)s>: %(message)s',
        },
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'default',
        },
    },
    'root': {
예제 #25
0
import json
import logging
import config

from viberbot import Api
from viberbot.api.bot_configuration import BotConfiguration

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

from bot import configure_viber, viber_response

sentry_sdk.init(
    dsn=config.sentry_dsn,
    environment=config.stage,
    integrations=[AwsLambdaIntegration()],
)

# Logging is cool!
logger = logging.getLogger()
if logger.handlers:
    for handler in logger.handlers:
        logger.removeHandler(handler)

logging.basicConfig(level=logging.INFO)

OK_RESPONSE = {
    "statusCode": 200,
    "headers": {
        "Content-Type": "application/json"
    },
예제 #26
0
import boto3, jinja2, json, urllib, datetime, random
from twython import Twython
import credentials

import sentry_sdk, sentryDSN
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

#capture all unhandled exceptions
sentry_sdk.init(sentryDSN.DSN, integrations=[AwsLambdaIntegration()])


def getTweetID(device_UUID, chart_period, chart_type):
    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table('tweetIDs')

    response = table.query(ConsistentRead=True,
                           ProjectionExpression=chart_type,
                           KeyConditionExpression=
                           'device_UUID = :devUUID AND chart_period = :period',
                           ExpressionAttributeValues={
                               ':devUUID': device_UUID,
                               ':period': chart_period,
                           })
    try:
        return response['Items'][0][chart_type]
    except:
        return -1


def uploadTweetID(device_UUID, chart_period, chart_type, tweetID):
    dynamodb = boto3.resource('dynamodb')
예제 #27
0
import os
import json
import logging

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

from book_feed.process_books import process_books, merge_similar_books

if not os.getenv("IS_LOCAL"):
    sentry_sdk.init(integrations=[AwsLambdaIntegration()], )

logger = logging.getLogger()
logging.getLogger("botocore").setLevel(logging.WARNING)
logging.getLogger("boto3").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
if os.getenv("IS_LOCAL"):
    logging.basicConfig(level=logging.DEBUG)
    logger.setLevel(logging.DEBUG)
else:
    logging.basicConfig(level=logging.INFO)
    logger.setLevel(logging.INFO)


def handle_book_offers_trigger(event, context):
    namespace = event.get("namespace")
    offer_filter = {}
    if namespace:
        offer_filter["dealer"] = namespace
    return json.dumps(process_books(offer_filter), default=str)
예제 #28
0
def setup_sentry(SENTRY_DSN):
    sentry_sdk.init(dsn=SENTRY_DSN, integrations=[AwsLambdaIntegration()])
예제 #29
0
"""
Just a wrapper around the actual script (cleanup) for serverless,
but adds sentry support
"""
import os

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

import cleanup

sentry_sdk.init(dsn=os.getenv("SENTRY_DSN"), integrations=[AwsLambdaIntegration()])


def run(event, context):
    cleanup.run()
예제 #30
0
)
from noiseblend.exception_handlers import (
    CatchAllExceptionHandler,
    NoiseblendAuthExceptionHandler,
    NoiseblendExceptionHandler,
    NoiseblendUnknownSlotExceptionHandler,
)
from noiseblend.helpers import cap, listify
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

logger = logging.getLogger()
logger.setLevel(logging.INFO)

patch_all()
sentry_dsn_file = Path(__file__).parent / "secrets" / "sentry_dsn"
sentry_sdk.init(sentry_dsn_file.read_text(), integrations=[AwsLambdaIntegration()])

sb = NoiseblendSkillBuilder(table_name="noiseblend", auto_create_table=False)


class NotImplementedHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return True

    def handle(self, handler_input):
        handler_input.response_builder.speak(NOT_IMPLEMENTED_YET)
        return handler_input.response_builder.response


class DislikeIntentHandler(NoiseblendRequestHandler):
    # pylint: disable=arguments-differ