From 32423ee82506eb18330841fc94334e2ec68ac208 Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:43:06 +0200 Subject: [PATCH] Rename heartbeats to cron check-ins --- elixir/plug/app/lib/plug_example.ex | 6 +++--- nodejs/express-redis/app/src/app.ts | 8 ++++---- python/flask/app/app.py | 11 ++++++----- ruby/sinatra-puma/app/app.rb | 8 ++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/elixir/plug/app/lib/plug_example.ex b/elixir/plug/app/lib/plug_example.ex index 15def3ef..125eda34 100644 --- a/elixir/plug/app/lib/plug_example.ex +++ b/elixir/plug/app/lib/plug_example.ex @@ -19,12 +19,12 @@ defmodule PlugExample do raise "Whoops!" end - get "/heartbeats" do - Appsignal.heartbeat("custom-heartbeat", fn -> + get "/cron" do + Appsignal.CheckIn.cron("custom-cron-checkin", fn -> :timer.sleep(3000) end) - send_resp(conn, 200, "Heartbeat sent!") + send_resp(conn, 200, "Cron check-in sent!") end get "/custom_instrumentation" do diff --git a/nodejs/express-redis/app/src/app.ts b/nodejs/express-redis/app/src/app.ts index 73e68c71..37b7b040 100644 --- a/nodejs/express-redis/app/src/app.ts +++ b/nodejs/express-redis/app/src/app.ts @@ -1,7 +1,7 @@ import express from "express" import { createClient } from "redis" import ioredis from "ioredis" -import { setTag, setCustomData, expressErrorHandler, WinstonTransport, heartbeat } from "@appsignal/nodejs" +import { setTag, setCustomData, expressErrorHandler, WinstonTransport, checkIn } from "@appsignal/nodejs" import { trace } from "@opentelemetry/api" import cookieParser from "cookie-parser" import winston from "winston" @@ -113,12 +113,12 @@ app.get("/route-param/:id", (req, res) => { res.send(`Route parameter id: ${req.params.id}`) }) -app.get("/heartbeat", async (req, res) => { - await heartbeat("custom-heartbeat", () => +app.get("/cron", async (req, res) => { + await checkIn.cron("custom-cron-checkin", () => new Promise((resolve) => setTimeout(resolve, 3000)) ) - res.send("Heartbeat sent!") + res.send("Cron check-in sent!") }) app.get("/fetch", async (req, res, next) => { diff --git a/python/flask/app/app.py b/python/flask/app/app.py index d58c65b7..b788a913 100644 --- a/python/flask/app/app.py +++ b/python/flask/app/app.py @@ -40,6 +40,7 @@ def home():
  • /hello/<name> → Use parameterised routing
  • /metrics → Emit custom metrics
  • /custom → Use sample data helpers (send a POST request with JSON for params!)
  • +
  • /cron → Send a cron check-in
  • """ @@ -99,14 +100,14 @@ def metrics(): return "

    Emitted some custom metrics!

    " -@app.route("/heartbeat") -def heartbeat(): - from appsignal import Heartbeat +@app.route("/cron") +def cron(): + from appsignal.check_in import Cron - with Heartbeat("custom-heartbeat"): + with Cron("custom-cron-checkin"): sleep(3) - return "

    Sent a heartbeat!

    " + return "

    Sent a cron check-in!

    " @app.route("/custom", methods=["GET", "POST"]) def custom(): diff --git a/ruby/sinatra-puma/app/app.rb b/ruby/sinatra-puma/app/app.rb index 377b3582..261f17b2 100644 --- a/ruby/sinatra-puma/app/app.rb +++ b/ruby/sinatra-puma/app/app.rb @@ -13,8 +13,8 @@
  • Error request
  • Slow streaming request
  • Streaming request with error
  • -
  • Custom heartbeat
  • Multiple errors with custom instrumentation
  • +
  • Custom cron check-in
  • HTML end @@ -73,10 +73,10 @@ class AnotherCustomError < StandardError end end -get "/heartbeat" do - Appsignal.heartbeat("custom-heartbeat") do +get "/cron" do + Appsignal::CheckIn.cron("custom-cron-checkin") do sleep 3 end - "Heartbeat sent!" + "Cron check-in sent!" end