Skip to content

Commit

Permalink
Merge branch 'main' into logger-invalid-name
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Nov 21, 2024
2 parents 0683c3f + af9d925 commit 74b08ad
Show file tree
Hide file tree
Showing 28 changed files with 461 additions and 349 deletions.
22 changes: 1 addition & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,6 @@ jobs:
cargo install [email protected]
cd ${{ matrix.example }}
cargo check-external-types --config allowed-external-types.toml
non-default-examples:
strategy:
matrix:
os: [ windows-latest, ubuntu-latest ]
example: [opentelemetry-otlp/examples/basic-otlp]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: |
cd ${{ matrix.example }}
cargo build --verbose
msrv:
strategy:
matrix:
Expand Down Expand Up @@ -132,7 +112,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: arduino/setup-protoc@v3
Expand Down
12 changes: 5 additions & 7 deletions examples/tracing-jaeger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use opentelemetry::{
KeyValue,
};
use opentelemetry_sdk::trace::TracerProvider;
use opentelemetry_sdk::{runtime, trace as sdktrace, Resource};
use opentelemetry_sdk::{runtime, Resource};
use opentelemetry_semantic_conventions::resource::SERVICE_NAME;

use std::error::Error;
Expand All @@ -17,12 +17,10 @@ fn init_tracer_provider() -> Result<opentelemetry_sdk::trace::TracerProvider, Tr

Ok(TracerProvider::builder()
.with_batch_exporter(exporter, runtime::Tokio)
.with_config(
sdktrace::Config::default().with_resource(Resource::new(vec![KeyValue::new(
SERVICE_NAME,
"tracing-jaeger",
)])),
)
.with_resource(Resource::new(vec![KeyValue::new(
SERVICE_NAME,
"tracing-jaeger",
)]))
.build())
}

Expand Down
5 changes: 2 additions & 3 deletions opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ mod tests {
use opentelemetry_sdk::export::logs::{LogBatch, LogExporter};
use opentelemetry_sdk::logs::{LogRecord, LogResult, LoggerProvider};
use opentelemetry_sdk::testing::logs::InMemoryLogExporter;
use opentelemetry_sdk::trace;
use opentelemetry_sdk::trace::{Sampler, TracerProvider};
use tracing::{error, warn};
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
Expand Down Expand Up @@ -402,7 +401,7 @@ mod tests {

// setup tracing as well.
let tracer_provider = TracerProvider::builder()
.with_config(trace::Config::default().with_sampler(Sampler::AlwaysOn))
.with_sampler(Sampler::AlwaysOn)
.build();
let tracer = tracer_provider.tracer("test-tracer");

Expand Down Expand Up @@ -579,7 +578,7 @@ mod tests {

// setup tracing as well.
let tracer_provider = TracerProvider::builder()
.with_config(trace::Config::default().with_sampler(Sampler::AlwaysOn))
.with_sampler(Sampler::AlwaysOn)
.build();
let tracer = tracer_provider.tracer("test-tracer");

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/examples/basic-otlp-http/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use opentelemetry_sdk::{
logs::LoggerProvider,
metrics::{MetricError, PeriodicReader, SdkMeterProvider},
runtime,
trace::{self as sdktrace, Config, TracerProvider},
trace::{self as sdktrace, TracerProvider},
};
use opentelemetry_sdk::{
logs::{self as sdklogs},
Expand Down Expand Up @@ -52,7 +52,7 @@ fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {

Ok(TracerProvider::builder()
.with_batch_exporter(exporter, runtime::Tokio)
.with_config(Config::default().with_resource(RESOURCE.clone()))
.with_resource(RESOURCE.clone())
.build())
}

Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-otlp/examples/basic-otlp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use opentelemetry_sdk::logs::LogError;
use opentelemetry_sdk::logs::LoggerProvider;
use opentelemetry_sdk::metrics::MetricError;
use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider};
use opentelemetry_sdk::trace::Config;
use opentelemetry_sdk::{runtime, trace as sdktrace, Resource};
use std::error::Error;
use tracing::info;
Expand All @@ -28,7 +27,7 @@ fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
.with_endpoint("http://localhost:4317")
.build()?;
Ok(sdktrace::TracerProvider::builder()
.with_config(Config::default().with_resource(RESOURCE.clone()))
.with_resource(RESOURCE.clone())
.with_batch_exporter(exporter, runtime::Tokio)
.build())
}
Expand Down
10 changes: 4 additions & 6 deletions opentelemetry-otlp/tests/integration_test/tests/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
.build()?;
Ok(opentelemetry_sdk::trace::TracerProvider::builder()
.with_batch_exporter(exporter, runtime::Tokio)
.with_config(
sdktrace::Config::default().with_resource(Resource::new(vec![KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
"basic-otlp-tracing-example",
)])),
)
.with_resource(Resource::new(vec![KeyValue::new(
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
"basic-otlp-tracing-example",
)]))
.build())
}

Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-proto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## vNext

- Update proto definitions to v1.4.0 [#2315](https://github.com/open-telemetry/opentelemetry-rust/pull/2315)


## 0.27.0

Released 2024-Nov-11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
/// storage, OR can be embedded by other protocols that transfer OTLP metrics
/// data but do not implement the OTLP protocol.
///
/// MetricsData
/// └─── ResourceMetrics
/// ├── Resource
/// ├── SchemaURL
/// └── ScopeMetrics
/// ├── Scope
/// ├── SchemaURL
/// └── Metric
/// ├── Name
/// ├── Description
/// ├── Unit
/// └── data
/// ├── Gauge
/// ├── Sum
/// ├── Histogram
/// ├── ExponentialHistogram
/// └── Summary
///
/// The main difference between this message and collector protocol is that
/// in this message there will not be any "control" or "metadata" specific to
/// OTLP protocol.
Expand Down Expand Up @@ -71,7 +89,6 @@ pub struct ScopeMetrics {
///
/// <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md>
///
///
/// The data model and relation between entities is shown in the
/// diagram below. Here, "DataPoint" is the term used to refer to any
/// one of the specific data point value types, and "points" is the term used
Expand All @@ -83,7 +100,7 @@ pub struct ScopeMetrics {
/// - DataPoint contains timestamps, attributes, and one of the possible value type
/// fields.
///
/// Metric
/// Metric
/// +------------+
/// |name |
/// |description |
Expand Down Expand Up @@ -277,6 +294,9 @@ pub struct ExponentialHistogram {
/// data type. These data points cannot always be merged in a meaningful way.
/// While they can be useful in some applications, histogram data points are
/// recommended for new applications.
/// Summary metrics do not have an aggregation temporality field. This is
/// because the count and sum fields of a SummaryDataPoint are assumed to be
/// cumulative values.
#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
Expand Down Expand Up @@ -587,7 +607,8 @@ pub mod exponential_histogram_data_point {
}
}
/// SummaryDataPoint is a single data point in a timeseries that describes the
/// time-varying values of a Summary metric.
/// time-varying values of a Summary metric. The count and sum fields represent
/// cumulative values.
#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
Expand Down
16 changes: 16 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

## vNext

- **DEPRECATED**:
- `trace::Config` methods are moving onto `TracerProvider` Builder to be consistent with other signals. See https://github.com/open-telemetry/opentelemetry-rust/pull/2303 for migration guide.
`trace::Config` is scheduled to be removed from public API in `v0.28.0`.
example:
```rust
// old
let tracer_provider: TracerProvider = TracerProvider::builder()
.with_config(Config::default().with_resource(Resource::empty()))
.build();

// new
let tracer_provider: TracerProvider = TracerProvider::builder()
.with_resource(Resource::empty())
.build();
```

## 0.27.0

Released 2024-Nov-11
Expand Down
5 changes: 1 addition & 4 deletions opentelemetry-sdk/benches/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use opentelemetry::{
};
use opentelemetry_sdk::{
export::trace::{ExportResult, SpanData, SpanExporter},
trace,
trace::{Sampler, TracerProvider},
};
#[cfg(not(target_os = "windows"))]
Expand Down Expand Up @@ -127,9 +126,7 @@ impl Display for Environment {

fn parent_sampled_tracer(inner_sampler: Sampler) -> (TracerProvider, BoxedTracer) {
let provider = TracerProvider::builder()
.with_config(
trace::Config::default().with_sampler(Sampler::ParentBased(Box::new(inner_sampler))),
)
.with_sampler(Sampler::ParentBased(Box::new(inner_sampler)))
.with_simple_exporter(NoopExporter)
.build();
let tracer = provider.tracer(module_path!());
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-sdk/benches/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use opentelemetry::trace::Tracer;
use opentelemetry::trace::TracerProvider as _;
use opentelemetry::{InstrumentationScope, Key};
use opentelemetry_sdk::logs::{LogProcessor, LogRecord, LogResult, Logger, LoggerProvider};
use opentelemetry_sdk::trace;
use opentelemetry_sdk::trace::{Sampler, TracerProvider};

#[derive(Debug)]
Expand Down Expand Up @@ -65,7 +64,7 @@ fn log_benchmark_group<F: Fn(&Logger)>(c: &mut Criterion, name: &str, f: F) {

// setup tracing as well.
let tracer_provider = TracerProvider::builder()
.with_config(trace::Config::default().with_sampler(Sampler::AlwaysOn))
.with_sampler(Sampler::AlwaysOn)
.build();
let tracer = tracer_provider.tracer("bench-tracer");

Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-sdk/benches/metrics_counter.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
The benchmark results:
criterion = "0.5.1"
OS: Ubuntu 22.04.3 LTS (5.15.146.1-microsoft-standard-WSL2)
rustc 1.82.0 (f6e511eec 2024-10-15)
OS: Ubuntu 22.04.3 LTS (5.15.167.4-microsoft-standard-WSL2)
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
RAM: 64.0 GB
| Test | Average time|
|--------------------------------|-------------|
| Counter_Add_Sorted | 193 ns |
| Counter_Add_Unsorted | 209 ns |
| Counter_Add_Sorted | 172 ns |
| Counter_Add_Unsorted | 183 ns |
| Counter_Overflow | 898 ns |
| ThreadLocal_Random_Generator_5 | 37 ns |
*/
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-sdk/benches/metrics_gauge.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
The benchmark results:
criterion = "0.5.1"
OS: Ubuntu 22.04.4 LTS (5.15.153.1-microsoft-standard-WSL2)
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz, 16vCPUs,
rustc 1.82.0 (f6e511eec 2024-10-15)
OS: Ubuntu 22.04.4 LTS (5.15.167.4-microsoft-standard-WSL2)
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
RAM: 64.0 GB
| Test | Average time|
|--------------------------------|-------------|
| Gauge_Add | 178.37 ns |
| Gauge_Add | 187.49 ns |
*/

use criterion::{criterion_group, criterion_main, Criterion};
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-sdk/benches/metrics_histogram.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
The benchmark results:
criterion = "0.5.1"
OS: Ubuntu 22.04.4 LTS (5.15.153.1-microsoft-standard-WSL2)
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz, 16vCPUs,
rustc 1.82.0 (f6e511eec 2024-10-15)
OS: Ubuntu 22.04.4 LTS (5.15.167.4-microsoft-standard-WSL2)
Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
RAM: 64.0 GB
| Test | Average time|
|--------------------------------|-------------|
| Histogram_Record | 193.04 ns |
| Histogram_Record | 225.04 ns |
*/

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/benches/span_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn span_builder_benchmark_group(c: &mut Criterion) {

fn not_sampled_provider() -> (sdktrace::TracerProvider, sdktrace::Tracer) {
let provider = sdktrace::TracerProvider::builder()
.with_config(sdktrace::Config::default().with_sampler(sdktrace::Sampler::AlwaysOff))
.with_sampler(sdktrace::Sampler::AlwaysOff)
.with_simple_exporter(NoopExporter)
.build();
let tracer = provider.tracer("not-sampled");
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/benches/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn trace_benchmark_group<F: Fn(&sdktrace::Tracer)>(c: &mut Criterion, name: &str

group.bench_function("always-sample", |b| {
let provider = sdktrace::TracerProvider::builder()
.with_config(sdktrace::Config::default().with_sampler(sdktrace::Sampler::AlwaysOn))
.with_sampler(sdktrace::Sampler::AlwaysOn)
.with_simple_exporter(VoidExporter)
.build();
let always_sample = provider.tracer("always-sample");
Expand All @@ -80,7 +80,7 @@ fn trace_benchmark_group<F: Fn(&sdktrace::Tracer)>(c: &mut Criterion, name: &str

group.bench_function("never-sample", |b| {
let provider = sdktrace::TracerProvider::builder()
.with_config(sdktrace::Config::default().with_sampler(sdktrace::Sampler::AlwaysOff))
.with_sampler(sdktrace::Sampler::AlwaysOff)
.with_simple_exporter(VoidExporter)
.build();
let never_sample = provider.tracer("never-sample");
Expand Down
Loading

0 comments on commit 74b08ad

Please sign in to comment.