gracefully shutdown reporter & add agent-test-tool based e2e case (#9)

16 files changed
tree: 84e0718c360eb2e7e4544584651f5700aab48f1d
  1. .github/
  2. examples/
  3. src/
  4. tests/
  5. .asf.yaml
  6. .dockerignore
  7. .gitignore
  8. .gitmodules
  9. Cargo.lock
  10. Cargo.toml
  11. LICENSE
  12. NOTICE
  13. README.md
  14. build.rs
  15. docker-compose.dev.yml
  16. docker-compose.e2e.yml
  17. requirements.txt
  18. rust-toolchain.toml
README.md

Apache SkyWalking Rust Agent

Twitter Follow

CI

SkyWalking Rust Agent provides observability capability for Rust App and Library, including tracing, metrics, topology map for distributed system and alert. It uses SkyWalking native formats and core concepts to keep best compatibility and performance.

Concepts

All concepts are from the official SkyWalking definitions.

Span

Span is an important and common concept in distributed tracing system. Learn Span from Google Dapper Paper. For better performance, we extend the span into 3 kinds.

  1. EntrySpan EntrySpan represents a service provider, also the endpoint of server side. As an APM system, we are targeting the application servers. So almost all the services and MQ-consumer are EntrySpan(s).
  2. LocalSpan LocalSpan represents a normal Java method, which does not relate to remote service, neither a MQ producer/consumer nor a service(e.g. HTTP service) provider/consumer.
  3. ExitSpan ExitSpan represents a client of service or MQ-producer, as named as LeafSpan at early age of SkyWalking. e.g. accessing DB by JDBC, reading Redis/Memcached are cataloged an ExitSpan.

Tag and Log are similar attributes of the span.

  • Tag is a key:value pair to indicate the attribute with a string value.
  • Log is heavier than tag, with one timestamp and multiple key:value pairs. Log represents an event, typically an error happens.

TracingContext

TracingContext is the context of the tracing process. Span should only be created through context, and be archived into the context after the span finished.

Example

use skywalking_rust::context::trace_context::TracingContext;
use skywalking_rust::reporter::grpc::Reporter;
use tokio;

async fn handle_request(reporter: ContextReporter) {
    let mut ctx = TracingContext::default("svc", "ins");
    {
        // Generate an Entry Span when a request
        // is received. An Entry Span is generated only once per context.
        let span = ctx.create_entry_span("operation1").unwrap();

        // Something...

        {
            // Generates an Exit Span when executing an RPC.
            let span2 = ctx.create_exit_span("operation2").unwrap();
            
            // Something...

            ctx.finalize_span(span2);
        }

        ctx.finalize_span(span);
    }
    reporter.send(context).await;
}

#[tokio::main]
async fn main() {
    let tx = Reporter::start("http://0.0.0.0:11800").await;

    // Start server...
}

License

Apache 2.0