Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Dec 1, 2023
1 parent 979caba commit 0906ebc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions fiberplane-pdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ pub fn derive_config_schema(input: TokenStream) -> TokenStream {
/// Used to automatically generate conversion methods to convert your data to
/// and from the `Blob` type.
///
/// The macro extends the struct to which it is applied with `parse()` and
/// `serialize()` methods.
/// The macro extends the struct to which it is applied with `parse_blob()` and
/// `to_blob()` methods.
///
/// # Example
///
Expand Down
2 changes: 1 addition & 1 deletion providers/prometheus/src/autometrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use grafana_common::{query_direct_and_proxied, Config};
use serde::{Deserialize, Serialize};
use std::collections::BTreeSet;

pub const ALL_FUNCTIONS_QUERY: &str = "x-autometrics-functions";
pub const ALL_FUNCTIONS_QUERY_TYPE: &str = "x-autometrics-functions";
pub const CHILD_FUNCTIONS_QUERY: &str = "x-autometrics-child-functions";

pub const AUTOMETRICS_FUNCTIONS_MIME_TYPE: &str = "application/vnd.autometrics.functions";
Expand Down
10 changes: 4 additions & 6 deletions providers/prometheus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use fp_bindgen::prelude::Serializable;
use grafana_common::{query_direct_and_proxied, Config};
use serde::{Deserialize, Serialize};

pub const CONFIG_QUERY: &str = "x-prometheus-config";
pub const CONFIG_QUERY_TYPE: &str = "x-prometheus-config";

pub const YAML_MIME_TYPE: &str = "text/yaml";

Expand All @@ -31,14 +31,12 @@ pub(crate) async fn query_config(_query: ConfigQuery, config: Config) -> Result<
}

pub fn create_code_cell(response: Blob) -> Result<Vec<Cell>> {
let config_yaml = Yaml::parse_blob(response)?;

let code_cell = Cell::Code(
CodeCell::builder()
.id("config".to_owned())
.content(String::from_utf8(response.data.into()).map_err(|err| {
Error::Deserialization {
message: err.to_string(),
}
})?)
.content(config_yaml.0)
.syntax("yaml")
.build(),
);
Expand Down
6 changes: 3 additions & 3 deletions providers/prometheus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const COMMIT_HASH: &str = env!("VERGEN_GIT_SHA");
const BUILD_TIMESTAMP: &str = env!("VERGEN_BUILD_TIMESTAMP");

pdk_query_types! {
ALL_FUNCTIONS_QUERY => {
ALL_FUNCTIONS_QUERY_TYPE => {
handler: query_all_functions(FunctionsQuery, Config).await,
supported_mime_types: [AUTOMETRICS_FUNCTIONS_MIME_TYPE]
},
CONFIG_QUERY => {
CONFIG_QUERY_TYPE => {
handler: query_config(ConfigQuery, Config).await,
label: "Prometheus config",
supported_mime_types: [YAML_MIME_TYPE]
Expand Down Expand Up @@ -55,7 +55,7 @@ fn create_cells(query_type: String, response: Blob) -> Result<Vec<Cell>> {

match query_type.as_str() {
TIMESERIES_QUERY_TYPE => create_graph_cell(),
YAML_MIME_TYPE => create_code_cell(response),
CONFIG_QUERY_TYPE => create_code_cell(response),
_ => Err(Error::UnsupportedRequest),
}
}
Expand Down

0 comments on commit 0906ebc

Please sign in to comment.