Skip to content

Commit

Permalink
feat(proto): remove build script and generate files using unit tests. (
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp authored Sep 30, 2022
1 parent cde31ec commit d571b24
Show file tree
Hide file tree
Showing 25 changed files with 2,303 additions and 124 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: CI
env:
CI: true
on:
pull_request:
push:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: integration tests

env:
CI: true
on:
pull_request:
types: [ labeled, synchronize, opened, reopened ]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ futures-util = { version = "0.3", default-features = false, features = ["std"] }

opentelemetry-proto = { version = "0.1", path = "../opentelemetry-proto", default-features = false }

grpcio = { version = "0.9", optional = true }
grpcio = { version = "0.11", optional = true }
opentelemetry = { version = "0.18", default-features = false, features = ["trace"], path = "../opentelemetry" }
opentelemetry-http = { version = "0.7", path = "../opentelemetry-http", optional = true }
protobuf = { version = "2.18", optional = true }
Expand Down Expand Up @@ -68,7 +68,7 @@ serialize = ["serde"]
default = ["grpc-tonic", "trace"]

# grpc using tonic
grpc-tonic = ["tonic", "prost", "http", "tokio", "opentelemetry-proto/gen-tonic", "opentelemetry-proto/build-client"]
grpc-tonic = ["tonic", "prost", "http", "tokio", "opentelemetry-proto/gen-tonic"]
tls = ["tonic/tls"]
tls-roots = ["tls", "tonic/tls-roots"]

Expand All @@ -85,4 +85,4 @@ reqwest-rustls = ["reqwest", "reqwest/rustls-tls-native-roots"]
surf-client = ["surf", "opentelemetry-http/surf"]

# test
integration-testing = ["tonic", "prost", "tokio/full", "trace", "opentelemetry-proto/build-server"]
integration-testing = ["tonic", "prost", "tokio/full", "trace"]
17 changes: 6 additions & 11 deletions opentelemetry-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ categories = [
keywords = ["opentelemetry", "otlp", "logging", "tracing", "metrics"]
license = "Apache-2.0"
edition = "2021"
build = "build.rs"
rust-version = "1.56"
autotests = false

Expand All @@ -24,15 +23,14 @@ doctest = false
[[test]]
name = "grpc_build"
path = "tests/grpc_build.rs"
required-features = ["with-serde", "gen-protoc"]

[features]
default = []

full = ["gen-tonic", "gen-protoc", "traces", "logs", "metrics", "zpages", "build-server", "build-client", "with-serde"]
full = ["gen-tonic", "gen-protoc", "traces", "logs", "metrics", "zpages", "with-serde"]

# crates used to generate rs files
gen-tonic = ["tonic", "tonic-build", "prost"]
gen-tonic = ["tonic", "prost"]
gen-protoc = ["grpcio", "protobuf"]

# telemetry pillars and functions
Expand All @@ -43,11 +41,9 @@ zpages = ["traces"]

# add ons
with-serde = ["protobuf/with-serde", "serde", "serde_json"]
build-server = []
build-client = []

[dependencies]
grpcio = { version = "0.9", optional = true }
grpcio = { version = "0.11", optional = true }
tonic = { version = "0.8.0", optional = true }
prost = { version = "0.11.0", optional = true }
protobuf = { version = "2.18", optional = true } # todo: update to 3.0 so we have docs for generated types.
Expand All @@ -60,7 +56,6 @@ serde_json = { version = "1.0", optional = true }
[dev-dependencies]
protobuf-codegen = { version = "2.16" }
protoc-grpcio = { version = "3.0" }

[build-dependencies]
tonic-build = { version = "0.8.0", optional = true }
prost-build = { version = "0.11.1", optional = true }
tonic-build = { version = "0.8.0" }
prost-build = { version = "0.11.1" }
tempfile = "3.3.0"
30 changes: 0 additions & 30 deletions opentelemetry-proto/build.rs

This file was deleted.

2 changes: 0 additions & 2 deletions opentelemetry-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
//! - `gen-protoc`: generate rs files using [grpcio](https://github.com/tikv/grpc-rs).
//!
//! ## Additional configurations
//! - `build-server`: build grpc service servers if enabled. Only applicable to `gen-tonic`.
//! - `build-client`: build grpc service clients if enabled. Only applicable to `gen-tonic`.
//! - `with-serde`: add serde annotations to generated types. Only applicable to `gen-protoc`.
//!
//! ## Misc
Expand Down
56 changes: 29 additions & 27 deletions opentelemetry-proto/src/proto.rs
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
#[cfg(feature = "gen-tonic")]
#[path = "proto/tonic"]
/// Generated files using [`tonic`](https://docs.rs/crate/grpcio) and [`prost`](https://docs.rs/crate/protobuf/latest)
pub mod tonic {
/// Service stub and clients
#[path = ""]
pub mod collector {
#[cfg(feature = "logs")]
#[path = ""]
pub mod logs {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.collector.logs.v1");
}
#[path = "opentelemetry.proto.collector.logs.v1.rs"]
pub mod v1;
}

#[cfg(feature = "metrics")]
#[path = ""]
pub mod metrics {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.collector.metrics.v1");
}
#[path = "opentelemetry.proto.collector.metrics.v1.rs"]
pub mod v1;
}

#[cfg(feature = "traces")]
#[path = ""]
pub mod trace {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.collector.trace.v1");
}
#[path = "opentelemetry.proto.collector.trace.v1.rs"]
pub mod v1;
}
}

/// Common types used across all signals
#[path = ""]
pub mod common {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.common.v1");
}
#[path = "opentelemetry.proto.common.v1.rs"]
pub mod v1;
}

#[cfg(feature = "logs")]
/// Generated types used in logging.
#[cfg(feature = "logs")]
#[path = ""]
pub mod logs {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.logs.v1");
}
#[path = "opentelemetry.proto.logs.v1.rs"]
pub mod v1;
}

#[cfg(feature = "metrics")]
/// Generated types used in metrics.
#[cfg(feature = "metrics")]
#[path = ""]
pub mod metrics {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.metrics.v1");
}
#[path = "opentelemetry.proto.metrics.v1.rs"]
pub mod v1;
}

/// Generated types used in resources.
#[path = ""]
pub mod resource {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.resource.v1");
}
#[path = "opentelemetry.proto.resource.v1.rs"]
pub mod v1;
}

#[cfg(feature = "traces")]
/// Generated types used in traces.
#[cfg(feature = "traces")]
#[path = ""]
pub mod trace {
pub mod v1 {
tonic::include_proto!("opentelemetry.proto.trace.v1");
}
#[path = "opentelemetry.proto.trace.v1.rs"]
pub mod v1;
}

pub use crate::transform::common::tonic::Attributes;
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/metrics_service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/resource.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/trace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/trace_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/trace_service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/proto/grpcio/tracez.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.27.1. Do not edit
// This file is generated by rust-protobuf 2.28.0. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_27_1;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_28_0;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
Loading

0 comments on commit d571b24

Please sign in to comment.