-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 168-otlp-span-exporter-env-cfg
- Loading branch information
Showing
40 changed files
with
1,947 additions
and
1,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,20 +23,21 @@ jobs: | |
- name: Test | ||
run: ./scripts/test.sh | ||
lint: | ||
strategy: | ||
matrix: | ||
rust: [stable, beta] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
submodules: true | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
toolchain: stable | ||
components: rustfmt | ||
profile: minimal | ||
- uses: arduino/setup-protoc@v1 | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
- name: Lint | ||
run: ./scripts/lint.sh | ||
msrv: | ||
|
@@ -55,7 +56,7 @@ jobs: | |
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,tokio-support,serde,testing && | ||
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml && | ||
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml | ||
meta: | ||
coverage: | ||
continue-on-error: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -65,21 +66,15 @@ jobs: | |
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
components: rustfmt, clippy | ||
override: true | ||
- uses: arduino/setup-protoc@v1 | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: -p opentelemetry --all-features --no-fail-fast | ||
args: -p opentelemetry -p opentelemetry-jaeger -p opentelemetry-zipkin -p opentelemetry-datadog -p opentelemetry-aws --all-features --no-fail-fast | ||
env: | ||
CARGO_INCREMENTAL: '0' | ||
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | ||
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | ||
- uses: actions-rs/[email protected] | ||
- uses: codecov/codecov-action@v1 | ||
- run: cargo fmt -- --check | ||
- uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --all-features --workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "external-otlp-tonic-tokio" | ||
version = "0.1.0" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
futures = "0.3" | ||
opentelemetry = { path = "../../opentelemetry", features = [ | ||
"tokio-support", | ||
"metrics", | ||
"serialize" | ||
] } | ||
opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = [ | ||
"tonic", | ||
"tls", | ||
"tls-roots", | ||
] } | ||
serde_json = "1.0" | ||
tokio = { version = "1.0", features = ["full"] } | ||
tonic = "0.4.0" | ||
url = "2.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# External OTLP collector with tonic and tokio with TLS | ||
|
||
This example shows basic span, and exports to OTLP enabled collectors, like honeycomb, lightstep and other services. | ||
As these services all reside outside your own infrastructure, they require TLS for encryption to ensure your data safety. | ||
With this example, you can export to any service that supports OTLP by using environment variables. | ||
The following example exports data to Honeycomb: | ||
|
||
```shell | ||
OTLP_TONIC_ENDPOINT=https://api.honeycomb.io:443 \ | ||
OTLP_TONIC_X_HONEYCOMB_TEAM=token \ | ||
OTLP_TONIC_X_HONEYCOMB_DATASET=dataset \' | ||
cargo run --bin external-otlp-tonic-tokio | ||
``` | ||
|
||
The only required variable is `OTLP_TONIC_ENDPOINT` and any other variable that beggins with the prefix `OTLP_TONIC_` will be sent as headers | ||
e.g.: `OTLP_TONIC_X_HONEYCOMB_TEAM` becomes `x-honeycomb-team` and `OTLP_TONIC_X_HONEYCOMB_DATASET` becomes `x-honeycomb-dataset`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
//! This should show how to connect to a third party collector like | ||
//! honeycomb or lightstep using tonic with tls and using tokio as reactor. | ||
//! To run this you have to specify a few environment variables like in the example: | ||
//! ```shell | ||
//! OTLP_TONIC_ENDPOINT=https://api.honeycomb.io:443 \ | ||
//! OTLP_TONIC_X_HONEYCOMB_TEAM=token \ | ||
//! OTLP_TONIC_X_HONEYCOMB_DATASET=dataset \' | ||
//! cargo run --bin external-otlp-tonic-tokio | ||
//! ``` | ||
use opentelemetry::trace::TraceError; | ||
use opentelemetry::{global, sdk::trace as sdktrace}; | ||
use opentelemetry::{ | ||
trace::{TraceContextExt, Tracer}, | ||
Key, | ||
}; | ||
use tonic::{ | ||
metadata::{MetadataKey, MetadataMap}, | ||
transport::ClientTlsConfig, | ||
}; | ||
use url::Url; | ||
|
||
use std::{env::vars, str::FromStr, time::Duration}; | ||
use std::{ | ||
env::{remove_var, var}, | ||
error::Error, | ||
}; | ||
|
||
// Use the variables to try and export the example to any external collector that accepts otlp | ||
// like: oltp itself, honeycomb or lightstep | ||
const ENDPOINT: &str = "OTLP_TONIC_ENDPOINT"; | ||
const HEADER_PREFIX: &str = "OTLP_TONIC_"; | ||
|
||
fn init_tracer() -> Result<(sdktrace::Tracer, opentelemetry_otlp::Uninstall), TraceError> { | ||
let endpoint = var(ENDPOINT).unwrap_or_else(|_| { | ||
panic!( | ||
"You must specify and endpoint to connect to with the variable {:?}.", | ||
ENDPOINT | ||
) | ||
}); | ||
let endpoint = Url::parse(&endpoint).expect("endpoint is not a valid url"); | ||
remove_var(ENDPOINT); | ||
let mut metadata = MetadataMap::new(); | ||
for (key, value) in vars() | ||
.filter(|(name, _)| name.starts_with(HEADER_PREFIX)) | ||
.map(|(name, value)| { | ||
let header_name = name | ||
.strip_prefix(HEADER_PREFIX) | ||
.map(|h| h.replace("_", "-")) | ||
.map(|h| h.to_ascii_lowercase()) | ||
.unwrap(); | ||
(header_name, value) | ||
}) | ||
{ | ||
metadata.insert(MetadataKey::from_str(&key).unwrap(), value.parse().unwrap()); | ||
} | ||
|
||
opentelemetry_otlp::new_pipeline() | ||
.with_endpoint(endpoint.as_str()) | ||
.with_metadata(dbg!(metadata)) | ||
.with_tls_config( | ||
ClientTlsConfig::new().domain_name( | ||
endpoint | ||
.host_str() | ||
.expect("the specified endpoint should have a valid host"), | ||
), | ||
) | ||
.install() | ||
} | ||
|
||
const LEMONS_KEY: Key = Key::from_static_str("ex.com/lemons"); | ||
const ANOTHER_KEY: Key = Key::from_static_str("ex.com/another"); | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> { | ||
let (_, _guard) = init_tracer()?; | ||
|
||
let tracer = global::tracer("ex.com/basic"); | ||
|
||
tracer.in_span("operation", |cx| { | ||
let span = cx.span(); | ||
span.add_event( | ||
"Nice operation!".to_string(), | ||
vec![Key::new("bogons").i64(100)], | ||
); | ||
span.set_attribute(ANOTHER_KEY.string("yes")); | ||
|
||
tracer.in_span("Sub operation...", |cx| { | ||
let span = cx.span(); | ||
span.set_attribute(LEMONS_KEY.string("five")); | ||
|
||
span.add_event("Sub span event".to_string(), vec![]); | ||
}); | ||
}); | ||
|
||
// wait for 1 minutes so that we could see metrics being pushed via OTLP every 10 seconds. | ||
tokio::time::sleep(Duration::from_secs(60)).await; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## v0.1.0 | ||
|
||
### Added | ||
|
||
- AWS XRay propagator |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Code owners file. | ||
# This file controls who is tagged for review for any given pull request. | ||
|
||
# For anything not explicitly taken by someone else: | ||
* @open-telemetry/rust-approvers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "opentelemetry-aws" | ||
version = "0.1.0" | ||
authors = ["OpenTelemetry Authors <[email protected]>"] | ||
description = "AWS exporters and propagators for OpenTelemetry" | ||
homepage = "https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-aws" | ||
repository = "https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-aws" | ||
readme = "README.md" | ||
categories = [ | ||
"development-tools::debugging", | ||
"development-tools::profiling", | ||
] | ||
keywords = ["opentelemetry", "tracing"] | ||
license = "Apache-2.0" | ||
edition = "2018" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[features] | ||
default = ["trace"] | ||
trace = ["opentelemetry/trace"] | ||
|
||
[dependencies] | ||
opentelemetry = { version = "0.12", path = "../opentelemetry", features = ["trace"] } | ||
lazy_static = "1.4" | ||
|
||
[dev-dependencies] | ||
opentelemetry = { path = "../opentelemetry", features = ["trace", "testing"] } |
Oops, something went wrong.