Skip to content

Commit

Permalink
Merge branch 'main' into sem-conv-1.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored May 31, 2024
2 parents 7d029d4 + 82fa485 commit 88e12ab
Show file tree
Hide file tree
Showing 103 changed files with 2,269 additions and 1,154 deletions.
7 changes: 7 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
"Cijo",
"clippy",
"codecov",
"datapoint",
"deque",
"Dirkjan",
"EPYC",
"hasher",
"isahc",
"Isobel",
Expand All @@ -43,6 +45,9 @@
"Lalit",
"LIBCLANG",
"msrv",
"mykey",
"myvalue",
"nocapture",
"Ochtman",
"opentelemetry",
"OTLP",
Expand All @@ -53,8 +58,10 @@
"runtimes",
"rustc",
"shoppingcart",
"struct",
"Tescher",
"tracerprovider",
"updown",
"Zhongyang",
"zipkin"
],
Expand Down
21 changes: 3 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2024-02-07
toolchain: nightly-2024-05-01
components: rustfmt
- name: external-type-check
run: |
Expand Down Expand Up @@ -110,10 +110,8 @@ jobs:
- uses: dtolnay/rust-toolchain@1.65.0
- name: Patch dependencies versions # some dependencies bump MSRV without major version bump
run: bash ./scripts/patch_dependencies.sh
- name: Run tests
run: cargo --version &&
cargo test --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,testing &&
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml
- name: Check MSRV for all crates
run: bash ./scripts/msrv.sh
cargo-deny:
runs-on: ubuntu-latest # This uses the step `EmbarkStudios/cargo-deny-action@v1` which is only supported on Linux
continue-on-error: true # Prevent sudden announcement of a new advisory from failing ci
Expand All @@ -138,19 +136,6 @@ jobs:
env:
CARGO_INCREMENTAL: '0'
RUSTDOCFLAGS: -Dwarnings
semver: # This job uses the latest published crate as baseline for comparison.
runs-on: ubuntu-latest
name: semver
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo-semver-checks
uses: obi1kenobi/cargo-semver-checks-action@v2.3
coverage:
continue-on-error: true
runs-on: ubuntu-latest
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/semver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Semver compliance
env:
CI: true
on:
pull_request:
types: [ labeled, synchronize, opened, reopened ]

jobs:
semver-compliance: # This job uses the latest published crate as baseline for comparison.
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.event.label.name == 'semver-check' || contains(github.event.pull_request.labels.*.name, 'semver-check') }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo-semver-checks
uses: obi1kenobi/cargo-semver-checks-action@v2.3
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ You can provide the protocol compiler protoc path programmatically (only works w
export PROTOC=$(which protoc)
```

It is recommended to use "3.15" or newer of protoc, as some of the proto
definitions include "optional" fields, that are not supported in older versions,
resulting in errors as shown
[here](https://github.com/open-telemetry/opentelemetry-proto/issues/451).

Prerequisites to build the protocol compiler protoc from source

- [protoc](https://github.com/protocolbuffers/protobuf)
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ debug = 1
async-std = "1.10"
async-trait = "0.1"
bytes = "1"
env_logger = { version = "0.10", default-features = false } # env_logger requires a newer MSRV
futures-core = "0.3"
futures-executor = "0.3"
futures-util = { version = "0.3", default-features = false }
Expand Down
12 changes: 5 additions & 7 deletions examples/logs-basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use log::{error, Level};
use opentelemetry::KeyValue;
use opentelemetry_appender_log::OpenTelemetryLogBridge;
use opentelemetry_sdk::logs::{Config, LoggerProvider};
use opentelemetry_sdk::logs::LoggerProvider;
use opentelemetry_sdk::Resource;
use opentelemetry_semantic_conventions::resource::SERVICE_NAME;

Expand All @@ -13,12 +13,10 @@ fn main() {
// Ok(serde_json::to_writer_pretty(writer, &data).unwrap()))
.build();
let logger_provider = LoggerProvider::builder()
.with_config(
Config::default().with_resource(Resource::new(vec![KeyValue::new(
SERVICE_NAME,
"logs-basic-example",
)])),
)
.with_resource(Resource::new(vec![KeyValue::new(
SERVICE_NAME,
"logs-basic-example",
)]))
.with_simple_exporter(exporter)
.build();

Expand Down
7 changes: 3 additions & 4 deletions examples/metrics-advanced/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use opentelemetry::global;
use opentelemetry::metrics::Unit;
use opentelemetry::Key;
use opentelemetry::KeyValue;
use opentelemetry_sdk::metrics::{
Expand All @@ -15,7 +14,7 @@ fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider {
Some(
Stream::new()
.name("my_histogram_renamed")
.unit(Unit::new("milliseconds")),
.unit("milliseconds"),
)
} else {
None
Expand Down Expand Up @@ -76,7 +75,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
// using view.
let histogram = meter
.f64_histogram("my_histogram")
.with_unit(Unit::new("ms"))
.with_unit("ms")
.with_description("My histogram example description")
.init();

Expand Down Expand Up @@ -114,7 +113,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
// use a custom set of boundaries, and min/max values will not be recorded.
let histogram2 = meter
.f64_histogram("my_second_histogram")
.with_unit(Unit::new("ms"))
.with_unit("ms")
.with_description("My histogram example description")
.init();

Expand Down
9 changes: 4 additions & 5 deletions examples/metrics-basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use opentelemetry::global;
use opentelemetry::metrics::Unit;
use opentelemetry::KeyValue;
use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider};
use opentelemetry_sdk::{runtime, Resource};
Expand Down Expand Up @@ -47,7 +46,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let _observable_counter = meter
.u64_observable_counter("my_observable_counter")
.with_description("My observable counter example description")
.with_unit(Unit::new("myunit"))
.with_unit("myunit")
.with_callback(|observer| {
observer.observe(
100,
Expand Down Expand Up @@ -75,7 +74,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let _observable_up_down_counter = meter
.i64_observable_up_down_counter("my_observable_updown_counter")
.with_description("My observable updown counter example description")
.with_unit(Unit::new("myunit"))
.with_unit("myunit")
.with_callback(|observer| {
observer.observe(
100,
Expand Down Expand Up @@ -108,7 +107,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let gauge = meter
.f64_gauge("my_gauge")
.with_description("A gauge set to 1.0")
.with_unit(Unit::new("myunit"))
.with_unit("myunit")
.init();

gauge.record(
Expand All @@ -123,7 +122,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let _observable_gauge = meter
.f64_observable_gauge("my_observable_gauge")
.with_description("An observable gauge set to 1.0")
.with_unit(Unit::new("myunit"))
.with_unit("myunit")
.with_callback(|observer| {
observer.observe(
1.0,
Expand Down
7 changes: 4 additions & 3 deletions examples/tracing-jaeger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use opentelemetry_semantic_conventions::resource::SERVICE_NAME;

use std::error::Error;

fn init_tracer() -> Result<opentelemetry_sdk::trace::Tracer, TraceError> {
fn init_tracer_provider() -> Result<opentelemetry_sdk::trace::TracerProvider, TraceError> {
opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(
Expand All @@ -19,7 +19,7 @@ fn init_tracer() -> Result<opentelemetry_sdk::trace::Tracer, TraceError> {
.with_endpoint("http://localhost:4317"),
)
.with_trace_config(
sdktrace::config().with_resource(Resource::new(vec![KeyValue::new(
sdktrace::Config::default().with_resource(Resource::new(vec![KeyValue::new(
SERVICE_NAME,
"tracing-jaeger",
)])),
Expand All @@ -29,7 +29,8 @@ fn init_tracer() -> Result<opentelemetry_sdk::trace::Tracer, TraceError> {

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let _tracer = init_tracer().expect("Failed to initialize tracer.");
let tracer_provider = init_tracer_provider().expect("Failed to initialize tracer provider.");
global::set_tracer_provider(tracer_provider.clone());

let tracer = global::tracer("tracing-jaeger");
tracer.in_span("main-operation", |cx| {
Expand Down
20 changes: 9 additions & 11 deletions opentelemetry-appender-tracing/benches/logs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
The benchmark results:
criterion = "0.5.1"
OS: Ubuntu 22.04.2 LTS (5.10.102.1-microsoft-standard-WSL2)
OS: Ubuntu 22.04.3 LTS (5.15.146.1-microsoft-standard-WSL2)
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
RAM: 64.0 GB
| Test | Average time|
Expand All @@ -10,7 +10,7 @@
| noop_layer_disabled | 12 ns |
| noop_layer_enabled | 25 ns |
| ot_layer_disabled | 19 ns |
| ot_layer_enabled | 561 ns |
| ot_layer_enabled | 371 ns |
*/

use async_trait::async_trait;
Expand All @@ -19,7 +19,7 @@ use opentelemetry::logs::LogResult;
use opentelemetry::KeyValue;
use opentelemetry_appender_tracing::layer as tracing_layer;
use opentelemetry_sdk::export::logs::{LogData, LogExporter};
use opentelemetry_sdk::logs::{Config, LogProcessor, LoggerProvider};
use opentelemetry_sdk::logs::{LogProcessor, LoggerProvider};
use opentelemetry_sdk::Resource;
use tracing::error;
use tracing_subscriber::prelude::*;
Expand All @@ -33,7 +33,7 @@ struct NoopExporter {

#[async_trait]
impl LogExporter for NoopExporter {
async fn export(&mut self, _: Vec<LogData>) -> LogResult<()> {
async fn export<'a>(&mut self, _: Vec<std::borrow::Cow<'a, LogData>>) -> LogResult<()> {
LogResult::Ok(())
}

Expand All @@ -54,7 +54,7 @@ impl NoopProcessor {
}

impl LogProcessor for NoopProcessor {
fn emit(&self, _: LogData) {
fn emit(&self, _: &mut LogData) {
// no-op
}

Expand Down Expand Up @@ -125,12 +125,10 @@ fn benchmark_with_ot_layer(c: &mut Criterion, enabled: bool, bench_name: &str) {
let exporter = NoopExporter { enabled };
let processor = NoopProcessor::new(Box::new(exporter));
let provider = LoggerProvider::builder()
.with_config(
Config::default().with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"benchmark",
)])),
)
.with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"benchmark",
)]))
.with_log_processor(processor)
.build();
let ot_layer = tracing_layer::OpenTelemetryTracingBridge::new(&provider);
Expand Down
15 changes: 5 additions & 10 deletions opentelemetry-appender-tracing/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@
use opentelemetry::KeyValue;
use opentelemetry_appender_tracing::layer;
use opentelemetry_sdk::{
logs::{Config, LoggerProvider},
Resource,
};
use opentelemetry_sdk::{logs::LoggerProvider, Resource};
use tracing::error;
use tracing_subscriber::prelude::*;

fn main() {
let exporter = opentelemetry_stdout::LogExporter::default();
let provider: LoggerProvider = LoggerProvider::builder()
.with_config(
Config::default().with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"log-appender-tracing-example",
)])),
)
.with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"log-appender-tracing-example",
)]))
.with_simple_exporter(exporter)
.build();
let layer = layer::OpenTelemetryTracingBridge::new(&provider);
Expand Down
Loading

0 comments on commit 88e12ab

Please sign in to comment.