@@ -2339,7 +2339,7 @@ impl<'de> Deserialize<'de> for LogAttribute {
23392339
23402340/// An ID that identifies an organization in the Sentry backend.
23412341#[ derive( Clone , Copy , Debug , Serialize , Deserialize , PartialEq ) ]
2342- struct OrganizationId ( u64 ) ;
2342+ pub struct OrganizationId ( u64 ) ;
23432343
23442344impl From < u64 > for OrganizationId {
23452345 fn from ( value : u64 ) -> Self {
@@ -2363,7 +2363,7 @@ impl std::fmt::Display for OrganizationId {
23632363
23642364/// A random number generated at the start of a trace by the head of trace SDK.
23652365#[ derive( Clone , Copy , Debug , Serialize , Deserialize , PartialEq ) ]
2366- struct SampleRand ( f64 ) ;
2366+ pub struct SampleRand ( f64 ) ;
23672367
23682368impl From < f64 > for SampleRand {
23692369 fn from ( value : f64 ) -> Self {
@@ -2392,8 +2392,8 @@ impl std::fmt::Display for SampleRand {
23922392/// This feature allows users to specify target sample rates for each project via the frontend instead of requiring an application redeployment.
23932393/// The backend needs additional information from the SDK to support these features, contained in
23942394/// 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 {
23972397 // Strictly required fields
23982398 // Still typed as optional, as when deserializing an envelope created by an older SDK they might still be missing
23992399 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
@@ -2432,3 +2432,101 @@ pub(crate) struct DynamicSamplingContext {
24322432 ) ]
24332433 org_id : Option < OrganizationId > ,
24342434}
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