Skip to content

Commit

Permalink
ref: Remove generate-schema command and JSON schema (#3974)
Browse files Browse the repository at this point in the history
As it was not used in an automated context, we're removing the generated
JSON schema for the event protocol. This resolves inconsistencies in the
documentation of our event protocol and also improves our compile times
through fewer derives.

We will subsequently improve the documentation of Relays types and work
on a replacement mechanism to publish docs for these types. In the
meanwhile, documentation can be viewed here:
https://getsentry.github.io/relay/relay_event_schema/protocol/index.html
  • Loading branch information
jan-auer authored Sep 2, 2024
1 parent 44186da commit 743d4b1
Show file tree
Hide file tree
Showing 62 changed files with 5 additions and 5,256 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,56 +48,6 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: target/doc

event_schema:
name: Event Schema
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Rust Toolchain
run: rustup toolchain install stable --profile minimal --no-self-update

- uses: swatinem/rust-cache@v2
with:
key: ${{ github.job }}

- name: Generate Schema
run: cargo run -p generate-schema -- -o event.schema.json

- name: Deploy
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.DATA_SCHEMAS_GITHUB_TOKEN }}
run: |
git config --global user.name "$(git log -1 --pretty=format:%an $GITHUB_SHA)"
git config --global user.email "$(git log -1 --pretty=format:%ae $GITHUB_SHA)"
git clone https://getsentry-bot:[email protected]/getsentry/sentry-data-schemas
cd sentry-data-schemas/
mkdir -p ./relay/
mv ../event.schema.json relay/event.schema.json
git add relay/event.schema.json
echo "attempting commit"
if ! git commit -m "getsentry/relay@$GITHUB_SHA" ; then
echo "Stopping, no changes"
exit 0
fi
for i in 1 2 3 4 5; do
echo "git push; Attempt $i"
if git push; then
exit 0
fi
git pull --rebase
done
echo "Failed to push"
exit 1
metrics_docs:
name: Metrics Docs
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Remove support for extrapolation of metrics. ([#3969](https://github.com/getsentry/relay/pull/3969))
- Remove the internal dashboard that shows logs and metrics. ([#3970](https://github.com/getsentry/relay/pull/3970))
- Remove the OTEL spans endpoint in favor of Envelopes. ([#3973](https://github.com/getsentry/relay/pull/3973))
- Remove the `generate-schema` tool. Relay no longer exposes JSON schema for the event protocol. Consult the Rust type documentation of the `relay-event-schema` crate instead. ([#3974](https://github.com/getsentry/relay/pull/3974))
- Allow creation of `SqliteEnvelopeBuffer` from config, and load existing stacks from db on startup. ([#3967](https://github.com/getsentry/relay/pull/3967))

## 24.8.0
Expand Down
67 changes: 0 additions & 67 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ relay-ua = { path = "relay-ua" }
relay-test = { path = "relay-test" }
relay-protocol-derive = { path = "relay-protocol-derive" }
relay-event-derive = { path = "relay-event-derive" }
relay-jsonschema-derive = { path = "relay-jsonschema-derive" }

android_trace_log = { version = "0.3.0", features = ["serde"] }
anyhow = "1.0.66"
Expand Down Expand Up @@ -137,7 +136,6 @@ regex = "1.10.2"
regex-lite = "0.1.6"
reqwest = "0.12.7"
rmp-serde = "1.1.1"
schemars = { version = "=0.8.10", features = ["uuid1", "chrono"] }
sentry = "0.34.0"
sentry-core = "0.34.0"
sentry-kafka-schemas = { version = "0.1.86", default-features = false }
Expand Down
2 changes: 0 additions & 2 deletions relay-base-schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ workspace = true
regex = { workspace = true }
relay-common = { workspace = true }
relay-protocol = { workspace = true }
schemars = { workspace = true, optional = true }
serde = { workspace = true }

[dev-dependencies]
serde_json = { workspace = true }

[features]
default = []
jsonschema = ["dep:schemars", "relay-protocol/jsonschema"]
3 changes: 0 additions & 3 deletions relay-base-schema/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use std::fmt;
use std::str::FromStr;

use relay_protocol::{Annotated, Empty, ErrorKind, FromValue, IntoValue, SkipSerialization, Value};
#[cfg(feature = "jsonschema")]
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// The type of an event.
Expand All @@ -26,7 +24,6 @@ use serde::{Deserialize, Serialize};
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize, Default,
)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
#[serde(rename_all = "lowercase")]
pub enum EventType {
/// Events that carry an exception payload.
Expand Down
11 changes: 0 additions & 11 deletions relay-base-schema/src/metrics/units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,6 @@ impl std::str::FromStr for MetricUnit {

relay_common::impl_str_serde!(MetricUnit, "a metric unit string");

#[cfg(feature = "jsonschema")]
impl schemars::JsonSchema for MetricUnit {
fn schema_name() -> String {
std::any::type_name::<Self>().to_owned()
}

fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
String::json_schema(gen)
}
}

impl Empty for MetricUnit {
#[inline]
fn is_empty(&self) -> bool {
Expand Down
3 changes: 0 additions & 3 deletions relay-base-schema/src/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use std::fmt;
use std::str::FromStr;

use relay_protocol::{Annotated, Empty, Error, FromValue, IntoValue, SkipSerialization, Value};
#[cfg(feature = "jsonschema")]
use schemars::JsonSchema;
use serde::Serialize;

/// Trace status.
Expand All @@ -16,7 +14,6 @@ use serde::Serialize;
// Note: This type is represented as a u8 in Snuba/Clickhouse, with Unknown being the default
// value. We use repr(u8) to statically validate that the trace status has 255 variants at most.
#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
#[serde(rename_all = "snake_case")]
#[repr(u8)] // size limit in clickhouse
pub enum SpanStatus {
Expand Down
10 changes: 0 additions & 10 deletions relay-event-schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ enumset = { workspace = true }
relay-common = { workspace = true }
relay-base-schema = { workspace = true }
relay-event-derive = { workspace = true }
relay-jsonschema-derive = { workspace = true, optional = true }
relay-protocol = { workspace = true, features = ["derive"] }
schemars = { workspace = true, optional = true }
sentry-release-parser = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand All @@ -35,11 +33,3 @@ uuid = { workspace = true }
insta = { workspace = true }
relay-protocol = { workspace = true, features = ["test"] }
similar-asserts = { workspace = true }

[features]
jsonschema = [
"relay-base-schema/jsonschema",
"relay-protocol/jsonschema",
"dep:relay-jsonschema-derive",
"dep:schemars",
]
3 changes: 0 additions & 3 deletions relay-event-schema/src/protocol/breadcrumb.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[cfg(test)]
use chrono::{TimeZone, Utc};
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;
Expand Down Expand Up @@ -47,7 +45,6 @@ use crate::protocol::{EventId, Level, Timestamp};
/// }
/// ```
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
#[metastructure(process_func = "process_breadcrumb", value_type = "Breadcrumb")]
pub struct Breadcrumb {
/// The timestamp of the breadcrumb. Recommended.
Expand Down
4 changes: 0 additions & 4 deletions relay-event-schema/src/protocol/clientsdk.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Array, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;
use crate::protocol::IpAddr;

/// An installed and loaded package as part of the Sentry SDK.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct ClientSdkPackage {
/// Name of the package.
pub name: Annotated<String>,
Expand All @@ -17,7 +14,6 @@ pub struct ClientSdkPackage {

/// The SDK Interface describes the Sentry SDK and its configuration used to capture and transmit an event.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
#[metastructure(process_func = "process_client_sdk_info", value_type = "ClientSdkInfo")]
pub struct ClientSdkInfo {
/// Unique SDK name. _Required._
Expand Down
3 changes: 0 additions & 3 deletions relay-event-schema/src/protocol/contexts/app.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;
Expand All @@ -10,7 +8,6 @@ use crate::protocol::LenientString;
/// App context describes the application. As opposed to the runtime, this is the actual
/// application that was running and carries metadata about the current session.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct AppContext {
/// Start time of the app.
///
Expand Down
3 changes: 0 additions & 3 deletions relay-event-schema/src/protocol/contexts/browser.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;

/// Web browser information.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct BrowserContext {
/// Display name of the browser application.
pub name: Annotated<String>,
Expand Down
3 changes: 0 additions & 3 deletions relay-event-schema/src/protocol/contexts/cloud_resource.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;
Expand All @@ -22,7 +20,6 @@ use crate::processor::ProcessValue;
/// }
/// ```
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct CloudResourceContext {
/// The cloud account ID the resource is assigned to.
#[metastructure(pii = "maybe")]
Expand Down
3 changes: 0 additions & 3 deletions relay-event-schema/src/protocol/contexts/device.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};
use uuid::Uuid;

Expand All @@ -10,7 +8,6 @@ use crate::processor::ProcessValue;
/// Device context describes the device that caused the event. This is most appropriate for mobile
/// applications.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct DeviceContext {
/// Name of the device.
#[metastructure(pii = "maybe")]
Expand Down
3 changes: 0 additions & 3 deletions relay-event-schema/src/protocol/contexts/gpu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(feature = "jsonschema")]
use relay_jsonschema_derive::JsonSchema;
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;
Expand All @@ -20,7 +18,6 @@ use crate::processor::ProcessValue;
/// }
/// ```
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct GpuContext {
/// The name of the graphics device.
#[metastructure(pii = "maybe")]
Expand Down
Loading

0 comments on commit 743d4b1

Please sign in to comment.