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

feat(ourlogs): Preliminary breadcrumb to log conversion #4479

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

## Unreleased

- Preliminary breadcrumb to log conversion. ([#4479](https://github.com/getsentry/relay/pull/4479))
- Allow log ingestion behind a flag, only for internal use currently. ([#4471](https://github.com/getsentry/relay/pull/4471))

**Features**:

- Preliminary breadcrumb to log conversion. ([#4479](https://github.com/getsentry/relay/pull/4479))
- Allow log ingestion behind a flag, only for internal use currently. ([#4471](https://github.com/getsentry/relay/pull/4471))
- Add configuration option to limit the amount of concurrent http connections. ([#4453](https://github.com/getsentry/relay/pull/4453))
- Add flags context to event schema. ([#4458](https://github.com/getsentry/relay/pull/4458))
- Add support for view hierarchy attachment scrubbing. ([#4452](https://github.com/getsentry/relay/pull/4452))
Expand Down
11 changes: 0 additions & 11 deletions relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,6 @@ pub struct Limits {
///
/// Defaults to `1024`, a value [google has been using for a long time](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4).
pub tcp_listen_backlog: u32,
/// The maximum number of breadcrumbs to convert to OurLogs.
///
/// When converting breadcrumbs to OurLogs, only up to this many breadcrumbs will be converted.
/// Defaults to 100.
pub max_breadcrumbs_converted: usize,
}

impl Default for Limits {
Expand Down Expand Up @@ -704,7 +699,6 @@ impl Default for Limits {
idle_timeout: None,
max_connections: None,
tcp_listen_backlog: 1024,
max_breadcrumbs_converted: 100,
}
}
}
Expand Down Expand Up @@ -2516,11 +2510,6 @@ impl Config {
let forward = self.values.routing.accept_unknown_items;
forward.unwrap_or_else(|| !self.processing_enabled())
}

/// Returns the maximum number of breadcrumbs that should be converted to OurLogs.
pub fn max_breadcrumbs_converted(&self) -> usize {
self.values.limits.max_breadcrumbs_converted
}
}

impl Default for Config {
Expand Down
5 changes: 5 additions & 0 deletions relay-dynamic-config/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ pub enum Feature {
/// Serialized as `organizations:ourlogs-ingestion`.
#[serde(rename = "organizations:ourlogs-ingestion")]
OurLogsIngestion,

/// Enables extracting logs from breadcrumbs for our log product.
#[serde(rename = "projects:ourlogs-breadcrumb-extraction")]
OurLogsBreadcrumbExtraction,

/// This feature has graduated and is hard-coded for external Relays.
#[doc(hidden)]
#[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
Expand Down
11 changes: 11 additions & 0 deletions relay-dynamic-config/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ pub struct Options {
)]
pub ourlogs_breadcrumb_extraction_sample_rate: Option<f32>,

/// The maximum number of breadcrumbs to convert to OurLogs.
///
/// When converting breadcrumbs to OurLogs, only up to this many breadcrumbs will be converted.
/// Defaults to 100.
#[serde(
rename = "relay.ourlogs-breadcrumb-extraction.max-breadcrumbs-converted",
deserialize_with = "default_on_error",
skip_serializing_if = "is_default"
)]
pub ourlogs_breadcrumb_extraction_max_breadcrumbs_converted: usize,

/// List of values on span description that are allowed to be sent to Sentry without being scrubbed.
///
/// At this point, it doesn't accept IP addresses in CIDR format.. yet.
Expand Down
5 changes: 5 additions & 0 deletions relay-event-schema/src/protocol/contexts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod monitor;
mod nel;
mod os;
mod otel;
mod our_logs;
mod performance_score;
mod profile;
mod replay;
Expand All @@ -25,6 +26,7 @@ pub use monitor::*;
pub use nel::*;
pub use os::*;
pub use otel::*;
pub use our_logs::*;
pub use performance_score::*;
pub use profile::*;
pub use replay::*;
Expand Down Expand Up @@ -90,6 +92,9 @@ pub enum Context {
Nel(Box<NelContext>),
/// Performance score information.
PerformanceScore(Box<PerformanceScoreContext>),
/// Ourlogs (logs product) information.
#[metastructure(tag = "sentry_logs")]
OurLogs(Box<OurLogsContext>),
Comment on lines +96 to +97
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these hard to remove later or is the deprecation sticky? If they are I'm probably going to delay this a week until Abhi is back and we can make sure everyone is fine with the context on the sdk side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the variant from the code is not a problem. After removing it, relay will still forward the context as if it were a user-defined context.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

/// Additional arbitrary fields for forwards compatibility.
#[metastructure(fallback_variant)]
Other(#[metastructure(pii = "true")] Object<Value>),
Expand Down
68 changes: 68 additions & 0 deletions relay-event-schema/src/protocol/contexts/our_logs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};

use crate::processor::ProcessValue;

/// Our Logs context.
///
/// The Sentry Logs context contains information about our logging product (ourlogs) for an event.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
pub struct OurLogsContext {
/// Whether breadcrumbs are being deduplicated.
pub deduplicated_breadcrumbs: Annotated<bool>,

/// Additional arbitrary fields for forwards compatibility.
#[metastructure(additional_properties, retain = true)]
pub other: Object<Value>,
}

impl super::DefaultContext for OurLogsContext {
fn default_key() -> &'static str {
"sentry_logs" // Ourlogs is an internal name, and 'logs' likely has conflicts with user contexts.
}

fn from_context(context: super::Context) -> Option<Self> {
match context {
super::Context::OurLogs(c) => Some(*c),
_ => None,
}
}

fn cast(context: &super::Context) -> Option<&Self> {
match context {
super::Context::OurLogs(c) => Some(c),
_ => None,
}
}

fn cast_mut(context: &mut super::Context) -> Option<&mut Self> {
match context {
super::Context::OurLogs(c) => Some(c),
_ => None,
}
}

fn into_context(self) -> super::Context {
super::Context::OurLogs(Box::new(self))
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::protocol::Context;

#[test]
fn test_our_logs_context() {
let json = r#"{
"deduplicated_breadcrumbs": true,
"type": "sentry_logs"
}"#;
let context = Annotated::new(Context::OurLogs(Box::new(OurLogsContext {
deduplicated_breadcrumbs: Annotated::new(true),
..OurLogsContext::default()
})));

assert_eq!(context, Annotated::from_json(json).unwrap());
assert_eq!(json, context.to_json_pretty().unwrap());
}
}
Loading
Loading