Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples (poem) #113

Open
onx2 opened this issue Sep 15, 2022 · 1 comment
Open

More examples (poem) #113

onx2 opened this issue Sep 15, 2022 · 1 comment

Comments

@onx2
Copy link

onx2 commented Sep 15, 2022

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
Copy link
Author

onx2 commented Sep 15, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant