Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/metrics-advanced/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::error::Error;
fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider {
// for example 1
let my_view_rename_and_unit = |i: &Instrument| {
if i.name == "my_histogram" {
if i.name() == "my_histogram" {
Some(
Stream::builder()
.with_name("my_histogram_renamed")
Expand All @@ -22,7 +22,7 @@ fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider {

// for example 2
let my_view_change_cardinality = |i: &Instrument| {
if i.name == "my_second_histogram" {
if i.name() == "my_second_histogram" {
// Note: If Stream is invalid, build() will return an error. By
// calling `.ok()`, any such error is ignored and treated as if the
// view does not match the instrument. If this is not the desired
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-proto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## vNext

- **Feature**: Added Rust code generation for profiles protos. [#2979](https://github.com/open-telemetry/opentelemetry-rust/pull/2979)
- Update `tonic` dependency version to 0.13
- - Update proto definitions to v1.6.0.

Expand Down
1 change: 0 additions & 1 deletion opentelemetry-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ trace = ["opentelemetry/trace", "opentelemetry_sdk/trace"]
metrics = ["opentelemetry/metrics", "opentelemetry_sdk/metrics"]
logs = ["opentelemetry/logs", "opentelemetry_sdk/logs"]
zpages = ["trace"]
profiles = []
testing = ["opentelemetry/testing"]

# add ons
Expand Down
34 changes: 1 addition & 33 deletions opentelemetry-proto/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) mod serializers {
use crate::tonic::common::v1::any_value::{self, Value};
use crate::tonic::common::v1::AnyValue;
use serde::de::{self, MapAccess, Visitor};
use serde::ser::{SerializeMap, SerializeSeq, SerializeStruct};
use serde::ser::{SerializeMap, SerializeStruct};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;

Expand Down Expand Up @@ -174,30 +174,6 @@ pub(crate) mod serializers {
s.parse::<u64>().map_err(de::Error::custom)
}

pub fn serialize_vec_u64_to_string<S>(value: &[u64], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let s = value.iter()
.map(|v| v.to_string())
.collect::<Vec<_>>();
let mut sq = serializer.serialize_seq(Some(s.len()))?;
for v in value {
sq.serialize_element(&v.to_string())?;
}
sq.end()
}

pub fn deserialize_vec_string_to_vec_u64<'de, D>(deserializer: D) -> Result<Vec<u64>, D::Error>
where
D: Deserializer<'de>,
{
let s: Vec<String> = Deserialize::deserialize(deserializer)?;
s.into_iter()
.map(|v| v.parse::<u64>().map_err(de::Error::custom))
.collect()
}

pub fn serialize_i64_to_string<S>(value: &i64, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down Expand Up @@ -290,13 +266,5 @@ pub mod tonic {
pub mod v1;
}

/// Generated types used in zpages.
#[cfg(feature = "profiles")]
#[path = ""]
pub mod profiles {
#[path = "opentelemetry.proto.profiles.v1development.rs"]
pub mod v1;
}

pub use crate::transform::common::tonic::Attributes;
}

This file was deleted.

3 changes: 0 additions & 3 deletions opentelemetry-proto/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ pub mod logs;

#[cfg(feature = "zpages")]
pub mod tracez;

#[cfg(feature = "profiles")]
pub mod profiles;
1 change: 0 additions & 1 deletion opentelemetry-proto/src/transform/profiles.rs

This file was deleted.

11 changes: 0 additions & 11 deletions opentelemetry-proto/tests/grpc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const TONIC_PROTO_FILES: &[&str] = &[
"src/proto/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto",
"src/proto/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.proto",
"src/proto/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto",
"src/proto/opentelemetry-proto/opentelemetry/proto/profiles/v1development/profiles.proto",
"src/proto/tracez.proto",
];
const TONIC_INCLUDES: &[&str] = &["src/proto/opentelemetry-proto", "src/proto"];
Expand Down Expand Up @@ -67,7 +66,6 @@ fn build_tonic() {
"metrics.v1.Summary",
"metrics.v1.NumberDataPoint",
"metrics.v1.HistogramDataPoint",
"profiles.v1development.Function",
] {
builder = builder.type_attribute(
path,
Expand All @@ -89,7 +87,6 @@ fn build_tonic() {
"logs.v1.LogRecord.trace_id",
"metrics.v1.Exemplar.span_id",
"metrics.v1.Exemplar.trace_id",
"profiles.v1development.Profile.profile_id",
] {
builder = builder
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_to_hex_string\", deserialize_with = \"crate::proto::serializers::deserialize_from_hex_string\"))]")
Expand All @@ -113,14 +110,6 @@ fn build_tonic() {
builder = builder
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_u64_to_string\", deserialize_with = \"crate::proto::serializers::deserialize_string_to_u64\"))]")
}
for path in ["profiles.v1development.Profile.time_nanos"] {
builder = builder
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_i64_to_string\", deserialize_with = \"crate::proto::serializers::deserialize_string_to_i64\"))]")
}
for path in ["profiles.v1development.Sample.timestamps_unix_nano"] {
builder = builder
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_vec_u64_to_string\", deserialize_with = \"crate::proto::serializers::deserialize_vec_string_to_vec_u64\"))]")
}

// special serializer and deserializer for value
// The Value::value field must be hidden
Expand Down
7 changes: 7 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ also modified to suppress telemetry before invoking exporters.
- Added `Stream::builder()` method that returns a new `StreamBuilder`
- `StreamBuilder::build()` returns `Result<Stream, Box<dyn Error>>` enabling
proper validation
<<<<<<< HEAD
- Removed `new_view()` on `View`. Views can be instead added by passing anything
that implements `View` trait to `with_view` method on `MeterProviderBuilder`.
`View` is implemented for `Fn(&Instrument) -> Option<Stream>`, so this can be
used to add views.
=======
>>>>>>> f04e9ec6 (feat: Use builder pattern for constructing Metric Streams (#2984))

- *Breaking* `Aggregation` enum moved behind feature flag
"spec_unstable_metrics_views". This was only required when using Views.
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ futures-executor = { workspace = true }
futures-util = { workspace = true, features = ["std", "sink", "async-await-macro"] }
percent-encoding = { workspace = true, optional = true }
rand = { workspace = true, features = ["std", "std_rng", "small_rng", "os_rng", "thread_rng"], optional = true }
glob = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive", "rc"], optional = true }
serde_json = { workspace = true, optional = true }
thiserror = { workspace = true }
Expand All @@ -45,7 +44,7 @@ trace = ["opentelemetry/trace", "rand", "percent-encoding"]
jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_json", "url", "experimental_async_runtime"]
logs = ["opentelemetry/logs", "serde_json"]
spec_unstable_logs_enabled = ["logs", "opentelemetry/spec_unstable_logs_enabled"]
metrics = ["opentelemetry/metrics", "glob"]
metrics = ["opentelemetry/metrics"]
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
experimental_async_runtime = []
rt-tokio = ["tokio", "tokio-stream", "experimental_async_runtime"]
Expand Down
22 changes: 0 additions & 22 deletions opentelemetry-sdk/src/metrics/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,8 @@ use std::sync::PoisonError;
use thiserror::Error;

/// A specialized `Result` type for metric operations.
#[cfg(feature = "spec_unstable_metrics_views")]
pub type MetricResult<T> = result::Result<T, MetricError>;
#[cfg(not(feature = "spec_unstable_metrics_views"))]
pub(crate) type MetricResult<T> = result::Result<T, MetricError>;

/// Errors returned by the metrics API.
#[cfg(feature = "spec_unstable_metrics_views")]
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum MetricError {
/// Other errors not covered by specific cases.
#[error("Metrics error: {0}")]
Other(String),
/// Invalid configuration
#[error("Config error {0}")]
Config(String),
/// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc.
/// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics)
/// for full list of requirements.
#[error("Invalid instrument configuration: {0}")]
InvalidInstrumentConfiguration(&'static str),
}

#[cfg(not(feature = "spec_unstable_metrics_views"))]
#[derive(Error, Debug)]
pub(crate) enum MetricError {
/// Other errors not covered by specific cases.
Expand Down
Loading
Loading