Skip to content

Commit

Permalink
Merge branch 'master' into feat/tx-counter-decision
Browse files Browse the repository at this point in the history
* master:
  feat(protocol): Add sourcemap debug image type to protocol (#1869)
  ref(statsd): Revert back the adition of metric names as tag on Sentry errors (#1873)
  feat(profiling): Add PHP support (#1871)
  fix(panic): revert sentry-types to 0.20.1 (#1872)
  • Loading branch information
jan-auer committed Feb 23, 2023
2 parents 0495803 + 7cb05e0 commit c294680
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 101 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Unreleased

**Features**:

- Protocol validation for source map image type. ([#1869](https://github.com/getsentry/relay/pull/1869))

**Internal**:

- Revert back the addition of metric names as tag on Sentry errors when relay drops metrics. ([#1873](https://github.com/getsentry/relay/pull/1873))
- Add PHP support. ([#1871](https://github.com/getsentry/relay/pull/1871))

## 23.2.0

**Features**:
Expand Down
43 changes: 36 additions & 7 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 relay-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ once_cell = "1.13.1"
parking_lot = "0.12.1"
regex = "1.5.5"
schemars = { version = "0.8.1", features = ["uuid1", "chrono"], optional = true }
sentry-types = "0.29.3"
sentry-types = "0.20.0"
serde = { version = "1.0.114", features = ["derive"] }
thiserror = "1.0.38"
uuid = { version = "1.3.0", features = ["serde", "v4", "v5"] }
Expand Down
67 changes: 67 additions & 0 deletions relay-general/src/protocol/debugmeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,43 @@ pub struct NativeDebugImage {
pub other: Object<Value>,
}

/// A debug image pointing to a source map.
///
/// Examples:
///
/// ```json
/// {
/// "type": "sourcemap",
/// "code_file": "https://example.com/static/js/main.min.js",
/// "debug_id": "395835f4-03e0-4436-80d3-136f0749a893"
/// }
/// ```
///
/// **Note:** Stack frames and the correlating entries in the debug image here
/// for `code_file`/`abs_path` are not PII stripped as they need to line up
/// perfectly for source map processing.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct SourceMapDebugImage {
/// Path and name of the image file as URL. (required).
///
/// The absolute path to the minified JavaScript file. This helps to correlate the file to the stack trace.
#[metastructure(required = "true")]
pub code_file: Annotated<String>,

/// Unique debug identifier of the source map.
#[metastructure(required = "true")]
pub debug_id: Annotated<DebugId>,

/// Path and name of the associated source map.
#[metastructure(pii = "maybe")]
pub debug_file: Annotated<String>,

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

/// Proguard mapping file.
///
/// Proguard images refer to `mapping.txt` files generated when Proguard obfuscates function names. The Java SDK integrations assign this file a unique identifier, which has to be included in the list of images.
Expand Down Expand Up @@ -449,6 +486,8 @@ pub enum DebugImage {
Proguard(Box<ProguardDebugImage>),
/// WASM debug image.
Wasm(Box<NativeDebugImage>),
/// Source map debug image.
SourceMap(Box<SourceMapDebugImage>),
/// A debug image that is unknown to this protocol specification.
#[metastructure(fallback_variant)]
Other(Object<Value>),
Expand Down Expand Up @@ -824,6 +863,34 @@ mod tests {
assert_eq!(json, image.to_json_pretty().unwrap());
}

#[test]
fn test_source_map_image_roundtrip() {
let json = r#"{
"code_file": "https://mycdn.invalid/foo.js.min",
"debug_id": "971f98e5-ce60-41ff-b2d7-235bbeb34578",
"debug_file": "https://mycdn.invalid/foo.js.map",
"other": "value",
"type": "sourcemap"
}"#;

let image = Annotated::new(DebugImage::SourceMap(Box::new(SourceMapDebugImage {
code_file: Annotated::new("https://mycdn.invalid/foo.js.min".into()),
debug_file: Annotated::new("https://mycdn.invalid/foo.js.map".into()),
debug_id: Annotated::new("971f98e5-ce60-41ff-b2d7-235bbeb34578".parse().unwrap()),
other: {
let mut map = Object::new();
map.insert(
"other".to_string(),
Annotated::new(Value::String("value".to_string())),
);
map
},
})));

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

#[test]
fn test_debug_image_other_roundtrip() {
let json = r#"{"other":"value","type":"mytype"}"#;
Expand Down
45 changes: 44 additions & 1 deletion relay-general/tests/snapshots/test_fixtures__event_schema.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: relay-general/tests/test_fixtures.rs
assertion_line: 109
expression: "relay_general::protocol::event_json_schema()"
---
{
Expand Down Expand Up @@ -1013,6 +1012,9 @@ expression: "relay_general::protocol::event_json_schema()"
{
"$ref": "#/definitions/NativeDebugImage"
},
{
"$ref": "#/definitions/SourceMapDebugImage"
},
{
"type": "object",
"additionalProperties": true
Expand Down Expand Up @@ -2905,6 +2907,47 @@ expression: "relay_general::protocol::event_json_schema()"
}
]
},
"SourceMapDebugImage": {
"description": " A debug image pointing to a source map.\n\n Examples:\n\n ```json\n {\n \"type\": \"sourcemap\",\n \"code_file\": \"https://example.com/static/js/main.min.js\",\n \"debug_id\": \"395835f4-03e0-4436-80d3-136f0749a893\"\n }\n ```\n\n **Note:** Stack frames and the correlating entries in the debug image here\n for `code_file`/`abs_path` are not PII stripped as they need to line up\n perfectly for source map processing.",
"anyOf": [
{
"type": "object",
"required": [
"code_file",
"debug_id"
],
"properties": {
"code_file": {
"description": " Path and name of the image file as URL. (required).\n\n The absolute path to the minified JavaScript file. This helps to correlate the file to the stack trace.",
"type": [
"string",
"null"
]
},
"debug_file": {
"description": " Path and name of the associated source map.",
"default": null,
"type": [
"string",
"null"
]
},
"debug_id": {
"description": " Unique debug identifier of the source map.",
"anyOf": [
{
"$ref": "#/definitions/DebugId"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
]
},
"SpanId": {
"description": " A 16-character hex string as described in the W3C trace context spec.",
"anyOf": [
Expand Down
1 change: 1 addition & 0 deletions relay-profiling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ enum Platform {
Android,
Cocoa,
Node,
Php,
Python,
Rust,
}
Expand Down
3 changes: 1 addition & 2 deletions relay-profiling/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ impl SampleProfile {
&& self.device.manufacturer.is_some()
&& self.device.model.is_some()
}
Platform::Python => self.runtime.is_some(),
Platform::Node => self.runtime.is_some(),
Platform::Python | Platform::Node | Platform::Php => self.runtime.is_some(),
_ => true,
}
}
Expand Down
8 changes: 2 additions & 6 deletions relay-server/src/extractors/request_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ pub struct PartialDsn {
impl PartialDsn {
/// Ensures a valid public key and project ID in the DSN.
fn from_dsn(dsn: Dsn) -> Result<Self, ParseDsnError> {
let project_id = dsn
.project_id()
.value()
.parse()
.map_err(|_| ParseDsnError::NoProjectId)?;
let project_id = dsn.project_id().value();

let public_key = dsn
.public_key()
Expand All @@ -102,7 +98,7 @@ impl PartialDsn {
host: dsn.host().to_owned(),
port: dsn.port(),
path: dsn.path().to_owned(),
project_id: Some(project_id),
project_id: Some(ProjectId::new(project_id)),
})
}

Expand Down
Loading

0 comments on commit c294680

Please sign in to comment.