Skip to content

Commit

Permalink
Merge branch 'main' into log-attributes-update
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Dec 19, 2024
2 parents ffeb1ec + acf16ed commit c8fdd05
Show file tree
Hide file tree
Showing 279 changed files with 19,074 additions and 9,698 deletions.
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"nocapture",
"Ochtman",
"opentelemetry",
"OTELCOL",
"OTLP",
"periodicreader",
"protoc",
"quantile",
"Redelmeier",
Expand All @@ -59,6 +61,7 @@
"shoppingcart",
"struct",
"Tescher",
"testresults",
"tracerprovider",
"updown",
"Zhongyang",
Expand Down
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/BUG-REPORT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ body:
- type: textarea
id: api-version
attributes:
label: API Version
label: OpenTelemetry API Version (i.e version of `opentelemetry` crate)
description: What version of the `opentelemetry` crate are you using?
placeholder: 0.x, 1.x, etc.
validations:
required: true
- type: textarea
id: sdk-version
attributes:
label: SDK Version
label: label: OpenTelemetry SDK Version (i.e version of `opentelemetry_sdk` crate)
description: What version of the `opentelemetry_sdk` crate are you using?
placeholder: 0.x, 1.x, etc.
validations:
Expand All @@ -39,6 +39,7 @@ body:
label: What Exporter(s) are you seeing the problem on?
multiple: true
options:
- stdout
- OTLP
- Zipkin
- Prometheus
Expand Down
37 changes: 11 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- main
paths-ignore:
- '**.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
Expand All @@ -22,8 +25,9 @@ jobs:
- rust: stable
os: macos-latest
- rust: stable
os: actuated-arm64-4cpu-16gb
os: otel-linux-arm64
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.rust == 'beta' }}
steps:
- name: Free disk space
if: ${{ matrix.os == 'ubuntu-latest'}}
Expand Down Expand Up @@ -73,39 +77,20 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2024-05-01
toolchain: nightly-2024-06-30
components: rustfmt
- name: external-type-check
run: |
cargo install cargo-check-external-types
cargo install cargo-check-external-types@0.1.13
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:
os: [windows-latest, ubuntu-latest]
rust: [1.65.0, 1.70.0]
rust: [1.75.0]
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -131,7 +116,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 Expand Up @@ -163,7 +148,7 @@ jobs:
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo llvm-cov
run: cargo llvm-cov --locked --all-features --workspace --lcov --output-path lcov.info
run: cargo llvm-cov --locked --all-features --workspace --lcov --lib --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
with:
components: rustfmt
- uses: arduino/setup-protoc@v3
- name: Run integration tests using docker compose
- name: Run integration tests
run: ./scripts/integration_tests.sh
1 change: 0 additions & 1 deletion .github/workflows/semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ env:
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
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
Cargo.lock
/.idea/

.cosine
.cosine

opentelemetry-otlp/tests/integration_test/result.json
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ For a deeper discussion, see:

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.

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`.
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`.

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.

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

- 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`).
- 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`.
- 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.

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

Expand Down
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ reqwest = { version = "0.12", default-features = false }
serde = { version = "1.0", default-features = false }
serde_json = "1.0"
temp-env = "0.3.6"
thiserror = { version = "1", default-features = false }
tonic = { version = "0.12", default-features = false }
thiserror = { version = "2", default-features = false }
tonic = { version = "0.12.3", default-features = false }
tonic-build = "0.12"
tokio = { version = "1", default-features = false }
tokio-stream = "0.1.1"
tracing = { version = "0.1", default-features = false }
tracing-core = { version = "0.1", default-features = false }
tokio-stream = "0.1"
# Using `tracing 0.1.40` because 0.1.39 (which is yanked) introduces the ability to set event names in macros,
# required for OpenTelemetry's internal logging macros.
tracing = { version = ">=0.1.40", default-features = false }
# `tracing-core >=0.1.33` is required for compatibility with `tracing >=0.1.40`.
tracing-core = { version = ">=0.1.33", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false }
url = { version = "2.5", default-features = false }
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,33 @@ analysis in order to understand your software's performance and behavior. You
can export and analyze them using [Prometheus], [Jaeger], and other
observability tools.

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

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

## Project Status

The table below summarizes the overall status of each component. Some components
include unstable features, which are documented in their respective crate
documentation.

| Signal/Component | Overall Status |
| -------------------- | ------------------ |
| Logs-API | Beta* |
| Logs-API | RC* |
| Logs-SDK | Beta |
| Logs-OTLP Exporter | Beta |
| Logs-Appender-Tracing | Beta |
| Metrics-API | Alpha |
| Metrics-SDK | Alpha |
| Metrics-OTLP Exporter | Alpha |
| Metrics-API | RC |
| Metrics-SDK | Beta |
| Metrics-OTLP Exporter | Beta |
| Traces-API | Beta |
| Traces-SDK | Beta |
| Traces-OTLP Exporter | Beta |

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

// Shutdown trace pipeline
global::shutdown_tracer_provider();
provider.shutdown().expect("TracerProvider should shutdown successfully")
}
```

Expand Down Expand Up @@ -159,7 +162,7 @@ Registry](https://opentelemetry.io/ecosystem/registry/?language=rust).
## Supported Rust Versions

OpenTelemetry is built against the latest stable release. The minimum supported
version is 1.65. The current OpenTelemetry version is not guaranteed to build
version is 1.75. The current OpenTelemetry version is not guaranteed to build
on Rust versions earlier than the minimum supported version.

The current stable Rust compiler and the three most recent minor versions
Expand Down Expand Up @@ -198,12 +201,12 @@ you're more than welcome to participate!
* [Harold Dost](https://github.com/hdost)
* [Julian Tescher](https://github.com/jtescher)
* [Lalit Kumar Bhasin](https://github.com/lalitb)
* [Utkarsh Umesan Pillai](https://github.com/utpilla)
* [Zhongyang Wu](https://github.com/TommyCpp)

### Approvers

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

### Emeritus

Expand Down
5 changes: 0 additions & 5 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,5 @@ license-files = [
]

[advisories]
ignore = [
# unsoundness in indirect dependencies without a safe upgrade below
"RUSTSEC-2021-0145",
"RUSTSEC-2019-0036"
]
unmaintained = "allow"
yanked = "allow"
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This directory contains some examples that should help you get start crates from
This example uses following crates from this repo:

- opentelemetry(log)
- opentelemetry-appender-log
- opentelemetry-appender-tracing
- opentelemetry-stdout

Check this example if you want to understand *how to instrument logs using opentelemetry*.
Expand Down
8 changes: 3 additions & 5 deletions examples/logs-basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ license = "Apache-2.0"
publish = false

[dependencies]
opentelemetry = { path = "../../opentelemetry", features = ["logs"] }
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["logs"] }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["logs"]}
opentelemetry-appender-log = { path = "../../opentelemetry-appender-log", default-features = false}
opentelemetry-semantic-conventions = { path = "../../opentelemetry-semantic-conventions" }
log = { workspace = true }
serde_json = { workspace = true }
opentelemetry-appender-tracing = { path = "../../opentelemetry-appender-tracing", default-features = false}
tracing = { workspace = true, features = ["std"]}
tracing-subscriber = { workspace = true, features = ["registry", "std"] }
8 changes: 4 additions & 4 deletions examples/logs-basic/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# OpenTelemetry Log Appender for log - Example
# OpenTelemetry Log Appender for tracing - Example

This example shows how to use the opentelemetry-appender-log crate, which is a
This example shows how to use the opentelemetry-appender-tracing crate, which is a
[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
that bridges logs from the [tracing crate](https://tracing.rs/tracing/#events) to
OpenTelemetry. The example setups a LoggerProvider with stdout exporter, so logs
are emitted to stdout.

## Usage

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

```shell
Expand Down
31 changes: 13 additions & 18 deletions examples/logs-basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
use log::{error, Level};
use opentelemetry::KeyValue;
use opentelemetry_appender_log::OpenTelemetryLogBridge;
use opentelemetry_appender_tracing::layer;
use opentelemetry_sdk::logs::LoggerProvider;
use opentelemetry_sdk::Resource;
use opentelemetry_semantic_conventions::resource::SERVICE_NAME;
use tracing::error;
use tracing_subscriber::prelude::*;

fn main() {
// Setup LoggerProvider with a stdout exporter
let exporter = opentelemetry_stdout::LogExporter::default();
let logger_provider = LoggerProvider::builder()
.with_resource(Resource::new([KeyValue::new(
SERVICE_NAME,
"logs-basic-example",
)]))
let provider: LoggerProvider = LoggerProvider::builder()
.with_resource(
Resource::builder()
.with_service_name("log-appender-tracing-example")
.build(),
)
.with_simple_exporter(exporter)
.build();
let layer = layer::OpenTelemetryTracingBridge::new(&provider);
tracing_subscriber::registry().with(layer).init();

// Setup Log Appender for the log crate.
let otel_log_appender = OpenTelemetryLogBridge::new(&logger_provider);
log::set_boxed_logger(Box::new(otel_log_appender)).unwrap();
log::set_max_level(Level::Error.to_level_filter());

// Emit logs using macros from the log crate.
// These logs gets piped through OpenTelemetry bridge and gets exported to stdout.
error!(target: "my-target", "hello from {}. My price is {}", "apple", 2.99);
error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "[email protected]", message = "This is an example message");
let _ = provider.shutdown();
}
5 changes: 2 additions & 3 deletions examples/metrics-advanced/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ publish = false

[dependencies]
opentelemetry = { path = "../../opentelemetry", features = ["metrics"] }
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["metrics", "rt-tokio"] }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["metrics"]}
opentelemetry_sdk = { path = "../../opentelemetry-sdk", features = ["spec_unstable_metrics_views", "rt-tokio"] }
opentelemetry-stdout = { path = "../../opentelemetry-stdout", features = ["metrics"] }
tokio = { workspace = true, features = ["full"] }
serde_json = { workspace = true }
Loading

0 comments on commit c8fdd05

Please sign in to comment.