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

ref(server): introduce client name enum #4226

Merged
merged 4 commits into from
Nov 7, 2024
Merged
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
9 changes: 4 additions & 5 deletions relay-server/src/endpoints/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::services::buffer::EnvelopeBuffer;
use crate::services::outcome::{DiscardReason, Outcome};
use crate::services::processor::{BucketSource, MetricData, ProcessMetrics, ProcessingGroup};
use crate::services::projects::cache::legacy::ValidateEnvelope;
use crate::statsd::{RelayCounters, RelayHistograms};
use crate::statsd::{RelayCounters, RelayHistograms, SdkTag};
use crate::utils::{self, ApiErrorResponse, FormDataIter, ManagedEnvelope};

#[derive(Clone, Copy, Debug, thiserror::Error)]
Expand Down Expand Up @@ -334,16 +334,15 @@ pub async fn handle_envelope(
state: &ServiceState,
envelope: Box<Envelope>,
) -> Result<Option<EventId>, BadStoreRequest> {
let client_name = envelope
let client_name: SdkTag = envelope
.meta()
.client_name()
Litarnus marked this conversation as resolved.
Show resolved Hide resolved
.filter(|name| name.starts_with("sentry") || name.starts_with("raven"))
.unwrap_or("proprietary");
.map_or(SdkTag::Other, SdkTag::from);
for item in envelope.items() {
metric!(
histogram(RelayHistograms::EnvelopeItemSize) = item.payload().len() as u64,
item_type = item.ty().name(),
sdk = client_name,
sdk = client_name.as_str(),
)
}

Expand Down
80 changes: 80 additions & 0 deletions relay-server/src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,83 @@ impl<S: AsRef<str>> From<S> for PlatformTag {
}
}
}

pub enum SdkTag {
Litarnus marked this conversation as resolved.
Show resolved Hide resolved
Ruby,
CocoaFlutter,
CocoaReactNative,
Cocoa,
Dotnet,
AndroidReactNative,
AndroidJava,
SpringBoot,
JavascriptBrowser,
Electron,
NestJs,
NextJs,
Node,
React,
Vue,
Native,
Laravel,
Symfony,
Php,
Python,
Other,
Litarnus marked this conversation as resolved.
Show resolved Hide resolved
}

impl SdkTag {
pub fn as_str(&self) -> &str {
match self {
Self::Ruby => "sentry-ruby",
Self::CocoaFlutter => "sentry.cocoa.flutter",
Self::CocoaReactNative => "sentry.cocoa.react-native",
Self::Cocoa => "sentry.cocoa",
Self::Dotnet => "sentry.dotnet",
Self::AndroidReactNative => "sentry.java.android.react-native",
Self::AndroidJava => "sentry.java.android",
Self::SpringBoot => "sentry.java.spring-boot.jakarta",
Self::JavascriptBrowser => "sentry.javascript.browser",
Self::Electron => "sentry.javascript.electron",
Self::NestJs => "sentry.javascript.nestjs",
Self::NextJs => "sentry.javascript.nextjs",
Self::Node => "sentry.javascript.node",
Self::React => "sentry.javascript.react",
Self::Vue => "sentry.javascript.vue",
Self::Native => "sentry.native",
Self::Laravel => "sentry.php.laravel",
Self::Symfony => "sentry.php.symfony",
Self::Php => "sentry.php",
Self::Python => "sentry.python",
Self::Other => "other",
}
}
}

impl<S: AsRef<str>> From<S> for SdkTag {
fn from(value: S) -> Self {
match value.as_ref() {
"sentry-ruby" => Self::Ruby,
"sentry.cocoa.flutter" => Self::CocoaFlutter,
"sentry.cocoa.react-native" => Self::CocoaReactNative,
"sentry.cocoa" => Self::Cocoa,
"sentry.dotnet" => Self::Dotnet,
"sentry.java.android.react-native" => Self::AndroidReactNative,
"sentry.java.android" => Self::AndroidJava,
"sentry.java.spring-boot.jakarta" => Self::SpringBoot,
"sentry.javascript.browser" => Self::JavascriptBrowser,
"sentry.javascript.electron" => Self::Electron,
"sentry.javascript.nestjs" => Self::NestJs,
"sentry.javascript.nextjs" => Self::NextJs,
"sentry.javascript.node" => Self::Node,
"sentry.javascript.react" => Self::React,
"sentry.javascript.vue" => Self::Vue,
"sentry.native" => Self::Native,
"sentry.php.laravel" => Self::Laravel,
"sentry.php.symfony" => Self::Symfony,
"sentry.php" => Self::Php,
"sentry.python" => Self::Python,
_ => Self::Other,
}
}
}
Loading