Skip to content

Commit a8d4bfa

Browse files
authored
Merge branch 'main' into reduce_cost_of_no_attribute_counters
2 parents 6b30d7e + f80d754 commit a8d4bfa

File tree

28 files changed

+937
-131
lines changed

28 files changed

+937
-131
lines changed

.github/workflows/integration_tests.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@ on:
77

88
jobs:
99
integration_tests:
10+
rust: stable
1011
runs-on: ubuntu-latest
1112
timeout-minutes: 10
1213
if: ${{ github.event.label.name == 'integration tests' || contains(github.event.pull_request.labels.*.name, 'integration tests') }}
1314
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v2
15+
- name: Free disk space
16+
run: |
17+
df -h
18+
sudo rm -rf /usr/local/lib/android
19+
sudo rm -rf /usr/share/dotnet
20+
df -h
21+
- uses: actions/checkout@v1
22+
with:
23+
submodules: true
24+
- uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: ${{ matrix.rust }}
27+
components: rustfmt
28+
profile: minimal
29+
- uses: arduino/setup-protoc@v1
1630
- name: Run integration tests using docker compose
1731
run: ./scripts/integration_tests.sh

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
**/*.rs.bk
55
Cargo.lock
66
/.idea/
7+
8+
.cosine

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ members = [
1818
"opentelemetry-otlp/examples/basic-otlp",
1919
"opentelemetry-otlp/examples/basic-otlp-http",
2020
"opentelemetry-otlp/examples/external-otlp-grpcio-async-std",
21+
"opentelemetry-otlp/tests/integration_test",
2122
"examples/metrics-basic",
2223
"examples/metrics-advanced",
2324
"examples/logs-basic",

examples/metrics-advanced/src/main.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,12 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
8080
// Record measurements using the histogram instrument.
8181
histogram.record(
8282
10.5,
83-
[
83+
&[
8484
KeyValue::new("mykey1", "myvalue1"),
8585
KeyValue::new("mykey2", "myvalue2"),
8686
KeyValue::new("mykey3", "myvalue3"),
8787
KeyValue::new("mykey4", "myvalue4"),
88-
]
89-
.as_ref(),
88+
],
9089
);
9190

9291
// Example 2 - Drop unwanted attributes using view.
@@ -98,13 +97,12 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
9897
// attribute.
9998
counter.add(
10099
10,
101-
[
100+
&[
102101
KeyValue::new("mykey1", "myvalue1"),
103102
KeyValue::new("mykey2", "myvalue2"),
104103
KeyValue::new("mykey3", "myvalue3"),
105104
KeyValue::new("mykey4", "myvalue4"),
106-
]
107-
.as_ref(),
105+
],
108106
);
109107

110108
// Example 3 - Change Aggregation configuration using View.
@@ -122,35 +120,32 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
122120
// the change of boundaries.
123121
histogram2.record(
124122
1.5,
125-
[
123+
&[
126124
KeyValue::new("mykey1", "myvalue1"),
127125
KeyValue::new("mykey2", "myvalue2"),
128126
KeyValue::new("mykey3", "myvalue3"),
129127
KeyValue::new("mykey4", "myvalue4"),
130-
]
131-
.as_ref(),
128+
],
132129
);
133130

134131
histogram2.record(
135132
1.2,
136-
[
133+
&[
137134
KeyValue::new("mykey1", "myvalue1"),
138135
KeyValue::new("mykey2", "myvalue2"),
139136
KeyValue::new("mykey3", "myvalue3"),
140137
KeyValue::new("mykey4", "myvalue4"),
141-
]
142-
.as_ref(),
138+
],
143139
);
144140

145141
histogram2.record(
146142
1.23,
147-
[
143+
&[
148144
KeyValue::new("mykey1", "myvalue1"),
149145
KeyValue::new("mykey2", "myvalue2"),
150146
KeyValue::new("mykey3", "myvalue3"),
151147
KeyValue::new("mykey4", "myvalue4"),
152-
]
153-
.as_ref(),
148+
],
154149
);
155150

156151
// Metrics are exported by default every 30 seconds when using stdout exporter,

examples/metrics-basic/src/main.rs

+14-21
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
3434
// Record measurements using the Counter instrument.
3535
counter.add(
3636
10,
37-
[
37+
&[
3838
KeyValue::new("mykey1", "myvalue1"),
3939
KeyValue::new("mykey2", "myvalue2"),
40-
]
41-
.as_ref(),
40+
],
4241
);
4342

4443
// Create a ObservableCounter instrument and register a callback that reports the measurement.
@@ -52,11 +51,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
5251
observer.observe_u64(
5352
&observable_counter,
5453
100,
55-
[
54+
&[
5655
KeyValue::new("mykey1", "myvalue1"),
5756
KeyValue::new("mykey2", "myvalue2"),
58-
]
59-
.as_ref(),
57+
],
6058
)
6159
})?;
6260

@@ -66,11 +64,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
6664
// Record measurements using the UpCounter instrument.
6765
updown_counter.add(
6866
-10,
69-
[
67+
&[
7068
KeyValue::new("mykey1", "myvalue1"),
7169
KeyValue::new("mykey2", "myvalue2"),
72-
]
73-
.as_ref(),
70+
],
7471
);
7572

7673
// Create a Observable UpDownCounter instrument and register a callback that reports the measurement.
@@ -84,11 +81,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
8481
observer.observe_i64(
8582
&observable_up_down_counter,
8683
100,
87-
[
84+
&[
8885
KeyValue::new("mykey1", "myvalue1"),
8986
KeyValue::new("mykey2", "myvalue2"),
90-
]
91-
.as_ref(),
87+
],
9288
)
9389
})?;
9490

@@ -101,11 +97,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
10197
// Record measurements using the histogram instrument.
10298
histogram.record(
10399
10.5,
104-
[
100+
&[
105101
KeyValue::new("mykey1", "myvalue1"),
106102
KeyValue::new("mykey2", "myvalue2"),
107-
]
108-
.as_ref(),
103+
],
109104
);
110105

111106
// Note that there is no ObservableHistogram instrument.
@@ -122,11 +117,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
122117

123118
gauge.record(
124119
1.0,
125-
[
120+
&[
126121
KeyValue::new("mykey1", "myvalue1"),
127122
KeyValue::new("mykey2", "myvalue2"),
128-
]
129-
.as_ref(),
123+
],
130124
);
131125
}
132126

@@ -142,11 +136,10 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
142136
observer.observe_f64(
143137
&observable_gauge,
144138
1.0,
145-
[
139+
&[
146140
KeyValue::new("mykey1", "myvalue1"),
147141
KeyValue::new("mykey2", "myvalue2"),
148-
]
149-
.as_ref(),
142+
],
150143
)
151144
})?;
152145

opentelemetry-http/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "opentelemetry-http"
33
version = "0.10.0"
4-
description = "Helper implementations for exchange of traces and metrics over HTTP"
4+
description = "Helper implementations for sending HTTP requests. Uses include propagating and extracting context over http, exporting telemetry, requesting sampling strategies."
55
homepage = "https://github.com/open-telemetry/opentelemetry-rust"
66
repository = "https://github.com/open-telemetry/opentelemetry-rust"
7-
keywords = ["opentelemetry", "tracing", "metrics"]
7+
keywords = ["opentelemetry", "tracing", "context", "propagation"]
88
license = "Apache-2.0"
99
edition = "2021"
1010
rust-version = "1.65"

opentelemetry-http/src/lib.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ pub use bytes::Bytes;
77
pub use http::{Request, Response};
88
use opentelemetry::propagation::{Extractor, Injector};
99

10+
/// Helper for injecting headers into HTTP Requests. This is used for OpenTelemetry context
11+
/// propagation over HTTP.
12+
/// See [this](https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/tracing-http-propagator/README.md)
13+
/// for example usage.
1014
pub struct HeaderInjector<'a>(pub &'a mut http::HeaderMap);
1115

1216
impl<'a> Injector for HeaderInjector<'a> {
@@ -20,6 +24,10 @@ impl<'a> Injector for HeaderInjector<'a> {
2024
}
2125
}
2226

27+
/// Helper for extracting headers from HTTP Requests. This is used for OpenTelemetry context
28+
/// propagation over HTTP.
29+
/// See [this](https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/tracing-http-propagator/README.md)
30+
/// for example usage.
2331
pub struct HeaderExtractor<'a>(pub &'a http::HeaderMap);
2432

2533
impl<'a> Extractor for HeaderExtractor<'a> {
@@ -39,7 +47,9 @@ impl<'a> Extractor for HeaderExtractor<'a> {
3947

4048
pub type HttpError = Box<dyn std::error::Error + Send + Sync + 'static>;
4149

42-
/// A minimal interface necessary for export spans over HTTP.
50+
/// A minimal interface necessary for sending requests over HTTP.
51+
/// Used primarily for exporting telemetry over HTTP. Also used for fetching
52+
/// sampling strategies for JaegerRemoteSampler
4353
///
4454
/// Users sometime choose HTTP clients that relay on a certain async runtime. This trait allows
4555
/// users to bring their choice of HTTP client.

opentelemetry-jaeger/src/exporter/config/collector/http_client.rs

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ mod collector_client_tests {
188188
use opentelemetry::trace::TraceError;
189189
use opentelemetry_sdk::runtime::Tokio;
190190

191+
// Ignore this test as it is flaky and the opentelemetry-jaeger is on-track for deprecation
192+
#[ignore]
191193
#[test]
192194
fn test_bring_your_own_client() -> Result<(), TraceError> {
193195
let invalid_uri_builder = new_collector_pipeline()

opentelemetry-jaeger/src/exporter/config/collector/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ mod tests {
571571
assert!(valid_uri.is_ok());
572572
}
573573

574+
// Ignore this test as it is flaky and the opentelemetry-jaeger is on-track for deprecation
575+
#[ignore]
574576
#[test]
575577
fn test_collector_exporter() {
576578
let exporter = new_collector_pipeline()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "integration_test_runner"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
8+
[dependencies]
9+
once_cell = "1.17"
10+
opentelemetry = { path = "../../../opentelemetry", features = ["metrics", "logs"] }
11+
opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-tokio", "logs", "testing"] }
12+
opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = ["tonic", "metrics", "logs"] }
13+
opentelemetry-semantic-conventions = { path = "../../../opentelemetry-semantic-conventions" }
14+
opentelemetry-proto = { path = "../../../opentelemetry-proto", features = ["gen-tonic-messages", "trace", "with-serde"] }
15+
tokio = { version = "1.0", features = ["full"] }
16+
serde_json = "1"
17+
testcontainers = "0.15.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"resourceSpans": [
3+
{
4+
"resource": {
5+
"attributes": [
6+
{
7+
"key": "service.name",
8+
"value": {
9+
"stringValue": "basic-otlp-tracing-example"
10+
}
11+
}
12+
]
13+
},
14+
"scopeSpans": [
15+
{
16+
"scope": {
17+
"name": "ex.com/basic"
18+
},
19+
"spans": [
20+
{
21+
"traceId": "9b458af7378cba65253d7042d34fc72e",
22+
"spanId": "cd7cf7bf939930b7",
23+
"parentSpanId": "",
24+
"name": "Sub operation...",
25+
"kind": 1,
26+
"startTimeUnixNano": 1703985537070566698,
27+
"endTimeUnixNano": 1703985537070572718,
28+
"attributes": [
29+
{
30+
"key": "lemons",
31+
"value": {
32+
"stringValue": "five"
33+
}
34+
}
35+
],
36+
"events": [
37+
{
38+
"timeUnixNano": 1703985537070567697,
39+
"name": "Sub span event"
40+
}
41+
],
42+
"status": {}
43+
}
44+
]
45+
}
46+
]
47+
},
48+
{
49+
"resource": {
50+
"attributes": [
51+
{
52+
"key": "service.name",
53+
"value": {
54+
"stringValue": "basic-otlp-tracing-example"
55+
}
56+
}
57+
]
58+
},
59+
"scopeSpans": [
60+
{
61+
"scope": {
62+
"name": "ex.com/basic"
63+
},
64+
"spans": [
65+
{
66+
"traceId": "9b458af7378cba65253d7042d34fc72e",
67+
"spanId": "d58cf2d702a061e0",
68+
"parentSpanId": "cd7cf7bf939930b7",
69+
"name": "operation",
70+
"kind": 1,
71+
"startTimeUnixNano": 1703985537070558635,
72+
"endTimeUnixNano": 1703985537070580454,
73+
"attributes": [
74+
{
75+
"key": "ex.com/another",
76+
"value": {
77+
"stringValue": "yes"
78+
}
79+
}
80+
],
81+
"events": [
82+
{
83+
"timeUnixNano": 1703985537070563326,
84+
"name": "Nice operation!",
85+
"attributes": [
86+
{
87+
"key": "bogons",
88+
"value": {
89+
"intValue": 100
90+
}
91+
}
92+
]
93+
}
94+
],
95+
"status": {}
96+
}
97+
]
98+
}
99+
]
100+
}
101+
]
102+
}

0 commit comments

Comments
 (0)