@@ -2339,7 +2339,7 @@ impl<'de> Deserialize<'de> for LogAttribute {
2339
2339
2340
2340
/// An ID that identifies an organization in the Sentry backend.
2341
2341
#[ derive( Clone , Copy , Debug , Serialize , Deserialize , PartialEq ) ]
2342
- struct OrganizationId ( u64 ) ;
2342
+ pub struct OrganizationId ( u64 ) ;
2343
2343
2344
2344
impl From < u64 > for OrganizationId {
2345
2345
fn from ( value : u64 ) -> Self {
@@ -2363,7 +2363,7 @@ impl std::fmt::Display for OrganizationId {
2363
2363
2364
2364
/// A random number generated at the start of a trace by the head of trace SDK.
2365
2365
#[ derive( Clone , Copy , Debug , Serialize , Deserialize , PartialEq ) ]
2366
- struct SampleRand ( f64 ) ;
2366
+ pub struct SampleRand ( f64 ) ;
2367
2367
2368
2368
impl From < f64 > for SampleRand {
2369
2369
fn from ( value : f64 ) -> Self {
@@ -2392,8 +2392,8 @@ impl std::fmt::Display for SampleRand {
2392
2392
/// This feature allows users to specify target sample rates for each project via the frontend instead of requiring an application redeployment.
2393
2393
/// The backend needs additional information from the SDK to support these features, contained in
2394
2394
/// the Dynamic Sampling Context.
2395
- #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
2396
- pub ( crate ) struct DynamicSamplingContext {
2395
+ #[ derive( Clone , Debug , Default , Serialize , Deserialize , PartialEq ) ]
2396
+ pub struct DynamicSamplingContext {
2397
2397
// Strictly required fields
2398
2398
// Still typed as optional, as when deserializing an envelope created by an older SDK they might still be missing
2399
2399
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
@@ -2432,3 +2432,101 @@ pub(crate) struct DynamicSamplingContext {
2432
2432
) ]
2433
2433
org_id : Option < OrganizationId > ,
2434
2434
}
2435
+
2436
+ impl DynamicSamplingContext {
2437
+ /// Creates an empty Dynamic Sampling Context.
2438
+ pub fn new ( ) -> Self {
2439
+ Default :: default ( )
2440
+ }
2441
+
2442
+ /// Gets the trace ID.
2443
+ pub fn trace_id ( & self ) -> Option < & TraceId > {
2444
+ self . trace_id . as_ref ( )
2445
+ }
2446
+
2447
+ /// Sets the trace ID.
2448
+ pub fn set_trace_id ( & mut self , trace_id : Option < TraceId > ) {
2449
+ self . trace_id = trace_id;
2450
+ }
2451
+
2452
+ /// Gets the DSN public key.
2453
+ pub fn public_key ( & self ) -> Option < & String > {
2454
+ self . public_key . as_ref ( )
2455
+ }
2456
+
2457
+ /// Sets the DSN public key.
2458
+ pub fn set_public_key ( & mut self , public_key : Option < String > ) {
2459
+ self . public_key = public_key;
2460
+ }
2461
+
2462
+ /// Gets the sample rate.
2463
+ pub fn sample_rate ( & self ) -> Option < & f32 > {
2464
+ self . sample_rate . as_ref ( )
2465
+ }
2466
+
2467
+ /// Sets the sample rate.
2468
+ pub fn set_sample_rate ( & mut self , sample_rate : Option < f32 > ) {
2469
+ self . sample_rate = sample_rate;
2470
+ }
2471
+
2472
+ /// Gets the sample random value generated by the head of trace SDK.
2473
+ pub fn sample_rand ( & self ) -> Option < & SampleRand > {
2474
+ self . sample_rand . as_ref ( )
2475
+ }
2476
+
2477
+ /// Sets the sample random value generated by the head of trace SDK.
2478
+ pub fn set_sample_rand ( & mut self , sample_rand : Option < SampleRand > ) {
2479
+ self . sample_rand = sample_rand;
2480
+ }
2481
+
2482
+ /// Gets the sampled flag, true if and only if the trace was sampled. This is set by the head
2483
+ /// of trace SDK.
2484
+ pub fn sampled ( & self ) -> Option < & bool > {
2485
+ self . sampled . as_ref ( )
2486
+ }
2487
+
2488
+ /// Sets the sampled flag.
2489
+ pub fn set_sampled ( & mut self , sampled : Option < bool > ) {
2490
+ self . sampled = sampled;
2491
+ }
2492
+
2493
+ /// Gets the release.
2494
+ pub fn release ( & self ) -> Option < & String > {
2495
+ self . release . as_ref ( )
2496
+ }
2497
+
2498
+ /// Sets the release.
2499
+ pub fn set_release ( & mut self , release : Option < String > ) {
2500
+ self . release = release;
2501
+ }
2502
+
2503
+ /// Gets the environment.
2504
+ pub fn environment ( & self ) -> Option < & String > {
2505
+ self . environment . as_ref ( )
2506
+ }
2507
+
2508
+ /// Sets the environment.
2509
+ pub fn set_environment ( & mut self , environment : Option < String > ) {
2510
+ self . environment = environment;
2511
+ }
2512
+
2513
+ /// Gets the transaction.
2514
+ pub fn transaction ( & self ) -> Option < & String > {
2515
+ self . transaction . as_ref ( )
2516
+ }
2517
+
2518
+ /// Sets the transaction.
2519
+ pub fn set_transaction ( & mut self , transaction : Option < String > ) {
2520
+ self . transaction = transaction;
2521
+ }
2522
+
2523
+ /// Gets the organization ID.
2524
+ pub fn org_id ( & self ) -> Option < & OrganizationId > {
2525
+ self . org_id . as_ref ( )
2526
+ }
2527
+
2528
+ /// Sets the organization ID.
2529
+ pub fn set_org_id ( & mut self , org_id : Option < OrganizationId > ) {
2530
+ self . org_id = org_id;
2531
+ }
2532
+ }
0 commit comments