async_profiler_agent/reporter/
mod.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! This module contains [Reporter]s that upload profiling data to a destination.
5//!
6//! The following [Reporter]s are included:
7//! 1. [local::LocalReporter], which uploads profiling data to a local directory
8//! 2. [s3::S3Reporter], which uploads profiling data to an S3 bucket
9//! 3. [multi::MultiReporter], which allows combining multiple reporters.
10
11use std::fmt;
12
13use async_trait::async_trait;
14
15use crate::metadata::ReportMetadata;
16
17pub mod local;
18pub mod multi;
19#[cfg(feature = "s3-no-defaults")]
20pub mod s3;
21
22/// Abstraction around reporting profiler data.
23#[async_trait]
24pub trait Reporter: fmt::Debug {
25    /// Takes a profiling sample, including JFR data and sample metadata,
26    /// and uploads it towards a destination.
27    ///
28    /// If this function returns an error, the sample will be dropped
29    /// but profiling will continue, and this function will be called
30    /// again for the next sample (or theoretically, a future version
31    /// might have configuration that will an attempt to re-upload the
32    /// current sample will be made - but today's [`Profiler`] does
33    /// not make any such attempts).
34    ///
35    /// [`Profiler`]: crate::profiler::Profiler
36    async fn report(
37        &self,
38        jfr: Vec<u8>,
39        metadata: &ReportMetadata,
40    ) -> Result<(), Box<dyn std::error::Error + Send>>;
41}