Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename heartbeats to cron check-ins #221

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion ruby/sinatra-puma/app/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
environment "production"

# Set up socket location
bind "unix:///#{shared_dir}/sockets/puma.sock"
bind "unix:///var/run/puma.sock"

# stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true

Expand Down