Ejemplo n.º 1
0
# * Description : This file contains code that instruments handled exception and
#                 creates custom tag & context
# *******************************************************************************
# **/

# Import Sentry library
import sentry_sdk
from sentry_sdk.integrations.gcp import GcpIntegration
from sentry_sdk import configure_scope

import os

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

# Fetching value of Environment variable set in Lambda function
env_var_value = os.environ['ENV_VAR']


def cloud_handler(event, context):
    """Cloud function which raises an exception and creates Custom tag &
    context.
    Args:
        event (dict): Event payload.
        context (google.cloud.functions.Context): Metadata for the event.
    """
    with configure_scope() as scope:
Ejemplo n.º 2
0
import json
import requests
import os
import sentry_sdk
from utilobot.helper import make_request, add_document_to_firestore
from sentry_sdk.integrations.gcp import GcpIntegration
from utilobot.bot_functionalities import SongParser, TelegramParseCallbackQueryData, URLShortner
from random import randint
from utilobot.exceptions import BaseFunctionalityException
from sentry_sdk import capture_exception
from google.cloud import firestore
sentry_sdk.init(
    os.environ.get('SENTRY_DSN'),
    integrations=[GcpIntegration(timeout_warning=True)],
    traces_sample_rate=1.0,
)

TELE_TOKEN = os.environ['BOT_TOKEN']
URL = "https://api.telegram.org/bot{}/".format(TELE_TOKEN)


def sendChatAction(chat_action, chat_id):
    assert chat_action in [
        'typing', 'upload_photo', 'record_video', 'upload_video',
        'record_audio', 'upload_audio', 'upload_document', 'find_location',
        'record_video_note', 'upload_video_note'
    ], "Unidentified chat action detected!"
    args = {}
    args['chat_id'] = chat_id
    args['action'] = chat_action
    request, session = make_request("post", URL + "sendChatAction", None,