Skip to content

Commit f19b130

Browse files
authored
Merge branch 'main' into remove-env-logger
2 parents 9ea90ff + 5fba0de commit f19b130

File tree

85 files changed

+7485
-2353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+7485
-2353
lines changed

.github/ISSUE_TEMPLATE/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ contact_links:
44
about: Please ask questions here.
55
- name: Slack
66
url: https://cloud-native.slack.com/archives/C03GDP0H023
7-
about: Or the `#otel-rust` channel in the CNCF Slack instance. (Not terribly responsive.)
7+
about: Or the `#otel-rust` channel in the CNCF Slack instance.
88
- name: "⚠️ Report a security vulnerability"
99
url: "https://github.com/open-telemetry/opentelemetry-rust/security/advisories/new"
1010
about: "Report a security vulnerability."

.github/repository-settings.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Log of local changes
2+
3+
Maintainers are expected to maintain this log. This is required as per
4+
[OpenTelemetry Community
5+
guidelines](https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md#collaborators-and-teams).
6+
7+
## May 6th 2024
8+
9+
Modified branch protection for main branch to require the following CI checks as
10+
we now added Windows to CI.
11+
test (ubuntu-latest, stable)
12+
test (stable, windows-latest)
13+
14+
## April 30th 2024
15+
16+
Modified branch protection for main branch to require the following CI checks:
17+
docs
18+
test (stable)

.github/workflows/ci.yml

+19-8
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ jobs:
1212
test:
1313
strategy:
1414
matrix:
15+
# test both stable and beta versions of Rust on ubuntu-latest
16+
os: [ubuntu-latest]
1517
rust: [stable, beta]
16-
runs-on: ubuntu-latest
18+
# test only stable version of Rust on Windows
19+
include:
20+
- rust: stable
21+
os: windows-latest
22+
runs-on: ${{ matrix.os }}
1723
steps:
1824
- name: Free disk space
25+
if: ${{ matrix.os == 'ubuntu-latest'}}
1926
run: |
2027
df -h
2128
sudo rm -rf /usr/local/lib/android
@@ -32,7 +39,7 @@ jobs:
3239
run: rustup set profile minimal
3340
- uses: arduino/setup-protoc@v3
3441
- name: Test
35-
run: ./scripts/test.sh
42+
run: bash ./scripts/test.sh
3643
lint:
3744
runs-on: ubuntu-latest
3845
steps:
@@ -48,12 +55,12 @@ jobs:
4855
command: fmt
4956
args: --all -- --check
5057
- name: Lint
51-
run: ./scripts/lint.sh
58+
run: bash ./scripts/lint.sh
5259
external-types:
5360
strategy:
5461
matrix:
5562
example: [opentelemetry, opentelemetry-sdk, opentelemetry-otlp, opentelemetry-zipkin]
56-
runs-on: ubuntu-latest
63+
runs-on: ubuntu-latest # TODO: Check if this could be covered for Windows. The step used currently fails on Windows.
5764
steps:
5865
- uses: actions/checkout@v4
5966
- uses: dtolnay/rust-toolchain@nightly
@@ -68,8 +75,9 @@ jobs:
6875
non-default-examples:
6976
strategy:
7077
matrix:
78+
os: [ windows-latest, ubuntu-latest ]
7179
example: [opentelemetry-otlp/examples/basic-otlp]
72-
runs-on: ubuntu-latest
80+
runs-on: ${{ matrix.os }}
7381
steps:
7482
- uses: actions/checkout@v4
7583
with:
@@ -83,21 +91,24 @@ jobs:
8391
cd ${{ matrix.example }}
8492
cargo build --verbose
8593
msrv:
86-
runs-on: ubuntu-latest
94+
strategy:
95+
matrix:
96+
os: [ windows-latest, ubuntu-latest ]
97+
runs-on: ${{ matrix.os }}
8798
steps:
8899
- uses: actions/checkout@v4
89100
with:
90101
submodules: true
91102
- uses: dtolnay/rust-toolchain@1.65.0
92103
- name: Patch dependencies versions # some dependencies bump MSRV without major version bump
93-
run: ./scripts/patch_dependencies.sh
104+
run: bash ./scripts/patch_dependencies.sh
94105
- name: Run tests
95106
run: cargo --version &&
96107
cargo check --lib --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,testing &&
97108
cargo check --lib --manifest-path=opentelemetry-jaeger/Cargo.toml --features rt-tokio &&
98109
cargo check --lib --manifest-path=opentelemetry-zipkin/Cargo.toml
99110
cargo-deny:
100-
runs-on: ubuntu-latest
111+
runs-on: ubuntu-latest # This uses the step `EmbarkStudios/cargo-deny-action@v1` which is only supported on Linux
101112
continue-on-error: true # Prevent sudden announcement of a new advisory from failing ci
102113
steps:
103114
- uses: actions/checkout@v4

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ futures-util = { version = "0.3", default-features = false }
2727
hyper = { version = "0.14", default-features = false }
2828
http = { version = "0.2", default-features = false }
2929
isahc = { version = "1.4", default-features = false }
30-
log = "0.4"
30+
log = "0.4.21"
3131
once_cell = "1.13"
3232
ordered-float = "4.0"
3333
pin-project-lite = "0.2"

README.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@ observability tools.
2525

2626
## Project Status
2727

28-
| Signal | Status |
29-
| ------- | ---------- |
30-
| Logs | Alpha* |
31-
| Metrics | Alpha |
32-
| Traces | Beta |
28+
| Signal/Component | Overall Status |
29+
| -------------------- | ------------------ |
30+
| Logs-API | Alpha* |
31+
| Logs-SDK | Alpha |
32+
| Logs-OTLP Exporter | Alpha |
33+
| Logs-Appender-Tracing | Alpha |
34+
| Metrics-API | Alpha |
35+
| Metrics-SDK | Alpha |
36+
| Metrics-OTLP Exporter | Alpha |
37+
| Traces-API | Beta |
38+
| Traces-SDK | Beta |
39+
| Traces-OTLP Exporter | Beta |
3340

3441
*OpenTelemetry Rust is not introducing a new end user callable Logging API.
3542
Instead, it provides [Logs Bridge

RELEASING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A draft PR can be created, but before releasing consider the following:
1616

1717
* Are there any pending pull requests which should be included in the next release?
1818
* Are they blockers?
19-
* Are there any unresolved issues which should be resolved before the next release?
19+
* Are there any unresolved issues which should be resolved before the next release? Check the release [blockers milestone](https://github.com/open-telemetry/opentelemetry-rust/milestones) for every release
2020
* Bring it up at a SIG meeting, this can usually get some of these questions answered sooner than later. It will also
2121
help establish a person to perform the release. Ideally this can be someone different each time to ensure that the
2222
process is documented.

examples/metrics-basic/src/main.rs

+43-54
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,21 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
4343
);
4444

4545
// Create a ObservableCounter instrument and register a callback that reports the measurement.
46-
let observable_counter = meter
46+
let _observable_counter = meter
4747
.u64_observable_counter("my_observable_counter")
4848
.with_description("My observable counter example description")
4949
.with_unit(Unit::new("myunit"))
50+
.with_callback(|observer| {
51+
observer.observe(
52+
100,
53+
&[
54+
KeyValue::new("mykey1", "myvalue1"),
55+
KeyValue::new("mykey2", "myvalue2"),
56+
],
57+
)
58+
})
5059
.init();
5160

52-
meter.register_callback(&[observable_counter.as_any()], move |observer| {
53-
observer.observe_u64(
54-
&observable_counter,
55-
100,
56-
&[
57-
KeyValue::new("mykey1", "myvalue1"),
58-
KeyValue::new("mykey2", "myvalue2"),
59-
],
60-
)
61-
})?;
62-
6361
// Create a UpCounter Instrument.
6462
let updown_counter = meter.i64_up_down_counter("my_updown_counter").init();
6563

@@ -73,23 +71,21 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
7371
);
7472

7573
// Create a Observable UpDownCounter instrument and register a callback that reports the measurement.
76-
let observable_up_down_counter = meter
74+
let _observable_up_down_counter = meter
7775
.i64_observable_up_down_counter("my_observable_updown_counter")
7876
.with_description("My observable updown counter example description")
7977
.with_unit(Unit::new("myunit"))
78+
.with_callback(|observer| {
79+
observer.observe(
80+
100,
81+
&[
82+
KeyValue::new("mykey1", "myvalue1"),
83+
KeyValue::new("mykey2", "myvalue2"),
84+
],
85+
)
86+
})
8087
.init();
8188

82-
meter.register_callback(&[observable_up_down_counter.as_any()], move |observer| {
83-
observer.observe_i64(
84-
&observable_up_down_counter,
85-
100,
86-
&[
87-
KeyValue::new("mykey1", "myvalue1"),
88-
KeyValue::new("mykey2", "myvalue2"),
89-
],
90-
)
91-
})?;
92-
9389
// Create a Histogram Instrument.
9490
let histogram = meter
9591
.f64_histogram("my_histogram")
@@ -108,43 +104,36 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
108104
// Note that there is no ObservableHistogram instrument.
109105

110106
// Create a Gauge Instrument.
111-
// Note that the Gauge instrument is experimental, and can be changed/removed in the future releases.
112-
#[cfg(feature = "otel_unstable")]
113-
{
114-
let gauge = meter
115-
.f64_gauge("my_gauge")
116-
.with_description("A gauge set to 1.0")
117-
.with_unit(Unit::new("myunit"))
118-
.init();
119-
120-
gauge.record(
121-
1.0,
122-
&[
123-
KeyValue::new("mykey1", "myvalue1"),
124-
KeyValue::new("mykey2", "myvalue2"),
125-
],
126-
);
127-
}
107+
let gauge = meter
108+
.f64_gauge("my_gauge")
109+
.with_description("A gauge set to 1.0")
110+
.with_unit(Unit::new("myunit"))
111+
.init();
112+
113+
gauge.record(
114+
1.0,
115+
&[
116+
KeyValue::new("mykey1", "myvalue1"),
117+
KeyValue::new("mykey2", "myvalue2"),
118+
],
119+
);
128120

129121
// Create a ObservableGauge instrument and register a callback that reports the measurement.
130-
let observable_gauge = meter
122+
let _observable_gauge = meter
131123
.f64_observable_gauge("my_observable_gauge")
132124
.with_description("An observable gauge set to 1.0")
133125
.with_unit(Unit::new("myunit"))
126+
.with_callback(|observer| {
127+
observer.observe(
128+
1.0,
129+
&[
130+
KeyValue::new("mykey1", "myvalue1"),
131+
KeyValue::new("mykey2", "myvalue2"),
132+
],
133+
)
134+
})
134135
.init();
135136

136-
// Register a callback that reports the measurement.
137-
meter.register_callback(&[observable_gauge.as_any()], move |observer| {
138-
observer.observe_f64(
139-
&observable_gauge,
140-
1.0,
141-
&[
142-
KeyValue::new("mykey1", "myvalue1"),
143-
KeyValue::new("mykey2", "myvalue2"),
144-
],
145-
)
146-
})?;
147-
148137
// Metrics are exported by default every 30 seconds when using stdout exporter,
149138
// however shutting down the MeterProvider here instantly flushes
150139
// the metrics, instead of waiting for the 30 sec interval.

opentelemetry-appender-log/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## vNext
44

5+
- Add log key-values as attributes [#1628](https://github.com/open-telemetry/opentelemetry-rust/pull/1628)
6+
57
## v0.3.0
68

79
## v0.2.0

opentelemetry-appender-log/Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ edition = "2021"
1212

1313
[dependencies]
1414
opentelemetry = { version = "0.22", path = "../opentelemetry", features = ["logs"]}
15-
log = { workspace = true, features = ["kv_unstable", "std"]}
15+
log = { workspace = true, features = ["kv", "std"]}
16+
serde = { workspace = true, optional = true, features = ["std"] }
1617

1718
[features]
1819
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
20+
with-serde = ["log/kv_serde", "serde"]
1921
default = ["logs_level_enabled"]
2022

2123
[dev-dependencies]
2224
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = [ "testing", "logs_level_enabled" ] }
25+
opentelemetry-stdout = { path = "../opentelemetry-stdout", features = ["logs"]}
26+
log = { workspace = true, features = ["kv_serde"] }
2327
tokio = { workspace = true }
28+
serde = { workspace = true, features = ["std", "derive"] }
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! run with `$ cargo run --example logs-basic-in-memory
1+
//! run with `$ cargo run --example logs-basic`
22
33
/// This example shows how to use in_memory_exporter for logs. This uses opentelemetry-appender-log crate, which is a
44
/// [logging appender](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#log-appender--bridge) that bridges logs from the [log crate](https://docs.rs/log/latest/log/) to OpenTelemetry.
@@ -8,15 +8,15 @@ use log::{error, info, warn, Level};
88
use opentelemetry_appender_log::OpenTelemetryLogBridge;
99
use opentelemetry_sdk::logs::{BatchLogProcessor, LoggerProvider};
1010
use opentelemetry_sdk::runtime;
11-
use opentelemetry_sdk::testing::logs::InMemoryLogsExporter;
11+
use opentelemetry_stdout::LogExporter;
1212

1313
#[tokio::main]
1414
async fn main() {
15-
//Create an InMemoryLogsExporter
16-
let exporter: InMemoryLogsExporter = InMemoryLogsExporter::default();
15+
//Create an exporter that writes to stdout
16+
let exporter = LogExporter::default();
1717
//Create a LoggerProvider and register the exporter
1818
let logger_provider = LoggerProvider::builder()
19-
.with_log_processor(BatchLogProcessor::builder(exporter.clone(), runtime::Tokio).build())
19+
.with_log_processor(BatchLogProcessor::builder(exporter, runtime::Tokio).build())
2020
.build();
2121

2222
// Setup Log Appender for the log crate.
@@ -25,14 +25,12 @@ async fn main() {
2525
log::set_max_level(Level::Info.to_level_filter());
2626

2727
// Emit logs using macros from the log crate.
28-
error!("hello from {}. My price is {}", "apple", 2.99);
28+
let fruit = "apple";
29+
let price = 2.99;
30+
31+
error!(fruit, price; "hello from {fruit}. My price is {price}");
2932
warn!("warn!");
3033
info!("test log!");
3134

3235
logger_provider.force_flush();
33-
34-
let emitted_logs = exporter.get_emitted_logs().unwrap();
35-
for log in emitted_logs {
36-
println!("{:?}", log);
37-
}
3836
}

0 commit comments

Comments
 (0)