Skip to content

Commit

Permalink
Rename heartbeats to cron check-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
unflxw committed Aug 6, 2024
1 parent 64bcf6f commit 32423ee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions elixir/plug/app/lib/plug_example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions nodejs/express-redis/app/src/app.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -113,12 +113,12 @@ app.get("/route-param/:id", (req, res) => {
res.send(`Route parameter <code>id</code>: ${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) => {
Expand Down
11 changes: 6 additions & 5 deletions python/flask/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def home():
<li><a href="/hello/world"><kbd>/hello/&lt;name&gt;</kbd> &rarr; Use parameterised routing</a></li>
<li><a href="/metrics"><kbd>/metrics</kbd> &rarr; Emit custom metrics</a></li>
<li><a href="/custom"><kbd>/custom</kbd> &rarr; Use sample data helpers (send a POST request with JSON for params!)</a></li>
<li><a href="/cron"><kbd>/cron</kbd> &rarr; Send a cron check-in</a></li>
</ul>
"""

Expand Down Expand Up @@ -99,14 +100,14 @@ def metrics():

return "<p>Emitted some custom metrics!</p>"

@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 "<p>Sent a heartbeat!</p>"
return "<p>Sent a cron check-in!</p>"

@app.route("/custom", methods=["GET", "POST"])
def custom():
Expand Down
8 changes: 4 additions & 4 deletions ruby/sinatra-puma/app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<li><a href="/error?time=#{time}">Error request</a></li>
<li><a href="/stream/slow?time=#{time}">Slow streaming request</a></li>
<li><a href="/stream/error?time=#{time}">Streaming request with error</a></li>
<li><a href="/heartbeat?time=#{time}">Custom heartbeat</a></li>
<li><a href="/errors?time=#{time}">Multiple errors with custom instrumentation</a></li>
<li><a href="/cron?time=#{time}">Custom cron check-in</a></li>
</ul>
HTML
end
Expand Down Expand Up @@ -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

0 comments on commit 32423ee

Please sign in to comment.