Skip to content

Commit 6c13684

Browse files
authored
Merge branch 'main' into main
2 parents c9de4b8 + bc5e6ce commit 6c13684

File tree

93 files changed

+984
-665
lines changed

Some content is hidden

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

93 files changed

+984
-665
lines changed

.github/workflows/fossa.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: FOSSA scanning
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
fossa:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
17+
- uses: fossas/fossa-action@93a52ecf7c3ac7eb40f5de77fd69b1a19524de94 # v1.5.0
18+
with:
19+
api-key: ${{secrets.FOSSA_API_KEY}}
20+
team: OpenTelemetry

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pin-project-lite = "0.2"
3636
prost = "0.13"
3737
prost-build = "0.13"
3838
prost-types = "0.13"
39-
rand = { version = "0.8", default-features = false }
39+
rand = { version = "0.9", default-features = false }
4040
reqwest = { version = "0.12", default-features = false }
4141
serde = { version = "1.0", default-features = false }
4242
serde_json = "1.0"
@@ -59,3 +59,6 @@ url = { version = "2.5", default-features = false }
5959
opentelemetry = { path = "opentelemetry" }
6060
opentelemetry_sdk = { path = "opentelemetry-sdk" }
6161
opentelemetry-stdout = { path = "opentelemetry-stdout" }
62+
63+
[workspace.lints.clippy]
64+
all = { level = "warn", priority = 1 }

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ you're more than welcome to participate!
186186
### Approvers
187187

188188
* [Shaun Cox](https://github.com/shaun-cox)
189+
* [Scott Gerring](https://github.com/scottgerring)
189190

190191
### Emeritus
191192

docs/design/logs.md

+33
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,22 @@ this crate.
280280
## Performance
281281

282282
// Call out things done specifically for performance
283+
// Rough draft
284+
285+
1. `LogRecord` is stack allocated and not Boxed unless required by the component
286+
needing to store it beyond the logging call. (eg: BatchProcessor)
287+
2. LogRecords's Attribute storage is specially designed struct, that holds up to
288+
five attributes in stack.
289+
3. When passing `LogRecord`s to processor, a mutable ref is passed. This allows
290+
calling multiple processors one after another, without the need for cloning.
291+
4. `Logger` provides a `Enabled` check which can optimize performance when
292+
no-one is interested in the log. The check is passed from `Logger` to the
293+
processor, which may consult its exporter to make the decision. An example use
294+
case - an ETW or user-events exporter can check for the presence of listener and
295+
convey that decision back to logger, allowing appender to avoid even the cost of
296+
creating a `LogRecord` in the first place if there is no listener. This check is
297+
done for each log emission, and can react dynamically to changes in interest, by
298+
enabling/disabling ETW/user-event listener.
283299

284300
### Perf test - benchmarks
285301

@@ -289,6 +305,23 @@ this crate.
289305

290306
// Share ~~ numbers
291307

308+
## Internal logs
309+
310+
OTel itself is instrumented with `tracing` crate to emit internal logs about its
311+
operations. This is feature gated under "internal-logs", and is enabled by
312+
default for all components. The `opentelemetry` provide few helper macros
313+
`otel_warn` etc., which in turn invokes various `tracing` macros like `warn!`
314+
etc. The cargo package name will be set as `target` when using `tracing`. For
315+
example, logs from `opentelemetry-otlp` will have target set to
316+
"opentelemetry-otlp".
317+
318+
The helper macros are part of public API, so can be used by anyone. But it is
319+
only meant for OTel components itself and anyone writing extensions like custom
320+
Exporters etc.
321+
322+
// TODO: Document the principles followed when selecting severity for internal
323+
logs // TODO: Document how this can cause circular loop and plans to address it.
324+
292325
## Summary
293326

294327
- OpenTelemetry Logs does not provide a user-facing logging API.

examples/metrics-advanced/src/main.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use opentelemetry::global;
22
use opentelemetry::Key;
33
use opentelemetry::KeyValue;
4-
use opentelemetry_sdk::metrics::{
5-
Aggregation, Instrument, PeriodicReader, SdkMeterProvider, Stream, Temporality,
6-
};
4+
use opentelemetry_sdk::metrics::{Aggregation, Instrument, SdkMeterProvider, Stream, Temporality};
75
use opentelemetry_sdk::Resource;
86
use std::error::Error;
97

examples/metrics-basic/src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use opentelemetry::{global, KeyValue};
2-
use opentelemetry_sdk::error::OTelSdkError;
3-
use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider};
2+
use opentelemetry_sdk::metrics::SdkMeterProvider;
43
use opentelemetry_sdk::Resource;
54
use std::error::Error;
65
use std::vec;

examples/tracing-jaeger/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use opentelemetry::{
22
global,
3-
trace::{TraceContextExt, TraceError, Tracer},
3+
trace::{TraceContextExt, Tracer},
44
KeyValue,
55
};
6-
use opentelemetry_sdk::trace::SdkTracerProvider;
6+
use opentelemetry_sdk::trace::{SdkTracerProvider, TraceError};
77
use opentelemetry_sdk::Resource;
88

99
use std::error::Error;

opentelemetry-appender-log/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ opentelemetry-stdout = { path = "../opentelemetry-stdout", features = ["logs"] }
3434
log = { workspace = true, features = ["kv_serde"] }
3535
tokio = { workspace = true }
3636
serde = { workspace = true, features = ["std", "derive"] }
37+
38+
[lints]
39+
workspace = true

opentelemetry-appender-log/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This crate contains a [Log Appender](https://github.com/open-telemetry/opentelem
88

99
[![Crates.io: opentelemetry-appender-log](https://img.shields.io/crates/v/opentelemetry-appender-log.svg)](https://crates.io/crates/opentelemetry-appender-log)
1010
[![Documentation](https://docs.rs/opentelemetry-appender-log/badge.svg)](https://docs.rs/opentelemetry-appender-log)
11-
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-appender-log)](./LICENSE)
11+
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-appender-log)](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-appender-log/LICENSE)
1212
[![GitHub Actions CI](https://github.com/open-telemetry/opentelemetry-rust/workflows/CI/badge.svg)](https://github.com/open-telemetry/opentelemetry-rust/actions?query=workflow%3ACI+branch%3Amain)
1313
[![Slack](https://img.shields.io/badge/slack-@cncf/otel/rust-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C03GDP0H023)
1414

@@ -29,4 +29,4 @@ of telemetry is intentionally left to other tools.
2929

3030
## Release Notes
3131

32-
You can find the release notes (changelog) [here](./CHANGELOG.md).
32+
You can find the release notes (changelog) [here](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-appender-log/CHANGELOG.md).

opentelemetry-appender-tracing/CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@
55
Fixes [1682](https://github.com/open-telemetry/opentelemetry-rust/issues/1682).
66
"spec_unstable_logs_enabled" feature now do not suppress logs for other layers.
77

8+
The special treatment of the "message" field has been extended when recording
9+
string values. With this change, when a log is emitted with a field named
10+
"message" (and string value), its value is directly assigned to the LogRecord’s
11+
body rather than being stored as an attribute named "message". This offers a
12+
slight performance improvement over previous.
13+
14+
For example, the below will now produce LogRecord with the message value
15+
populated as LogRecord's body:
16+
17+
```rust
18+
error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", message = "This is an example message");
19+
```
20+
21+
Previously, Body was only populated when the below style was used.
22+
23+
```rust
24+
error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", "This is an example message");
25+
```
26+
27+
This style, while slightly slower, should still be used when the value is not a
28+
simple string, but require format arguments as in the below example.
29+
30+
```rust
31+
error!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", "This is an example message with format arguments {} and {}", "foo", "bar");
32+
```
33+
834
## 0.28.1
935

1036
Released 2025-Feb-12

opentelemetry-appender-tracing/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ experimental_use_tracing_span_context = ["tracing-opentelemetry"]
4343
name = "logs"
4444
harness = false
4545
required-features = ["spec_unstable_logs_enabled"]
46+
47+
[lints]
48+
workspace = true

opentelemetry-appender-tracing/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ traces.
1414

1515
[![Crates.io: opentelemetry-appender-tracing](https://img.shields.io/crates/v/opentelemetry-appender-tracing.svg)](https://crates.io/crates/opentelemetry-appender-tracing)
1616
[![Documentation](https://docs.rs/opentelemetry-appender-tracing/badge.svg)](https://docs.rs/opentelemetry-appender-tracing)
17-
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-appender-tracing)](./LICENSE)
17+
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-appender-tracing)](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-appender-tracing/LICENSE)
1818
[![GitHub Actions CI](https://github.com/open-telemetry/opentelemetry-rust/workflows/CI/badge.svg)](https://github.com/open-telemetry/opentelemetry-rust/actions?query=workflow%3ACI+branch%3Amain)
1919
[![Slack](https://img.shields.io/badge/slack-@cncf/otel/rust-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C03GDP0H023)
2020

@@ -37,7 +37,7 @@ of telemetry is intentionally left to other tools.
3737

3838
## Release Notes
3939

40-
You can find the release notes (changelog) [here](./CHANGELOG.md).
40+
You can find the release notes (changelog) [here](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-appender-tracing/CHANGELOG.md).
4141

4242
## Supported Rust Versions
4343

opentelemetry-appender-tracing/src/layer.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,14 @@ impl<LR: LogRecord> tracing::field::Visit for EventVisitor<'_, LR> {
8888
if is_duplicated_metadata(field.name()) {
8989
return;
9090
}
91-
//TODO: Consider special casing "message" to populate body and document
92-
// to users to use message field for log message, to avoid going to the
93-
// record_debug, which has dyn dispatch, string allocation and
94-
// formatting cost.
95-
9691
//TODO: Fix heap allocation. Check if lifetime of &str can be used
9792
// to optimize sync exporter scenario.
98-
self.log_record
99-
.add_attribute(Key::new(field.name()), AnyValue::from(value.to_owned()));
93+
if field.name() == "message" {
94+
self.log_record.set_body(AnyValue::from(value.to_owned()));
95+
} else {
96+
self.log_record
97+
.add_attribute(Key::new(field.name()), AnyValue::from(value.to_owned()));
98+
}
10099
}
101100

102101
fn record_bool(&mut self, field: &tracing_core::Field, value: bool) {

opentelemetry-http/Cargo.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name = "opentelemetry-http"
33
version = "0.28.0"
44
description = "Helper implementations for sending HTTP requests. Uses include propagating and extracting context over http, exporting telemetry, requesting sampling strategies."
5-
homepage = "https://github.com/open-telemetry/opentelemetry-rust"
6-
repository = "https://github.com/open-telemetry/opentelemetry-rust"
5+
homepage = "https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-http"
6+
repository = "https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-http"
77
keywords = ["opentelemetry", "tracing", "context", "propagation"]
88
license = "Apache-2.0"
99
edition = "2021"
@@ -26,4 +26,7 @@ hyper-util = { workspace = true, features = ["client-legacy", "http1", "http2"],
2626
opentelemetry = { version = "0.28", path = "../opentelemetry", features = ["trace"] }
2727
reqwest = { workspace = true, features = ["blocking"], optional = true }
2828
tokio = { workspace = true, features = ["time"], optional = true }
29-
tracing = {workspace = true, optional = true}
29+
tracing = {workspace = true, optional = true}
30+
31+
[lints]
32+
workspace = true

opentelemetry-http/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ requesting sampling strategies.
1010

1111
[![Crates.io: opentelemetry-http](https://img.shields.io/crates/v/opentelemetry-http.svg)](https://crates.io/crates/opentelemetry-http)
1212
[![Documentation](https://docs.rs/opentelemetry-http/badge.svg)](https://docs.rs/opentelemetry-http)
13-
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-http)](./LICENSE)
13+
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-http)](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-http/LICENSE)
1414
[![GitHub Actions CI](https://github.com/open-telemetry/opentelemetry-rust/workflows/CI/badge.svg)](https://github.com/open-telemetry/opentelemetry-rust/actions?query=workflow%3ACI+branch%3Amain)
1515
[![Slack](https://img.shields.io/badge/slack-@cncf/otel/rust-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C03GDP0H023)
1616

@@ -33,7 +33,7 @@ of telemetry is intentionally left to other tools.
3333

3434
## Release Notes
3535

36-
You can find the release notes (changelog) [here](./CHANGELOG.md).
36+
You can find the release notes (changelog) [here](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-http/CHANGELOG.md).
3737

3838
## Supported Rust Versions
3939

opentelemetry-jaeger-propagator/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ opentelemetry = { features = ["testing"], path = "../opentelemetry" }
3131
[features]
3232
default = ["internal-logs"]
3333
internal-logs = ["tracing"]
34+
35+
[lints]
36+
workspace = true

opentelemetry-jaeger-propagator/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ opentelemetry-otlp crate.
1010

1111
[![Crates.io: opentelemetry-jaeger-propagator](https://img.shields.io/crates/v/opentelemetry-jaeger-propagator.svg)](https://crates.io/crates/opentelemetry-jaeger-propagator)
1212
[![Documentation](https://docs.rs/opentelemetry-jaeger-propagator/badge.svg)](https://docs.rs/opentelemetry-jaeger-propagator)
13-
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-jaeger-propagator)](./LICENSE)
13+
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-jaeger-propagator)](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-jaeger-propagator/LICENSE)
1414
[![GitHub Actions CI](https://github.com/open-telemetry/opentelemetry-rust/workflows/CI/badge.svg)](https://github.com/open-telemetry/opentelemetry-rust/actions?query=workflow%3ACI+branch%3Amain)
1515
[![Slack](https://img.shields.io/badge/slack-@cncf/otel/rust-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C03GDP0H023)
1616

@@ -33,7 +33,7 @@ of telemetry is intentionally left to other tools.
3333

3434
## Release Notes
3535

36-
You can find the release notes (changelog) [here](./CHANGELOG.md).
36+
You can find the release notes (changelog) [here](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-jaeger-propagator/CHANGELOG.md).
3737

3838
## Supported Rust Versions
3939

opentelemetry-otlp/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@ hyper-client = ["opentelemetry-http/hyper"]
8383

8484
# test
8585
integration-testing = ["tonic", "prost", "tokio/full", "trace", "logs"]
86+
87+
[lints]
88+
workspace = true

opentelemetry-otlp/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ implementation for
1010

1111
[![Crates.io: opentelemetry-otlp](https://img.shields.io/crates/v/opentelemetry-otlp.svg)](https://crates.io/crates/opentelemetry-otlp)
1212
[![Documentation](https://docs.rs/opentelemetry-otlp/badge.svg)](https://docs.rs/opentelemetry-otlp)
13-
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-otlp)](./LICENSE)
13+
[![LICENSE](https://img.shields.io/crates/l/opentelemetry-otlp)](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/LICENSE)
1414
[![GitHub Actions CI](https://github.com/open-telemetry/opentelemetry-rust/workflows/CI/badge.svg)](https://github.com/open-telemetry/opentelemetry-rust/actions?query=workflow%3ACI+branch%3Amain)
1515
[![codecov](https://codecov.io/gh/open-telemetry/opentelemetry-rust/branch/main/graph/badge.svg)](https://codecov.io/gh/open-telemetry/opentelemetry-rust)
1616
[![Slack](https://img.shields.io/badge/slack-@cncf/otel/rust-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C03GDP0H023)
@@ -41,7 +41,7 @@ See [docs](https://docs.rs/opentelemetry-otlp).
4141

4242
## Release Notes
4343

44-
You can find the release notes (changelog) [here](./CHANGELOG.md).
44+
You can find the release notes (changelog) [here](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/CHANGELOG.md).
4545

4646
## Supported Rust Versions
4747

opentelemetry-otlp/examples/basic-otlp-http/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-traci
1818
tokio = { workspace = true, features = ["full"] }
1919
tracing = { workspace = true, features = ["std"]}
2020
tracing-subscriber = { workspace = true, features = ["env-filter","registry", "std", "fmt"] }
21+
22+
[lints]
23+
workspace = true

opentelemetry-otlp/examples/basic-otlp/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["grpc-t
1212
tokio = { version = "1.0", features = ["full"] }
1313
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing"}
1414
tracing = { workspace = true, features = ["std"]}
15-
tracing-subscriber = { workspace = true, features = ["env-filter","registry", "std", "fmt"] }
15+
tracing-subscriber = { workspace = true, features = ["env-filter","registry", "std", "fmt"] }
16+
17+
[lints]
18+
workspace = true

opentelemetry-otlp/src/exporter/http/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl HttpExporterBuilder {
120120
.or(env::var(OTEL_EXPORTER_OTLP_TIMEOUT).ok())
121121
{
122122
Some(val) => match val.parse() {
123-
Ok(seconds) => Duration::from_millis(seconds),
123+
Ok(milli_seconds) => Duration::from_millis(milli_seconds),
124124
Err(_) => self.exporter_config.timeout,
125125
},
126126
None => self.exporter_config.timeout,
@@ -210,7 +210,7 @@ impl HttpExporterBuilder {
210210
#[cfg(feature = "trace")]
211211
pub fn build_span_exporter(
212212
mut self,
213-
) -> Result<crate::SpanExporter, opentelemetry::trace::TraceError> {
213+
) -> Result<crate::SpanExporter, opentelemetry_sdk::trace::TraceError> {
214214
use crate::{
215215
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_HEADERS,
216216
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
@@ -223,7 +223,7 @@ impl HttpExporterBuilder {
223223
OTEL_EXPORTER_OTLP_TRACES_HEADERS,
224224
)?;
225225

226-
Ok(crate::SpanExporter::new(client))
226+
Ok(crate::SpanExporter::from_http(client))
227227
}
228228

229229
/// Create a log exporter with the current configuration
@@ -301,7 +301,7 @@ impl OtlpHttpClient {
301301
fn build_trace_export_body(
302302
&self,
303303
spans: Vec<SpanData>,
304-
) -> opentelemetry::trace::TraceResult<(Vec<u8>, &'static str)> {
304+
) -> opentelemetry_sdk::trace::TraceResult<(Vec<u8>, &'static str)> {
305305
use opentelemetry_proto::tonic::collector::trace::v1::ExportTraceServiceRequest;
306306
let resource_spans = group_spans_by_resource_and_scope(spans, &self.resource);
307307

@@ -310,7 +310,7 @@ impl OtlpHttpClient {
310310
#[cfg(feature = "http-json")]
311311
Protocol::HttpJson => match serde_json::to_string_pretty(&req) {
312312
Ok(json) => Ok((json.into(), "application/json")),
313-
Err(e) => Err(opentelemetry::trace::TraceError::from(e.to_string())),
313+
Err(e) => Err(opentelemetry_sdk::trace::TraceError::from(e.to_string())),
314314
},
315315
_ => Ok((req.encode_to_vec(), "application/x-protobuf")),
316316
}

0 commit comments

Comments
 (0)