Skip to content

Commit

Permalink
feat(uptime): Update sentry-kafka-schemas, remove monitor ids and a…
Browse files Browse the repository at this point in the history
…dd subscription_id (#56)

This updates the checker to use `subscription_id` instead of monitor ids
  • Loading branch information
wedamija authored Jun 14, 2024
1 parent a2c93ee commit 0884632
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ thiserror = "1.0.61"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["json"] }
console = "0.15.8"
sentry-kafka-schemas = "0.1.91"
sentry-kafka-schemas = "0.1.93"

[patch.crates-io]
rdkafka = { git = "https://github.com/fede1024/rust-rdkafka" }
Expand Down
8 changes: 5 additions & 3 deletions src/checker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use reqwest::{Client, ClientBuilder, Response, StatusCode};
use std::{error::Error, time::Duration};
use tokio::time::Instant;
use uuid::Uuid;
use uuid::{Uuid, uuid};

use crate::types::{
CheckResult, CheckStatus, CheckStatusReason, CheckStatusReasonType, RequestInfo, RequestType,
Expand All @@ -26,6 +26,8 @@ pub struct Checker {
client: Client,
}

pub const SUBSCRIPTION_ID: Uuid = uuid!("663399a09e6340a79c3c7a3f26878904");

/// Fetches the response from a URL.
///
/// First attempts to fetch just the head, and if not supported falls back to fetching the entire body.
Expand Down Expand Up @@ -123,8 +125,8 @@ impl Checker {

CheckResult {
guid: Uuid::new_v4(),
monitor_id: 0,
monitor_environment_id: 0,
// TODO: Use the real subscription id here when we have it
subscription_id: SUBSCRIPTION_ID,
status,
status_reason,
trace_id,
Expand Down
6 changes: 3 additions & 3 deletions src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ mod tests {
RequestType,
};
use rust_arroyo::backends::kafka::config::KafkaConfig;
use uuid::Uuid;
use uuid::{Uuid};
use crate::checker::SUBSCRIPTION_ID;

pub async fn send_result(result: CheckStatus) -> Result<(), ExtractCodeError> {
let guid = Uuid::new_v4();
let result = CheckResult {
guid,
monitor_id: 123,
monitor_environment_id: 456,
subscription_id: SUBSCRIPTION_ID,
status: result,
status_reason: Some(CheckStatusReason {
status_type: CheckStatusReasonType::DnsError,
Expand Down
14 changes: 5 additions & 9 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ pub struct CheckResult {
#[serde(serialize_with = "uuid_simple")]
pub guid: Uuid,

/// The identifier of the uptime monitor
pub monitor_id: u64,

/// The identifier of the uptime monitors environment
pub monitor_environment_id: u64,
/// The identifier of the subscription
#[serde(serialize_with = "uuid_simple")]
pub subscription_id: Uuid,

/// The status of the check
pub status: CheckStatus,
Expand Down Expand Up @@ -103,8 +101,7 @@ mod tests {
fn serialize_json_roundtrip_failure_example() {
let json = r#"{
"guid": "54afc7ed9c53491481919c931f75bae1",
"monitor_id": 1,
"monitor_environment_id": 1,
"subscription_id": "23d6048d67c948d9a19c0b47979e9a03",
"status": "failure",
"status_reason": {
"type": "dns_error",
Expand All @@ -130,8 +127,7 @@ mod tests {
fn serialize_json_roundtrip_success_example() {
let json = r#"{
"guid": "54afc7ed9c53491481919c931f75bae1",
"monitor_id": 1,
"monitor_environment_id": 1,
"subscription_id": "23d6048d67c948d9a19c0b47979e9a03",
"status": "success",
"status_reason": null,
"trace_id": "947efba02dac463b9c1d886a44bafc94",
Expand Down

0 comments on commit 0884632

Please sign in to comment.