async_graphql_apollo_studio_extension icon indicating copy to clipboard operation
async_graphql_apollo_studio_extension copied to clipboard

More examples (poem)

Open onx2 opened this issue 3 years ago • 1 comments
trafficstars

Would you mind creating an example of how to use this extension with poem?

I'm not very familiar with tracing and apollo studio, it would be helpful to have some more information on how to get a basic example working locally.

When setting up a new graph on apollo studio they give you this screen: image

How can I get this to auto-detect my schema?

Here's some more info that might be helpful:

Versions from Cargo.toml

async-graphql = { version = "4.0.13", features = ["chrono", "uuid", "dataloader", "apollo_tracing"] }
async-graphql-extension-apollo-tracing = { version = "3.0.1", features = ["tokio-comp", "compression"] }

WIP attempt at creating a new ApolloTracing extension

let apollo_tracing = ApolloTracing::new(
            "service:My-Graph-8sf1w:wmwfq3rgbhMJjHJGz8WuTw".into(),
            "https://localhost:3000".into(),
            "My-Graph-8sf1w@current".into(),
            "v1.0.0".into(),
            10,
        );

How do these expected values map to what apollo studio gives me? image

Thanks in advance for any help / suggestions you can provide!

onx2 avatar Sep 15 '22 02:09 onx2

Update: I read through some more of the doc comments for register and ApolloTracingDataExt and I'm using the following code:

in my handler

#[handler]
pub async fn index(
    schema: Data<&RealSchema>,
    headers: &HeaderMap,
    req: GraphQLRequest,
) -> GraphQLResponse {
    let mut req = req.0;
    if let Some(token) = get_token_from_headers(headers) {
        req = req.data(token);
    }
    req = req.data(ApolloTracingDataExt {
        userid: Some("idk what this is".to_string()),
        path: Some("/".to_string()),
        host: Some("localhost:3000".to_string()),
        method: Some(HTTPMethod::POST),
        secure: Some(false),
        protocol: Some("HTTP/1.1".to_string()),
        status_code: Some(200),
        client_name: Some("My client_name IDK".to_string()),
        client_version: Some("My client_version IDK".to_string()),
    });

    schema.execute(req).await.into()
}

registering

...
.extension(ApolloTracing::new(
            "service:My-Graph-8sf1w:_b9JOwqgkFqkRDBhBwTsfA".into(),
            "localhost".into(),
            "My-Graph-8sf1w@current".into(),
            "v1.0.0".into(),
            10,
        ));

register(
            "service:My-Graph-8sf1w:_b9JOwqgkFqkRDBhBwTsfA",
            &graphql_schema,
            "my-graph",
            "current",
            "1.0.0",
            "localhost",
        )
        .await
        .expect("Couldn't register schema with apollo tracing.");

And I'm getting the following output in my terminal:

[2022-09-15T03:35:00Z DEBUG reqwest::async_impl::client] response '422 Unprocessable Entity' for https://usage-reporting.api.apollographql.com/api/ingress/traces

Do you see anything in my configuration that would warrant a 422?

onx2 avatar Sep 15 '22 03:09 onx2