Skip to content

Commit a8d1fce

Browse files
authored
Merge branch 'main' into hwrdtm/fix-serde-v2
2 parents 0356f95 + 166a127 commit a8d1fce

File tree

13 files changed

+31
-47
lines changed

13 files changed

+31
-47
lines changed

.cspell.json

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"Dirkjan",
3838
"EPYC",
3939
"hasher",
40-
"isahc",
4140
"Isobel",
4241
"jaegertracing",
4342
"Kühle",

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ futures-executor = "0.3"
2525
futures-util = { version = "0.3", default-features = false }
2626
hyper = { version = "0.14", default-features = false }
2727
http = { version = "0.2", default-features = false }
28-
isahc = { version = "1.4", default-features = false }
2928
log = "0.4.21"
3029
once_cell = "1.13"
3130
ordered-float = "4.0"
@@ -46,4 +45,4 @@ tokio-stream = "0.1.1"
4645
tracing = { version = "0.1", default-features = false }
4746
tracing-core = { version = "0.1", default-features = false }
4847
tracing-subscriber = { version = "0.3", default-features = false }
49-
url = { version = "=2.5.0", default-features = false } #pinning the version supporting rustc 1.65
48+
url = { version = "2.5", default-features = false }

opentelemetry-http/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## vNext
44

55
- **Breaking** Correct the misspelling of "webkpi" to "webpki" in features [#1842](https://github.com/open-telemetry/opentelemetry-rust/pull/1842)
6+
- **Breaking** Remove support for the `isahc` HTTP client [#1924](https://github.com/open-telemetry/opentelemetry-rust/pull/1924)
67

78
## v0.12.0
89

opentelemetry-http/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ async-trait = { workspace = true }
1818
bytes = { workspace = true }
1919
http = { workspace = true }
2020
hyper = { workspace = true, features = ["http2", "client", "tcp"], optional = true }
21-
isahc = { workspace = true, optional = true }
2221
opentelemetry = { version = "0.23", path = "../opentelemetry", features = ["trace"] }
2322
reqwest = { workspace = true, features = ["blocking"], optional = true }
2423
tokio = { workspace = true, features = ["time"], optional = true }

opentelemetry-http/src/lib.rs

-26
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,6 @@ mod reqwest {
9999
}
100100
}
101101

102-
#[cfg(feature = "isahc")]
103-
mod isahc {
104-
use crate::ResponseExt;
105-
106-
use super::{async_trait, Bytes, HttpClient, HttpError, Request, Response};
107-
use isahc::AsyncReadResponseExt;
108-
use std::convert::TryInto as _;
109-
110-
#[async_trait]
111-
impl HttpClient for isahc::HttpClient {
112-
async fn send(&self, request: Request<Vec<u8>>) -> Result<Response<Bytes>, HttpError> {
113-
let mut response = self.send_async(request).await?;
114-
let mut bytes = Vec::with_capacity(response.body().len().unwrap_or(0).try_into()?);
115-
response.copy_to(&mut bytes).await?;
116-
117-
let headers = std::mem::take(response.headers_mut());
118-
let mut http_response = Response::builder()
119-
.status(response.status().as_u16())
120-
.body(bytes.into())?;
121-
*http_response.headers_mut() = headers;
122-
123-
Ok(http_response.error_for_status()?)
124-
}
125-
}
126-
}
127-
128102
#[cfg(feature = "hyper")]
129103
pub mod hyper {
130104
use crate::ResponseExt;

opentelemetry-otlp/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ tls-webpki-roots = ["tls", "tonic/tls-webpki-roots"]
7171

7272
# http binary
7373
http-proto = ["prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "http", "trace", "metrics"]
74-
# http json This does not work today due to known issue. See https://github.com/open-telemetry/opentelemetry-rust/issues/1763.
7574
http-json = ["serde_json", "prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "opentelemetry-proto/with-serde", "http", "trace", "metrics"]
7675
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"]
7776
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ once_cell = { workspace = true }
1616
opentelemetry = { path = "../../../opentelemetry" }
1717
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "metrics", "logs"] }
1818
opentelemetry-http = { path = "../../../opentelemetry-http", optional = true }
19-
opentelemetry-otlp = { path = "../..", features = ["http-proto", "reqwest-client", "logs"] }
19+
opentelemetry-otlp = { path = "../..", features = ["http-proto", "http-json", "reqwest-client", "logs"] }
2020
opentelemetry-appender-tracing = { path = "../../../opentelemetry-appender-tracing", default-features = false}
2121
opentelemetry-semantic-conventions = { path = "../../../opentelemetry-semantic-conventions" }
2222

opentelemetry-otlp/examples/basic-otlp-http/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Basic OTLP exporter Example
22

33
This example shows how to setup OpenTelemetry OTLP exporter for logs, metrics
4-
and traces to exports them to the [OpenTelemetry
4+
and traces to export them to the [OpenTelemetry
55
Collector](https://github.com/open-telemetry/opentelemetry-collector) via OTLP
6-
over HTTP/protobuf. The Collector then sends the data to the appropriate
6+
over selected protocol such as HTTP/protobuf or HTTP/json. The Collector then sends the data to the appropriate
77
backend, in this case, the logging Exporter, which displays data to console.
88

99
## Usage

opentelemetry-otlp/examples/basic-otlp-http/src/main.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ use opentelemetry::{
66
Key, KeyValue,
77
};
88
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
9+
use opentelemetry_otlp::Protocol;
910
use opentelemetry_otlp::{HttpExporterBuilder, WithExportConfig};
1011
use opentelemetry_sdk::trace::{self as sdktrace, Config};
1112
use opentelemetry_sdk::{
1213
logs::{self as sdklogs},
1314
Resource,
1415
};
16+
use std::error::Error;
1517
use tracing::info;
1618
use tracing_subscriber::prelude::*;
1719
use tracing_subscriber::EnvFilter;
1820

19-
use std::error::Error;
20-
2121
#[cfg(feature = "hyper")]
2222
mod hyper;
2323

@@ -39,22 +39,34 @@ fn init_logs() -> Result<sdklogs::LoggerProvider, opentelemetry::logs::LogError>
3939
opentelemetry_otlp::new_pipeline()
4040
.logging()
4141
.with_resource(RESOURCE.clone())
42-
.with_exporter(http_exporter().with_endpoint("http://localhost:4318/v1/logs"))
42+
.with_exporter(
43+
http_exporter()
44+
.with_protocol(Protocol::HttpBinary) //can be changed to `Protocol::HttpJson` to export in JSON format
45+
.with_endpoint("http://localhost:4318/v1/logs"),
46+
)
4347
.install_batch(opentelemetry_sdk::runtime::Tokio)
4448
}
4549

4650
fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
4751
opentelemetry_otlp::new_pipeline()
4852
.tracing()
49-
.with_exporter(http_exporter().with_endpoint("http://localhost:4318/v1/traces"))
53+
.with_exporter(
54+
http_exporter()
55+
.with_protocol(Protocol::HttpBinary) //can be changed to `Protocol::HttpJson` to export in JSON format
56+
.with_endpoint("http://localhost:4318/v1/traces"),
57+
)
5058
.with_trace_config(Config::default().with_resource(RESOURCE.clone()))
5159
.install_batch(opentelemetry_sdk::runtime::Tokio)
5260
}
5361

5462
fn init_metrics() -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, MetricsError> {
5563
opentelemetry_otlp::new_pipeline()
5664
.metrics(opentelemetry_sdk::runtime::Tokio)
57-
.with_exporter(http_exporter().with_endpoint("http://localhost:4318/v1/metrics"))
65+
.with_exporter(
66+
http_exporter()
67+
.with_protocol(Protocol::HttpBinary) //can be changed to `Protocol::HttpJson` to export in JSON format
68+
.with_endpoint("http://localhost:4318/v1/metrics"),
69+
)
5870
.with_resource(RESOURCE.clone())
5971
.build()
6072
}

opentelemetry-otlp/examples/basic-otlp/src/main.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,15 @@ fn init_metrics() -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, Metric
4040
endpoint: "http://localhost:4317".to_string(),
4141
..ExportConfig::default()
4242
};
43-
let provider = opentelemetry_otlp::new_pipeline()
43+
opentelemetry_otlp::new_pipeline()
4444
.metrics(runtime::Tokio)
4545
.with_exporter(
4646
opentelemetry_otlp::new_exporter()
4747
.tonic()
4848
.with_export_config(export_config),
4949
)
5050
.with_resource(RESOURCE.clone())
51-
.build();
52-
match provider {
53-
Ok(provider) => Ok(provider),
54-
Err(err) => Err(err),
55-
}
51+
.build()
5652
}
5753

5854
fn init_logs() -> Result<opentelemetry_sdk::logs::LoggerProvider, LogError> {

opentelemetry-sdk/CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
`RwLock` instead of `Mutex` to reduce contention
1818

1919
- **Breaking** [1726](https://github.com/open-telemetry/opentelemetry-rust/pull/1726)
20-
Update `LogProcessor::emit() method to take mutable reference to LogData. This is breaking
20+
Update `LogProcessor::emit()` method to take mutable reference to LogData. This is breaking
2121
change for LogProcessor developers. If the processor needs to invoke the exporter
2222
asynchronously, it should clone the data to ensure it can be safely processed without
2323
lifetime issues. Any changes made to the log data before cloning in this method will be
2424
reflected in the next log processor in the chain, as well as to the exporter.
2525
- **Breaking** [1726](https://github.com/open-telemetry/opentelemetry-rust/pull/1726)
26-
Update `LogExporter::export() method to accept a batch of log data, which can be either a
26+
Update `LogExporter::export()` method to accept a batch of log data, which can be either a
2727
reference or owned`LogData`. If the exporter needs to process the log data
2828
asynchronously, it should clone the log data to ensure it can be safely processed without
2929
lifetime issues.

opentelemetry-sdk/src/logs/log_emitter.rs

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ pub struct LoggerProvider {
4040

4141
/// Default logger name if empty string is provided.
4242
const DEFAULT_COMPONENT_NAME: &str = "rust.opentelemetry.io/sdk/logger";
43+
// According to a Go-specific study mentioned on https://go.dev/blog/slog,
44+
// up to 5 attributes is the most common case. We have chosen 8 as the default
45+
// capacity for attributes to avoid reallocation in common scenarios.
4346
const PREALLOCATED_ATTRIBUTE_CAPACITY: usize = 8;
4447

4548
impl opentelemetry::logs::LoggerProvider for LoggerProvider {

scripts/patch_dependencies.sh

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ function patch_version() {
66
cargo update -p $1:$latest_version --precise $2
77
}
88

9+
patch_version cc 1.0.105
10+
patch_version url 2.5.0

0 commit comments

Comments
 (0)