Git Product home page Git Product logo

actix-web-opentelemetry's Introduction

Actix Web OpenTelemetry

Build Status Crates.io: actix-web-opentelemetry Documentation License: MIT

OpenTelemetry integration for Actix Web.

Exporter configuration

actix-web uses tokio as the underlying executor, so exporters should be configured to be non-blocking:

[dependencies]
# if exporting to jaeger, use the `tokio` feature.
opentelemetry-jaeger = { version = "..", features = ["rt-tokio-current-thread"] }

# if exporting to zipkin, use the `tokio` based `reqwest-client` feature.
opentelemetry-zipkin = { version = "..", features = ["reqwest-client"], default-features = false }

# ... ensure the same same for any other exporters

Execute client and server example

# Run jaeger in background
$ docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest

# Run server example with tracing middleware
$ cargo run --example server
# (In other tab) Run client example with request tracing
$ cargo run --example client --features awc

# View spans (see the image below)
$ firefox http://localhost:16686/

Jaeger UI

Features

  • awc -- enable support for tracing the awc http client.
  • metrics -- enable support for opentelemetry metrics (only traces are enabled by default)
  • metrics-prometheus -- enable support for prometheus metrics (requires metrics feature)
  • sync-middleware -- enable tracing on actix-web middlewares that do synchronous work before returning a future. Adds a small amount of overhead to every request.

actix-web-opentelemetry's People

Contributors

fourbytes avatar frefreak avatar gnieto avatar janik-cloudflare avatar jtescher avatar kj800x avatar lukemathwalker avatar markdingram avatar ptescher avatar robjtede avatar tl-marco-ieni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

actix-web-opentelemetry's Issues

zstd?

Why does this crate force the use of actix-http/zstd?

It looks like this was introduced by 10bee3e, cc @fourbytes .

Update Opentelemetry to 1.19

Opentelemetry v1.19 was released and It would be really lovely to update all crates, not just the Opentelemetry

Is there a logging feature?

image

I wanna capture these kinds of log (ERROR, INFO, WARN) from the running console, and export them to something like Logstash, but I only find Metrics and Tracing features in the docs.

Add a full example using OTLP

Hi,
Just wanted to ask if it's possible to add an example of using actix-web-opentelemetry with a pipeline using OTLP.
That will allow people to start quickly and send traces to Observability tools.

Release v3 ?

Could you release the v3 of this module on cargo please ? ๐Ÿ˜Š

no default features for actix-web

The dependency in Cargo.toml should ideally be:

- actix-web = "3.0.2"
+ actix-web = { version = "3.0.2", default-features = false }

status code handling for awc client

It seems currently the client span won't set span status to error when the http request fails in some ways (5xx, 4xx, etc), so the resulting spans' status are always UNSET. Do you think its reasonable to automatically set the span status according to the http status similar to what golang's contrib net/http do? (https://github.com/open-telemetry/opentelemetry-go-contrib/blob/6c86403/instrumentation/net/http/otelhttp/handler.go#L219)

The spec have this included so at least we have a standard to follow.

Filter requests being traced

Hello,

Thanks for this library! We would like to filter requests being traced to exclude healthchecks ones, is there a way to implement a filter determining if a request needs to be traced?

Zipkin pipeline fail

If i try to use zipkin pipeline instead of jaeger it fail with: Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.

Code:

[dependencies]
actix-web = "3.2"
actix-web-opentelemetry = "0.7"
opentelemetry-zipkin = "0.7"
use actix_web::{get, web, App, HttpServer, Responder};
use actix_web_opentelemetry::RequestTracing;

#[get("/{id}/{name}/index.html")]
async fn index(web::Path((id, name)): web::Path<(u32, String)>) -> impl Responder {
    format!("Hello {}! id:{}", name, id)
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    opentelemetry_zipkin::new_pipeline()
            .install()
            .expect("pipeline install error");
    HttpServer::new(|| App::new().service(index).wrap(RequestTracing::new()))
        .bind("127.0.0.1:8080")?
        .run()
        .await
}

Guidance: Accessing the current span from another middleware

This may not be possible but as of today I haven't found a way to access the context created by this middleware in my own middleware. Is this possible or am I missing something. I have tried ordering my middleware registration in all the combinations I could think of.

I would love some guidance on what might be possible today.

Thank you.

Using RequestTracingMiddleware with a TraceContextPropagator.

hey ๐Ÿ‘‹ thanks for putting together this crate!

I see you've defined the type RequestTracingMiddleware to be generic in terms of an HttpTextFormat, and was hoping to use this type like RequestTracing does, but with TraceContextPropagator instead of B3Propagator.

In trying to do the above myself, I found that RequestTracingMiddleware is public but not exposed in lib.rs.

#[derive(Debug)]
pub struct RequestTracingMiddleware<S, H: api::HttpTextFormat, R: RouteFormatter> {
service: S,
header_extractor: H,
route_formatter: R,
}

pub use {
client::with_tracing,
middleware::metrics::{RequestMetrics, RequestMetricsMiddleware},
middleware::route_formatter::{RouteFormatter, UuidWildcardFormatter},
middleware::trace::RequestTracing,
};

Have you given thought to how library users can do this, and what the desired api would be? Ideally I could write something as simple as:

use actix_web_opentelemetry::RequestTracing
...
App::new().wrap(RequestTracing::new(TextContextPropagator::new()))

thanks for everything ๐Ÿ™

Please help with the example

This code (from your example, with 1 small change)

let (_tracer, _uninstall) = opentelemetry_jaeger::new_pipeline()
      .with_agent_endpoint("localhost:6831")
      .install()
      .expect("pipeline install error");

produces this error:

thread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime'

In your example, there is no special Tokio runtime created to run this code, and I'd like to avoid it too :)
Could you please give me a hint on how to make it work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.