Skip to content

Commit bfd2873

Browse files
committed
Merge main to switch_batch_log_to_background_thread
2 parents 082972d + e8a2878 commit bfd2873

File tree

224 files changed

+9253
-6202
lines changed

Some content is hidden

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

224 files changed

+9253
-6202
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
- main
99
paths-ignore:
1010
- '**.md'
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
1114
jobs:
1215
test:
1316
strategy:
@@ -22,8 +25,9 @@ jobs:
2225
- rust: stable
2326
os: macos-latest
2427
- rust: stable
25-
os: actuated-arm64-4cpu-16gb
28+
os: otel-linux-arm64
2629
runs-on: ${{ matrix.os }}
30+
continue-on-error: ${{ matrix.rust == 'beta' }}
2731
steps:
2832
- name: Free disk space
2933
if: ${{ matrix.os == 'ubuntu-latest'}}
@@ -73,33 +77,13 @@ jobs:
7377
- uses: actions/checkout@v4
7478
- uses: dtolnay/rust-toolchain@nightly
7579
with:
76-
toolchain: nightly-2024-05-01
80+
toolchain: nightly-2024-06-30
7781
components: rustfmt
7882
- name: external-type-check
7983
run: |
80-
cargo install cargo-check-external-types
84+
cargo install cargo-check-external-types@0.1.13
8185
cd ${{ matrix.example }}
8286
cargo check-external-types --config allowed-external-types.toml
83-
non-default-examples:
84-
strategy:
85-
matrix:
86-
os: [ windows-latest, ubuntu-latest ]
87-
example: [opentelemetry-otlp/examples/basic-otlp]
88-
runs-on: ${{ matrix.os }}
89-
steps:
90-
- uses: actions/checkout@v4
91-
with:
92-
submodules: true
93-
- uses: dtolnay/rust-toolchain@stable
94-
with:
95-
components: rustfmt
96-
- uses: arduino/setup-protoc@v3
97-
with:
98-
repo-token: ${{ secrets.GITHUB_TOKEN }}
99-
- name: Build
100-
run: |
101-
cd ${{ matrix.example }}
102-
cargo build --verbose
10387
msrv:
10488
strategy:
10589
matrix:
@@ -132,7 +116,7 @@ jobs:
132116
runs-on: ubuntu-latest
133117
steps:
134118
- uses: actions/checkout@v4
135-
- uses: dtolnay/rust-toolchain@nightly
119+
- uses: dtolnay/rust-toolchain@stable
136120
with:
137121
components: rustfmt
138122
- uses: arduino/setup-protoc@v3

.github/workflows/semver.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ env:
44
on:
55
pull_request:
66
types: [ labeled, synchronize, opened, reopened ]
7-
87
jobs:
98
semver-compliance: # This job uses the latest published crate as baseline for comparison.
109
runs-on: ubuntu-latest

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ For a deeper discussion, see:
140140

141141
Currently, the Opentelemetry Rust SDK has two ways to handle errors. In the situation where errors are not allowed to return. One should call global error handler to process the errors. Otherwise, one should return the errors.
142142

143-
The Opentelemetry Rust SDK comes with an error type `opentelemetry::Error`. For different function, one error has been defined. All error returned by trace module MUST be wrapped in `opentelemetry::trace::TraceError`. All errors returned by metrics module MUST be wrapped in `opentelemetry::metrics::MetricsError`. All errors returned by logs module MUST be wrapped in `opentelemetry::logs::LogsError`.
143+
The Opentelemetry Rust SDK comes with an error type `opentelemetry::Error`. For different function, one error has been defined. All error returned by trace module MUST be wrapped in `opentelemetry::trace::TraceError`. All errors returned by metrics module MUST be wrapped in `opentelemetry::metrics::MetricError`. All errors returned by logs module MUST be wrapped in `opentelemetry::logs::LogsError`.
144144

145145
For users that want to implement their own exporters. It's RECOMMENDED to wrap all errors from the exporter into a crate-level error type, and implement `ExporterError` trait.
146146

@@ -169,7 +169,7 @@ It's important to regularly review and remove the `otel_unstable` flag from the
169169
The potential features include:
170170

171171
- Stable and non-experimental features that compliant to specification, and have a feature flag to minimize compilation size. Example: feature flags for signals (like `logs`, `traces`, `metrics`) and runtimes (`rt-tokio`, `rt-tokio-current-thread`, `rt-async-std`).
172-
- Stable and non-experimental features, although not part of the specification, are crucial for enhancing the tracing/log crate's functionality or boosting performance. These features are also subject to discussion and approval by the OpenTelemetry Rust Maintainers. An example of such a feature is `logs_level_enabled`.
172+
- Stable and non-experimental features, although not part of the specification, are crucial for enhancing the tracing/log crate's functionality or boosting performance. These features are also subject to discussion and approval by the OpenTelemetry Rust Maintainers.
173173

174174
All such features should adhere to naming convention `<signal>_<feature_name>`
175175

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ reqwest = { version = "0.12", default-features = false }
3939
serde = { version = "1.0", default-features = false }
4040
serde_json = "1.0"
4141
temp-env = "0.3.6"
42-
thiserror = { version = "1", default-features = false }
42+
thiserror = { version = "2", default-features = false }
4343
tonic = { version = "0.12.3", default-features = false }
4444
tonic-build = "0.12"
4545
tokio = { version = "1", default-features = false }
4646
tokio-stream = "0.1"
4747
tracing = { version = "0.1", default-features = false }
4848
tracing-core = { version = "0.1", default-features = false }
4949
tracing-subscriber = { version = "0.3", default-features = false }
50-
url = { version = "2.5", default-features = false }
50+
url = { version = "2.5.2", default-features = false } #https://github.com/servo/rust-url/issues/992

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,33 @@ analysis in order to understand your software's performance and behavior. You
1717
can export and analyze them using [Prometheus], [Jaeger], and other
1818
observability tools.
1919

20-
*Compiler support: [requires `rustc` 1.70+][msrv]*
20+
*[Supported Rust Versions](#supported-rust-versions)*
2121

2222
[Prometheus]: https://prometheus.io
2323
[Jaeger]: https://www.jaegertracing.io
24-
[msrv]: #supported-rust-versions
2524

2625
## Project Status
2726

27+
The table below summarizes the overall status of each component. Some components
28+
include unstable features, which are documented in their respective crate
29+
documentation.
30+
2831
| Signal/Component | Overall Status |
2932
| -------------------- | ------------------ |
30-
| Logs-API | Beta* |
33+
| Logs-API | RC* |
3134
| Logs-SDK | Beta |
3235
| Logs-OTLP Exporter | Beta |
3336
| Logs-Appender-Tracing | Beta |
34-
| Metrics-API | Beta |
35-
| Metrics-SDK | Alpha |
36-
| Metrics-OTLP Exporter | Alpha |
37+
| Metrics-API | RC |
38+
| Metrics-SDK | Beta |
39+
| Metrics-OTLP Exporter | Beta |
3740
| Traces-API | Beta |
3841
| Traces-SDK | Beta |
3942
| Traces-OTLP Exporter | Beta |
4043

4144
*OpenTelemetry Rust is not introducing a new end user callable Logging API.
4245
Instead, it provides [Logs Bridge
43-
API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md),
46+
API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/api.md),
4447
that allows one to write log appenders that can bridge existing logging
4548
libraries to the OpenTelemetry log data model. The following log appenders are
4649
available:
@@ -80,7 +83,7 @@ fn main() {
8083
});
8184

8285
// Shutdown trace pipeline
83-
global::shutdown_tracer_provider();
86+
provider.shutdown().expect("TracerProvider should shutdown successfully")
8487
}
8588
```
8689

@@ -198,12 +201,12 @@ you're more than welcome to participate!
198201
* [Harold Dost](https://github.com/hdost)
199202
* [Julian Tescher](https://github.com/jtescher)
200203
* [Lalit Kumar Bhasin](https://github.com/lalitb)
204+
* [Utkarsh Umesan Pillai](https://github.com/utpilla)
201205
* [Zhongyang Wu](https://github.com/TommyCpp)
202206

203207
### Approvers
204208

205209
* [Shaun Cox](https://github.com/shaun-cox)
206-
* [Utkarsh Umesan Pillai](https://github.com/utpilla)
207210

208211
### Emeritus
209212

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory contains some examples that should help you get start crates from
77
This example uses following crates from this repo:
88

99
- opentelemetry(log)
10-
- opentelemetry-appender-log
10+
- opentelemetry-appender-tracing
1111
- opentelemetry-stdout
1212

1313
Check this example if you want to understand *how to instrument logs using opentelemetry*.

examples/logs-basic/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish = false
99
opentelemetry = { path = "../../opentelemetry", features = ["logs"] }
1010
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["logs"] }
1111
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["logs"]}
12-
opentelemetry-appender-log = { path = "../../opentelemetry-appender-log", default-features = false}
12+
opentelemetry-appender-tracing = { path = "../../opentelemetry-appender-tracing", default-features = false}
1313
opentelemetry-semantic-conventions = { path = "../../opentelemetry-semantic-conventions" }
14-
log = { workspace = true }
15-
serde_json = { workspace = true }
14+
tracing = { workspace = true, features = ["std"]}
15+
tracing-subscriber = { workspace = true, features = ["registry", "std"] }

examples/logs-basic/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# OpenTelemetry Log Appender for log - Example
1+
# OpenTelemetry Log Appender for tracing - Example
22

3-
This example shows how to use the opentelemetry-appender-log crate, which is a
3+
This example shows how to use the opentelemetry-appender-tracing crate, which is a
44
[logging
55
appender](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#log-appender--bridge)
6-
that bridges logs from the [log crate](https://docs.rs/log/latest/log/) to
6+
that bridges logs from the [tracing crate](https://tracing.rs/tracing/#events) to
77
OpenTelemetry. The example setups a LoggerProvider with stdout exporter, so logs
88
are emitted to stdout.
99

1010
## Usage
1111

12-
Run the following, and Logs emitted using [log](https://docs.rs/log/latest/log/)
12+
Run the following, and Logs emitted using [tracing](https://docs.rs/tracing/latest/tracing/)
1313
will be written out to stdout.
1414

1515
```shell

examples/logs-basic/src/main.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
use log::{error, Level};
21
use opentelemetry::KeyValue;
3-
use opentelemetry_appender_log::OpenTelemetryLogBridge;
2+
use opentelemetry_appender_tracing::layer;
43
use opentelemetry_sdk::logs::LoggerProvider;
54
use opentelemetry_sdk::Resource;
6-
use opentelemetry_semantic_conventions::resource::SERVICE_NAME;
5+
use tracing::error;
6+
use tracing_subscriber::prelude::*;
77

88
fn main() {
9-
// Setup LoggerProvider with a stdout exporter
109
let exporter = opentelemetry_stdout::LogExporter::default();
11-
let logger_provider = LoggerProvider::builder()
12-
.with_resource(Resource::new([KeyValue::new(
13-
SERVICE_NAME,
14-
"logs-basic-example",
10+
let provider: LoggerProvider = LoggerProvider::builder()
11+
.with_resource(Resource::new(vec![KeyValue::new(
12+
"service.name",
13+
"log-appender-tracing-example",
1514
)]))
1615
.with_simple_exporter(exporter)
1716
.build();
17+
let layer = layer::OpenTelemetryTracingBridge::new(&provider);
18+
tracing_subscriber::registry().with(layer).init();
1819

19-
// Setup Log Appender for the log crate.
20-
let otel_log_appender = OpenTelemetryLogBridge::new(&logger_provider);
21-
log::set_boxed_logger(Box::new(otel_log_appender)).unwrap();
22-
log::set_max_level(Level::Error.to_level_filter());
23-
24-
// Emit logs using macros from the log crate.
25-
// These logs gets piped through OpenTelemetry bridge and gets exported to stdout.
26-
error!(target: "my-target", "hello from {}. My price is {}", "apple", 2.99);
20+
error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "[email protected]", message = "This is an example message");
21+
let _ = provider.shutdown();
2722
}

examples/metrics-advanced/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77

88
[dependencies]
99
opentelemetry = { path = "../../opentelemetry", features = ["metrics"] }
10-
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["metrics", "rt-tokio"] }
10+
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["spec_unstable_metrics_views", "rt-tokio"] }
1111
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["metrics"] }
1212
tokio = { workspace = true, features = ["full"] }
1313
serde_json = { workspace = true }

0 commit comments

Comments
 (0)