Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@anovis
Copy link
Collaborator

@anovis anovis commented Dec 21, 2023

    from goblet.alerts.alerts import BackendAlert, PubSubDLQAlert, UptimeAlert
    from goblet.alerts.alert_conditions import MetricCondition, CustomMetricCondition, LogMatchCondition, PubSubDLQCondition, UptimeCondition

        app = Goblet(function_name="alerts-test")

        metric_alert = BackendAlert(
            "metric",
            conditions=[
                MetricCondition(
                    "test",
                    metric="cloudfunctions.googleapis.com/function/execution_count",
                    value=10,
                )
            ],
        )
        log_alert = BackendAlert(
            "error",
            conditions=[LogMatchCondition("error", "severity>=ERROR")],
        )
        custom_alert = BackendAlert(
            "custom",
            conditions=[
                CustomMetricCondition(
                    "custom",
                    metric_filter="severity=(ERROR OR CRITICAL OR ALERT OR EMERGENCY) httpRequest.status=(500 OR 501 OR 502 OR 503 OR 504)",
                    value=10,
                )
            ],
        )

        app.alert(metric_alert)
        app.alert(log_alert)
        app.alert(custom_alert)

        @app.pubsub_subscription(
            "test",
            dlq=True,
            dlq_alerts=[
                PubSubDLQAlert(
                    "pubsubdlq",
                    conditions=[
                        PubSubDLQCondition(
                            "pubsubdlq",
                            subscription_id="pubsub-deploy-subscription",
                        )
                    ],
                )
            ],
        )
       def pubsub(data):
            return true

@app.uptime(timeout="30s",alerts=[UptimeAlert("uptime", conditions=[UptimeCondition("uptime")])])
def uptime_check():
    app.log.info("success")
    return "success"

@codecov
Copy link

codecov bot commented Dec 21, 2023

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (d35acc7) 89.63% compared to head (6fbef8a) 89.63%.

Files Patch % Lines
goblet/alerts/alerts.py 89.06% 14 Missing ⚠️
goblet/app.py 83.33% 3 Missing ⚠️
goblet/resource_manager.py 75.00% 2 Missing ⚠️
goblet/tests/test_uptime.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #472    +/-   ##
========================================
  Coverage   89.63%   89.63%            
========================================
  Files          67       69     +2     
  Lines        6212     6332   +120     
========================================
+ Hits         5568     5676   +108     
- Misses        644      656    +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anovis anovis merged commit 23c7ac8 into main Jan 3, 2024
@anovis anovis deleted the alerts-refactor branch January 3, 2024 15:35
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.

2 participants