File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,31 @@ pub struct Sentry {
450450 ///
451451 /// `OS__SENTRY__DEBUG`
452452 pub debug : bool ,
453+
454+ /// Additional tags to attach to all Sentry events.
455+ ///
456+ /// Key-value pairs that are sent as tags with every event reported to Sentry. Useful for adding
457+ /// context such as deployment identifiers or environment details.
458+ ///
459+ /// # Default
460+ ///
461+ /// Empty (no tags)
462+ ///
463+ /// # Environment Variables
464+ ///
465+ /// Each tag is set individually:
466+ /// - `OS__SENTRY__TAGS__FOO=foo`
467+ /// - `OS__SENTRY__TAGS__BAR=bar`
468+ ///
469+ /// # YAML Example
470+ ///
471+ /// ```yaml
472+ /// sentry:
473+ /// tags:
474+ /// foo: foo
475+ /// bar: bar
476+ /// ```
477+ pub tags : BTreeMap < String , String > ,
453478}
454479
455480impl Sentry {
@@ -471,6 +496,7 @@ impl Default for Sentry {
471496 traces_sample_rate : 0.01 ,
472497 inherit_sampling_decision : true ,
473498 debug : false ,
499+ tags : BTreeMap :: new ( ) ,
474500 }
475501 }
476502}
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ pub fn init_sentry(config: &Config) -> Option<sentry::ClientInitGuard> {
2525 let config = & config. sentry ;
2626 let dsn = config. dsn . as_ref ( ) ?;
2727
28- Some ( sentry:: init ( sentry:: ClientOptions {
28+ let guard = sentry:: init ( sentry:: ClientOptions {
2929 dsn : dsn. expose_secret ( ) . parse ( ) . ok ( ) ,
3030 release : Some ( RELEASE . into ( ) ) ,
3131 environment : config. environment . clone ( ) ,
@@ -47,7 +47,15 @@ pub fn init_sentry(config: &Config) -> Option<sentry::ClientInitGuard> {
4747 enable_logs : true ,
4848 debug : config. debug ,
4949 ..Default :: default ( )
50- } ) )
50+ } ) ;
51+
52+ sentry:: configure_scope ( |scope| {
53+ for ( k, v) in & config. tags {
54+ scope. set_tag ( k, v) ;
55+ }
56+ } ) ;
57+
58+ Some ( guard)
5159}
5260
5361pub fn init_tracing ( config : & Config ) {
You can’t perform that action at this time.
0 commit comments