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

Datadog tracer client initialization instructions are incorrect #14

Open
bfouts-osaro opened this issue Jan 6, 2023 · 4 comments
Open

Comments

@bfouts-osaro
Copy link

The instructions do not demonstrate with_http_client, which is required in order to initialize the pipeline.

This fails:

    let tracer = opentelemetry_datadog::new_pipeline()
        .install_batch(opentelemetry::runtime::Tokio)?;

with

ExportFailed(NoHttpClient)

because this is the only place where a http client is intitialized: https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-datadog/src/exporter/mod.rs#L344

The "Bring your own http client" appears to be the only version that could work, but it describes how to define the http client but not how to bind it to the tracer.

The instructions should also have something like:

    let client = isahc::HttpClient::builder().build().unwrap();
    let http_client = Arc::new(IsahcClient{0:client});
    let tracer = new_pipeline()
        .with_http_client::<IsahcClient>(http_client)
      ...
@svix-james
Copy link

svix-james commented Jan 26, 2023

There may be some documentation improvements that would help here as well, but have you tried adding one of the related features to your Cargo.toml -- e.g., reqwest-client? I believe this will fix your issue without needing to take the BYO approach

@bfouts-osaro
Copy link
Author

I wasn't able to get reqwest-client working at all for the datadog package. The main issue being that the http_client is required, but the documentation makes no attempt to specify how to provide one.

I ended up using the generalized OTEL solution instead of this datadog package and that was considerably more straight forward

@cijothomas cijothomas transferred this issue from open-telemetry/opentelemetry-rust Nov 30, 2023
@paymog
Copy link

paymog commented Apr 23, 2024

Yes I agree, I've enabled the reqwest feature like so

opentelemetry-datadog = { version = "0.10", features = ["reqwest"] }

but then when I make the tracer like so

        let ddog_tracer = opentelemetry_datadog::new_pipeline()
            .with_service_name("graph-node")
            .with_agent_endpoint(&otel_endpoint) // Pass a reference to the String
            .with_api_version(opentelemetry_datadog::ApiVersion::Version05)
            .install_batch(opentelemetry_sdk::runtime::Tokio)
            .unwrap_or_else(|err| {
                eprintln!("Failed to initialize ddog tracer: {}", err);
                std::process::exit(1);
            });

I get

Failed to initialize ddog tracer: Exporter datadog encountered the following error(s): http client must be set, users can enable reqwest or surf feature to use http client implementation within create

A complete working example with a toml file would be much appreciated

@paymog
Copy link

paymog commented Apr 23, 2024

Got it! Turns out we should use the default function to set a client for us like so

        let ddog_tracer = opentelemetry_datadog::DatadogPipelineBuilder::default()
            .with_service_name("graph-node")
            .with_agent_endpoint(&otel_endpoint) // Pass a reference to the String
            .install_batch(opentelemetry_sdk::runtime::Tokio)
            .unwrap_or_else(|err| {
                eprintln!("Failed to initialize ddog tracer: {}", err);
                std::process::exit(1);
            });

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

3 participants