Skip to content

Commit

Permalink
feat(spans): Align otel attributes with sentry span (#3457)
Browse files Browse the repository at this point in the history
To simplify conversion in the future, align attribute names in Otel's
span attributes with keys in Sentry's `span.data`. The old keys in
`span.data` remain as legacy alias.

See also getsentry/develop#1230 for the span
schema / attribute convention.

ref: #3278

---------

Co-authored-by: David Herberth <[email protected]>
  • Loading branch information
jjbayer and Dav1dde authored Apr 22, 2024
1 parent b57381a commit 69874ae
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 114 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Respect country code TLDs when scrubbing span tags. ([#3458](https://github.com/getsentry/relay/pull/3458))

**Features**:

- Use same keys for OTel span attributes and Sentry span data. ([#3457](https://github.com/getsentry/relay/pull/3457))

**Internal**:

- Emit gauges for total and self times for spans. ([#3448](https://github.com/getsentry/relay/pull/3448))
Expand All @@ -14,7 +18,7 @@

**Features**:

- Add inbound filters for Annotated<Replay> types. ([#3420](https://github.com/getsentry/relay/pull/3420))
- Add inbound filters for `Annotated<Replay>` types. ([#3420](https://github.com/getsentry/relay/pull/3420))
- Add Linux distributions to os context. ([#3443](https://github.com/getsentry/relay/pull/3443))

**Internal:**
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions relay-event-schema/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ pub struct SpanData {
pub db_system: Annotated<Value>,

/// The sentry environment.
#[metastructure(field = "environment")]
#[metastructure(field = "sentry.environment", legacy_alias = "environment")]
pub environment: Annotated<String>,

/// The release version of the project.
#[metastructure(field = "release")]
#[metastructure(field = "sentry.release", legacy_alias = "release")]
pub release: Annotated<LenientString>,

/// The decoded body size of the response (in bytes).
Expand Down Expand Up @@ -276,7 +276,7 @@ pub struct SpanData {
/// This corresponds to the transaction name in the transaction-based model.
///
/// For INP spans, this is the route name where the interaction occurred.
#[metastructure(field = "segment.name", legacy_alias = "transaction")]
#[metastructure(field = "sentry.segment.name", legacy_alias = "transaction")]
pub segment_name: Annotated<String>,

/// Name of the UI component (e.g. React).
Expand All @@ -292,11 +292,11 @@ pub struct SpanData {
pub user: Annotated<Value>,

/// Replay ID
#[metastructure(field = "replay_id")]
#[metastructure(field = "sentry.replay.id", legacy_alias = "replay_id")]
pub replay_id: Annotated<Value>,

/// The sentry SDK (see [`crate::protocol::ClientSdkInfo`]).
#[metastructure(field = "sdk.name")]
#[metastructure(field = "sentry.sdk.name")]
pub sdk_name: Annotated<String>,

/// Other fields in `span.data`.
Expand Down
1 change: 1 addition & 0 deletions relay-server/src/services/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,7 @@ struct SpanKafkaMessage<'a> {
event_id: Option<EventId>,
#[serde(rename(deserialize = "exclusive_time"))]
exclusive_time_ms: f64,
#[serde(default)]
is_segment: bool,

#[serde(borrow, default, skip_serializing_if = "Option::is_none")]
Expand Down
9 changes: 8 additions & 1 deletion relay-spans/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ chrono = { workspace = true }
enumset = { workspace = true }
hex = { workspace = true }
once_cell = { workspace = true }
opentelemetry-proto = { workspace = true, features = ["gen-tonic", "with-serde", "trace"] }
opentelemetry-proto = { workspace = true, features = [
"gen-tonic",
"with-serde",
"trace",
] }
relay-event-schema = { workspace = true }
relay-protocol = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_repr = { workspace = true }

[dev-dependencies]
insta = { workspace = true }
1 change: 0 additions & 1 deletion relay-spans/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ pub use crate::span::otel_to_sentry_span;

pub use opentelemetry_proto::tonic::trace::v1 as otel_trace;

mod otel_to_sentry_tags;
mod span;
mod status_codes;
34 changes: 0 additions & 34 deletions relay-spans/src/otel_to_sentry_tags.rs

This file was deleted.

Loading

0 comments on commit 69874ae

Please sign in to comment.