Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add arm64 #22

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
os: windows-latest
- rust: stable
os: macos-latest
- rust: stable
os: actuated-arm64-4cpu-16gb
runs-on: ${{ matrix.os }}
steps:
- name: Free disk space
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ debug = 1
async-std = "1.10"
async-trait = "0.1"
bytes = "1"
criterion = "0.5"
futures-core = "0.3"
futures-executor = "0.3"
futures-util = { version = "0.3", default-features = false }
Expand All @@ -45,4 +46,4 @@ tokio-stream = "0.1.1"
tracing = { version = "0.1", default-features = false }
tracing-core = { version = "0.1", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false }
url = { version = "2.2", default-features = false }
url = { version = "=2.5.0", default-features = false } #pinning the version supporting rustc 1.65
10 changes: 4 additions & 6 deletions examples/tracing-grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ pub mod hello_world {
async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
let tracer = global::tracer("example/client");
let span = tracer
.span_builder(String::from("Greeter/client"))
.span_builder("Greeter/client")
.with_kind(SpanKind::Client)
.with_attributes(vec![KeyValue::new("component", "grpc")])
.with_attributes([KeyValue::new("component", "grpc")])
.start(&tracer);
let cx = Context::current_with_span(span);
let mut client = GreeterClient::connect("http://[::1]:50051").await?;
Expand All @@ -75,10 +75,8 @@ async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static
status_code.to_string()
}
};
cx.span().add_event(
"Got response!".to_string(),
vec![KeyValue::new("status", status)],
);
cx.span()
.add_event("Got response!", vec![KeyValue::new("status", status)]);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing-http-propagator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn send_request(
.await?;

cx.span().add_event(
"Got response!".to_string(),
"Got response!",
vec![KeyValue::new("status", res.status().to_string())],
);

Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-appender-log/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## vNext

- [1869](https://github.com/open-telemetry/opentelemetry-rust/pull/1869) Utilize the `LogRecord::set_target()` method to pass the log target to the SDK.

## v0.4.0

- Add log key-values as attributes [#1628](https://github.com/open-telemetry/opentelemetry-rust/pull/1628)
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-appender-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ serde = { workspace = true, optional = true, features = ["std"] }
[features]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
with-serde = ["log/kv_serde", "serde"]
default = ["logs_level_enabled"]

[dev-dependencies]
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = [ "testing", "logs_level_enabled" ] }
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-appender-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ where
log_record.set_severity_text(record.level().as_str().into());
log_record.set_body(AnyValue::from(record.args().to_string()));
log_record.add_attributes(log_attributes(record.key_values()));
log_record.set_target(record.metadata().target().to_string());

self.logger.emit(log_record);
}
Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-appender-tracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## vNext

- [1869](https://github.com/open-telemetry/opentelemetry-rust/pull/1869) Utilize the `LogRecord::set_target()` method to pass the tracing target to the SDK.
Exporters might use the target to override the instrumentation scope, which previously contained "opentelemetry-appender-tracing".

## v0.4.0

- Removed unwanted dependency on opentelemetry-sdk.
Expand Down
5 changes: 2 additions & 3 deletions opentelemetry-appender-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ log = { workspace = true }
opentelemetry-stdout = { path = "../opentelemetry-stdout", features = ["logs"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["logs", "testing"] }
tracing-log = "0.2"
async-trait = "0.1"
criterion = "0.5.1"
async-trait = { workspace = true }
criterion = { workspace = true }

[features]
experimental_metadata_attributes = ["dep:tracing-log"]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
default = ["logs_level_enabled"]


[[bench]]
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ where
let mut log_record = self.logger.create_log_record();
log_record.set_severity_number(severity_of_level(meta.level()));
log_record.set_severity_text(meta.level().to_string().into());
log_record.set_target(meta.target().to_string());

let mut visitor = EventVisitor::new(&mut log_record);
visitor.visit_metadata(meta);
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger-propagator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ opentelemetry = { version = "0.23", default-features = false, features = [
], path = "../opentelemetry" }

[dev-dependencies]
opentelemetry_sdk = { features = ["testing"], path = "../opentelemetry-sdk" }
opentelemetry = { features = ["testing"], path = "../opentelemetry" }

[features]
default = []
3 changes: 3 additions & 0 deletions opentelemetry-otlp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ now use `.with_resource(RESOURCE::default())` to configure Resource when using
These methods would also no longer set the global tracer provider. It would now be the responsibility of users to set it by calling `global::set_tracer_provider(tracer_provider.clone());`. Refer to the [basic-otlp](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/examples/basic-otlp/src/main.rs) and [basic-otlp-http](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/examples/basic-otlp-http/src/main.rs) examples on how to initialize OTLP Trace Exporter.
- **Breaking** Correct the misspelling of "webkpi" to "webpki" in features [#1842](https://github.com/open-telemetry/opentelemetry-rust/pull/1842)
- Bump MSRV to 1.70 [#1840](https://github.com/open-telemetry/opentelemetry-rust/pull/1840)
- Fixing the OTLP HTTP/JSON exporter. [#1882](https://github.com/open-telemetry/opentelemetry-rust/pull/1882) - The exporter was broken in the
previous release.
- **Breaking** [1869](https://github.com/open-telemetry/opentelemetry-rust/pull/1869) The OTLP logs exporter now overrides the [InstrumentationScope::name](https://github.com/open-telemetry/opentelemetry-proto/blob/b3060d2104df364136d75a35779e6bd48bac449a/opentelemetry/proto/common/v1/common.proto#L73) field with the `target` from `LogRecord`, if target is populated.

## v0.16.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ receivers:
http:

exporters:
logging:
loglevel: debug
debug:
verbosity: detailed

service:
pipelines:
traces:
receivers: [otlp]
exporters: [logging]
exporters: [debug]
metrics:
receivers: [otlp]
exporters: [logging]
exporters: [debug]
logs:
receivers: [otlp]
exporters: [logging]
exporters: [debug]
9 changes: 3 additions & 6 deletions opentelemetry-otlp/examples/basic-otlp-http/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,15 @@ fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
}

fn init_metrics() -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, MetricsError> {
let provider = opentelemetry_otlp::new_pipeline()
opentelemetry_otlp::new_pipeline()
.metrics(opentelemetry_sdk::runtime::Tokio)
.with_exporter(
opentelemetry_otlp::new_exporter()
.http()
.with_endpoint("http://localhost:4318/v1/metrics"),
)
.with_resource(RESOURCE.clone())
.build();
match provider {
Ok(provider) => Ok(provider),
Err(err) => Err(err),
}
.build()
}

#[tokio::main]
Expand All @@ -85,6 +81,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
);

let meter_provider = result.unwrap();
global::set_meter_provider(meter_provider.clone());

// Opentelemetry will not provide a global API to manage the logger
// provider. Application users must manage the lifecycle of the logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ receivers:
http:

exporters:
logging:
loglevel: debug
debug:
verbosity: detailed

service:
pipelines:
traces:
receivers: [otlp]
exporters: [logging]
exporters: [debug]
metrics:
receivers: [otlp]
exporters: [logging]
exporters: [debug]
logs:
receivers: [otlp]
exporters: [logging]
exporters: [debug]
10 changes: 6 additions & 4 deletions opentelemetry-otlp/tests/integration_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ publish = false
once_cell = { workspace = true }
opentelemetry = { path = "../../../opentelemetry", features = ["metrics", "logs"] }
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "logs", "testing"] }
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["tonic", "metrics", "logs"] }
opentelemetry-semantic-conventions = { path = "../../../opentelemetry-semantic-conventions" }
opentelemetry-proto = { path = "../../../opentelemetry-proto", features = ["gen-tonic-messages", "trace", "with-serde"] }
opentelemetry-appender-log = { path = "../../../opentelemetry-appender-log", default-features = false}
opentelemetry-proto = { path = "../../../opentelemetry-proto", features = ["gen-tonic-messages", "trace", "logs", "with-serde"] }
log = { workspace = true }
tokio = { version = "1.0", features = ["full"] }
serde_json = "1"
testcontainers = "0.15.0"

[target.'cfg(unix)'.dependencies]
opentelemetry-appender-log = { path = "../../../opentelemetry-appender-log", default-features = false}
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["tonic", "metrics", "logs"] }
opentelemetry-semantic-conventions = { path = "../../../opentelemetry-semantic-conventions" }
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ receivers:
http:

exporters:
logging:
loglevel: debug
file:
path: /testresults/result.json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ fn span_eq(left: &Span, right: &Span) -> bool {
pub fn read_spans_from_json(file: File) -> Vec<ResourceSpans> {
let reader = std::io::BufReader::new(file);

let trace_data: TracesData = serde_json::from_reader(reader).unwrap();
let trace_data: TracesData = serde_json::from_reader(reader).expect("Failed to read json file");
trace_data.resource_spans
}
27 changes: 27 additions & 0 deletions opentelemetry-otlp/tests/integration_test/tests/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ use opentelemetry::{
trace::{TraceContextExt, Tracer},
Key, KeyValue,
};
use opentelemetry_proto::tonic::trace::v1::TracesData;
use opentelemetry_sdk::{runtime, trace as sdktrace, Resource};
use std::error::Error;
use std::fs::File;
use std::io::Write;
use std::os::unix::fs::MetadataExt;

fn init_tracer_provider() -> Result<sdktrace::TracerProvider, TraceError> {
Expand Down Expand Up @@ -83,3 +85,28 @@ pub fn test_assert_span_eq() {

TraceAsserter::new(spans.clone(), spans).assert();
}

#[test]
pub fn test_serde() {
let spans = read_spans_from_json(
File::open("./expected/traces.json").expect("Failed to read traces.json"),
);
let json = serde_json::to_string_pretty(&TracesData {
resource_spans: spans,
})
.expect("Failed to serialize spans to json");

// Write to file.
let mut file = File::create("./expected/serialized_traces.json").unwrap();
file.write_all(json.as_bytes()).unwrap();

let left = read_spans_from_json(
File::open("./expected/traces.json").expect("Failed to read traces.json"),
);
let right = read_spans_from_json(
File::open("./expected/serialized_traces.json")
.expect("Failed to read serialized_traces.json"),
);

TraceAsserter::new(left, right).assert();
}
2 changes: 1 addition & 1 deletion opentelemetry-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ hex = { version = "0.4.3", optional = true }
tonic-build = { workspace = true }
prost-build = { workspace = true }
tempfile = "3.3.0"
serde_json = "1.0"
serde_json = { workspace = true }
22 changes: 17 additions & 5 deletions opentelemetry-proto/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,26 @@ pub(crate) mod serializers {

// AnyValue <-> KeyValue conversion
pub fn serialize_to_value<S>(value: &Option<AnyValue>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
where
S: Serializer,
{
// Serialize any_value::Value using its own implementation
// If value is None, it will be serialized as such
match value {
Some(any_value) => match &any_value.value {
Some(Value::IntValue(i)) => serialize_i64_to_string(i, serializer),
Some(Value::IntValue(i)) => {
// Attempt to create a struct to wrap the intValue
let mut state = match serializer.serialize_struct("Value", 1) {
Ok(s) => s,
Err(e) => return Err(e), // Handle the error or return it
};

// Attempt to serialize the intValue field
if let Err(e) = state.serialize_field("intValue", &i.to_string()) {
return Err(e); // Handle the error or return it
}

// Finalize the struct serialization
state.end()
},
Some(value) => value.serialize(serializer),
None => serializer.serialize_none(),
},
Expand Down
Loading
Loading