relay/main.rs
1//! <p align="center">
2//! <img src="https://github.com/getsentry/relay/blob/master/artwork/relay-logo.png?raw=true" alt="Relay" width="480">
3//! </p>
4//!
5//! Relay is a standalone service for scrubbing personal information and improving event submission
6//! response time. It acts as a middle layer between your application and Sentry.io. For information
7//! on setting up Relay in front of Sentry, see:
8//!
9//! [Relay documentation]
10//!
11//! # Event Ingestion
12//!
13//! Relay is also the primary event ingestion system at Sentry. When compiled with the `processing`
14//! feature and configured for ingestion, Relay ships functionality for:
15//!
16//! - Acknowledging and handling web requests on store endpoints
17//! - Applying rate limits and inbound data filters
18//! - Data scrubbing of event payloads and attachments
19//! - Validation and normalization of malformed or outdated data
20//! - Forwarding of all information into the event processing pipeline
21//!
22//! # Feature Flags
23//!
24//! - `processing`: Includes event ingestion and processing functionality. This should only be
25//! specified when compiling Relay as Sentry service. Standalone Relays do not need this feature.
26//! - `crash-handler`: Allows native crash reporting for segfaults and out-of-memory situations when
27//! internal error reporting to Sentry is enabled.
28//!
29//! # Workspace Crates
30//!
31//! Relay is split into the following workspace crates:
32//!
33//! - `relay`: Main entry point and command line interface.
34//! - [`relay-auth`]: Authentication and crypto.
35//! - [`relay-base-schema`]: Basic types for Relay's API schema used across multiple services.
36//! - [`relay-cabi`]: C-bindings for exposing functionality to Python.
37//! - [`relay-cardinality`]: Metrics cardinality limiter.
38//! - [`relay-common`]: Common utilities and crate re-exports.
39//! - [`relay-config`]: Static configuration for the CLI and server.
40//! - [`relay-cogs`]: Break down the cost of Relay by its features.
41//! - [`relay-crash`]: Crash reporting for the Relay server.
42//! - [`relay-dynamic-config`]: Dynamic configuration passed from Sentry.
43//! - [`relay-event-derive`]: Derive for visitor traits on the Event schema.
44//! - [`relay-event-normalization`]: Event normalization and processing.
45//! - [`relay-event-schema`]: Event schema (Error, Transaction, Security) and types for event processing.
46//! - [`relay-ffi`]: Utilities for error handling in FFI bindings.
47//! - [`relay-ffi-macros`]: Macros for error handling in FFI bindings.
48//! - [`relay-filter`]: Inbound data filters.
49//! - [`relay-kafka`]: Kafka-related functionality.
50//! - [`relay-log`]: Error reporting and logging.
51//! - [`relay-metrics`]: Metrics protocol and processing.
52//! - [`relay-monitors`]: Monitors protocol and processing for Sentry.
53//! - [`relay-pattern`]: A glob like pattern used throughout Relay.
54//! - [`relay-pii`]: Scrubbing of personally identifiable information (PII) from events.
55//! - [`relay-profiling`]: Profiling protocol and processing.
56//! - [`relay-protocol`]: Types and traits for building JSON-based protocols and schemas.
57//! - [`relay-protocol-derive`]: Derives for Relay's protocol traits.
58//! - [`relay-quotas`]: Sentry quotas and rate limiting.
59//! - [`relay-redis`]: Pooled Redis and Redis cluster abstraction.
60//! - [`relay-replays`]: Session replay protocol and processing.
61//! - [`relay-sampling`]: Dynamic sampling functionality.
62//! - [`relay-server`]: Endpoints and services.
63//! - [`relay-statsd`]: High-level StatsD metric client for internal measurements.
64//! - [`relay-system`]: Foundational system components for Relay's services.
65//! - [`relay-test`]: Helpers for testing the web server and services.
66//! - [`relay-threading`]: Threading code that is used by Relay.
67//! - [`relay-ua`]: User agent parser with built-in rules.
68//!
69//! # Tools
70//!
71//! Complementary to the Relay binary, the workspace contains a set of tools to interface with some
72//! of Relay's functionality or to export information:
73//!
74//! - [`document-metrics`]: Generate documentation for metrics.
75//! - [`process-event`]: Process a Sentry event payload.
76//! - [`scrub-minidump`]: Scrub PII from a Minidump file.
77//!
78//! [relay documentation]: https://docs.sentry.io/product/relay/
79//! [`relay-auth`]: ../relay_auth/index.html
80//! [`relay-base-schema`]: ../relay_base_schema/index.html
81//! [`relay-cabi`]: ../relay_cabi/index.html
82//! [`relay-cardinality`]: ../relay_cardinality/index.html
83//! [`relay-common`]: ../relay_common/index.html
84//! [`relay-config`]: ../relay_config/index.html
85//! [`relay-cogs`]: ../relay_cogs/index.html
86//! [`relay-crash`]: ../relay_crash/index.html
87//! [`relay-dynamic-config`]: ../relay_dynamic_config/index.html
88//! [`relay-event-derive`]: ../relay_event_derive/index.html
89//! [`relay-event-normalization`]: ../relay_event_normalization/index.html
90//! [`relay-event-schema`]: ../relay_event_schema/index.html
91//! [`relay-ffi`]: ../relay_ffi/index.html
92//! [`relay-ffi-macros`]: ../relay_ffi_macros/index.html
93//! [`relay-filter`]: ../relay_filter/index.html
94//! [`relay-kafka`]: ../relay_kafka/index.html
95//! [`relay-log`]: ../relay_log/index.html
96//! [`relay-metrics`]: ../relay_metrics/index.html
97//! [`relay-monitors`]: ../relay_monitors/index.html
98//! [`relay-pattern`]: ../relay_pattern/index.html
99//! [`relay-pii`]: ../relay_pii/index.html
100//! [`relay-profiling`]: ../relay_profiling/index.html
101//! [`relay-protocol`]: ../relay_protocol/index.html
102//! [`relay-protocol-derive`]: ../relay_protocol_derive/index.html
103//! [`relay-quotas`]: ../relay_quotas/index.html
104//! [`relay-redis`]: ../relay_redis/index.html
105//! [`relay-replays`]: ../relay_replays/index.html
106//! [`relay-sampling`]: ../relay_sampling/index.html
107//! [`relay-server`]: ../relay_server/index.html
108//! [`relay-statsd`]: ../relay_statsd/index.html
109//! [`relay-system`]: ../relay_system/index.html
110//! [`relay-test`]: ../relay_test/index.html
111//! [`relay-ua`]: ../relay_ua/index.html
112//! [`document-metrics`]: ../document_metrics/index.html
113//! [`process-event`]: ../process_event/index.html
114//! [`scrub-minidump`]: ../scrub_minidump/index.html
115
116#![doc(
117 html_logo_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png",
118 html_favicon_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png"
119)]
120#![allow(
121 clippy::derive_partial_eq_without_eq,
122 clippy::print_stdout,
123 clippy::print_stderr
124)]
125
126mod cli;
127mod cliapp;
128mod setup;
129mod utils;
130
131use std::process;
132
133use relay_log::Hub;
134
135#[cfg(target_os = "linux")]
136#[global_allocator]
137static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
138
139pub fn main() {
140 let exit_code = match cli::execute() {
141 Ok(()) => 0,
142 Err(err) => {
143 relay_log::ensure_error(&err);
144 1
145 }
146 };
147
148 Hub::current().client().map(|x| x.close(None));
149 process::exit(exit_code);
150}