/// Send the session to the server and consumes the session object.
/// # Example
/// ```ignore
/// let config = PyroscopeConfig::new("https://localhost:8080", "my-app");
/// let report = vec![1, 2, 3];
/// let until = 154065120;
/// let session = Session::new(until, config, report)?;
/// session.send()?;
/// ```
Send the session to the server and consumes the session object.
Send the session to the server and consumes the session object .
pub fn send(self) -> Result<()> {
        log::info!(
            target: LOG_TAG,
            "Sending Session: {} - {}",
            self.from,
            self.until
        );
        // Check if the report is empty
        if self.report.is_empty() {
            return Ok(());
        }
        // Create a new client
        let client = reqwest::blocking::Client::new();
        // Clone URL
        let url = self.config.url.clone();
        // Merge application name with Tags
        let application_name = merge_tags_with_app_name(
            self.config.application_name.clone(),
            self.config.tags.clone(),
        )?;
        // Create and send the request
        client
            .post(format!("{}/ingest", url))
            .header("Content-Type", "binary/octet-stream")
            .query(&[
                ("name", application_name.as_str()),
                ("from", &format!("{}", self.from)),
                ("until", &format!("{}", self.until)),
                ("format", "folded"),
                ("sampleRate", &format!("{}", self.config.sample_rate)),
                ("spyName", self.config.spy_name.as_str()),
            ])
            .body(self.report)
            .timeout(Duration::from_secs(10))
            .send()?;
        Ok(())
    }
pub fn send ( self ) -> Result < ( ) > { log :: info ! ( target LOG_TAG " " self from self until ) ; // Check if the report is empty if self . report . is_empty ( ) { return Ok ( ( ) ) ; } // Create a new client let client = reqwest :: blocking :: Client :: new ( ) ; // Clone URL let url = self . config . url . clone ( ) ; // Merge application name with Tags let application_name = merge_tags_with_app_name ( self . config . application_name . clone ( ) , self . config . tags . clone ( ) , ) ? ; // Create and send the request client . post ( format ! ( " " url ) ) . header ( " " , " " ) . query ( & [ ( " " , application_name . as_str ( ) ) , ( " " , & format ! ( " " self from ) ) , ( " " , & format ! ( " " self until ) ) , ( " " , " " ) , ( " " , & format ! ( " " self config sample_rate ) ) , ( " " , self . config . spy_name . as_str ( ) ) , ] ) . body ( self . report ) . timeout ( Duration :: from_secs ( 10 ) ) . send ( ) ? ; Ok ( ( ) ) }
Send the session to the server and consumes the session object.
Send the session to the server and consumes the session object .
self
example
None