Skip to content

Commit bbffd71

Browse files
authored
Merge branch 'main' into validate-baggage
2 parents cca2401 + 31b494b commit bbffd71

File tree

6 files changed

+290
-140
lines changed

6 files changed

+290
-140
lines changed

.github/workflows/benchmark.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow runs a Criterion benchmark on a PR and compares the results against the base branch.
2+
# It is triggered on a PR or a push to main.
3+
#
4+
# The workflow is gated on the presence of the "performance" label on the PR.
5+
#
6+
# The workflow runs on a self-hosted runner pool. We can't use the shared runners for this,
7+
# because they are only permitted to run on the default branch to preserve resources.
8+
#
9+
# In the future, we might like to consider using bencher.dev or the framework used by otel-golang here.
10+
on:
11+
pull_request:
12+
push:
13+
branches:
14+
- main
15+
name: benchmark pull requests
16+
jobs:
17+
runBenchmark:
18+
name: run benchmark
19+
permissions:
20+
pull-requests: write
21+
22+
# If we're running on a PR, use ubuntu-latest - a shared runner. We can't use the self-hosted
23+
# runners on arbitrary PRs, and we don't want to unleash that load on the pool anyway.
24+
# If we're running on main, use the OTEL self-hosted runner pool.
25+
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
26+
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'performance')) || github.event_name == 'push' }}
27+
env:
28+
# For PRs, compare against the base branch - e.g., 'main'.
29+
# For pushes to main, compare against the previous commit
30+
BRANCH_NAME: ${{ github.event_name == 'pull_request' && github.base_ref || github.event.before }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 10 # Fetch current commit and its parent
35+
- uses: arduino/setup-protoc@v3
36+
with:
37+
repo-token: ${{ secrets.GITHUB_TOKEN }}
38+
- uses: dtolnay/rust-toolchain@master
39+
with:
40+
toolchain: stable
41+
- uses: boa-dev/criterion-compare-action@v3
42+
with:
43+
cwd: opentelemetry
44+
branchName: ${{ env.BRANCH_NAME }}
45+
- uses: boa-dev/criterion-compare-action@v3
46+
with:
47+
cwd: opentelemetry-appender-tracing
48+
features: spec_unstable_logs_enabled
49+
branchName: ${{ env.BRANCH_NAME }}
50+
- uses: boa-dev/criterion-compare-action@v3
51+
with:
52+
cwd: opentelemetry-sdk
53+
features: rt-tokio,testing,metrics,logs,spec_unstable_metrics_views
54+
branchName: ${{ env.BRANCH_NAME }}

.github/workflows/pr_criterion.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

opentelemetry-otlp/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
`Error` which contained many variants unrelated to building an exporter, the
1818
new one returns specific variants applicable to building an exporter. Some
1919
variants might be applicable only on select features.
20+
- **Breaking** `ExportConfig`'s `timeout` field is now optional(`Option<Duration>`)
21+
- **Breaking** Export configuration done via code is final. ENV variables cannot be used to override the code config.
22+
Do not use code based config, if there is desire to control the settings via ENV variables.
23+
List of ENV variables and corresponding setting being affected by this change.
24+
- `OTEL_EXPORTER_OTLP_ENDPOINT` -> `ExportConfig.endpoint`
25+
- `OTEL_EXPORTER_OTLP_TIMEOUT` -> `ExportConfig.timeout`
2026

2127
## 0.28.0
2228

opentelemetry-otlp/src/exporter/http/mod.rs

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use super::{
2-
default_headers, default_protocol, parse_header_string, ExporterBuildError,
2+
default_headers, default_protocol, parse_header_string, resolve_timeout, ExporterBuildError,
33
OTEL_EXPORTER_OTLP_HTTP_ENDPOINT_DEFAULT,
44
};
5-
use crate::{
6-
ExportConfig, Protocol, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS,
7-
OTEL_EXPORTER_OTLP_TIMEOUT,
8-
};
5+
use crate::{ExportConfig, Protocol, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS};
96
use http::{HeaderName, HeaderValue, Uri};
107
use opentelemetry_http::HttpClient;
118
use opentelemetry_proto::transform::common::tonic::ResourceAttributesWithSchema;
@@ -112,19 +109,10 @@ impl HttpExporterBuilder {
112109
let endpoint = resolve_http_endpoint(
113110
signal_endpoint_var,
114111
signal_endpoint_path,
115-
self.exporter_config.endpoint.clone(),
112+
self.exporter_config.endpoint.as_deref(),
116113
)?;
117114

118-
let timeout = match env::var(signal_timeout_var)
119-
.ok()
120-
.or(env::var(OTEL_EXPORTER_OTLP_TIMEOUT).ok())
121-
{
122-
Some(val) => match val.parse() {
123-
Ok(milli_seconds) => Duration::from_millis(milli_seconds),
124-
Err(_) => self.exporter_config.timeout,
125-
},
126-
None => self.exporter_config.timeout,
127-
};
115+
let timeout = resolve_timeout(signal_timeout_var, self.exporter_config.timeout.as_ref());
128116

129117
#[allow(unused_mut)] // TODO - clippy thinks mut is not needed, but it is
130118
let mut http_client = self.http_config.client.take();
@@ -371,30 +359,27 @@ fn build_endpoint_uri(endpoint: &str, path: &str) -> Result<Uri, ExporterBuildEr
371359
fn resolve_http_endpoint(
372360
signal_endpoint_var: &str,
373361
signal_endpoint_path: &str,
374-
provided_endpoint: Option<String>,
362+
provided_endpoint: Option<&str>,
375363
) -> Result<Uri, ExporterBuildError> {
376-
// per signal env var is not modified
377-
if let Some(endpoint) = env::var(signal_endpoint_var)
364+
// programmatic configuration overrides any value set via environment variables
365+
if let Some(provider_endpoint) = provided_endpoint {
366+
provider_endpoint
367+
.parse()
368+
.map_err(|er: http::uri::InvalidUri| {
369+
ExporterBuildError::InvalidUri(provider_endpoint.to_string(), er.to_string())
370+
})
371+
} else if let Some(endpoint) = env::var(signal_endpoint_var)
378372
.ok()
379373
.and_then(|s| s.parse().ok())
380374
{
381-
return Ok(endpoint);
382-
}
383-
384-
// if signal env var is not set, then we check if the OTEL_EXPORTER_OTLP_ENDPOINT is set
385-
if let Some(endpoint) = env::var(OTEL_EXPORTER_OTLP_ENDPOINT)
375+
// per signal env var is not modified
376+
Ok(endpoint)
377+
} else if let Some(endpoint) = env::var(OTEL_EXPORTER_OTLP_ENDPOINT)
386378
.ok()
387379
.and_then(|s| build_endpoint_uri(&s, signal_endpoint_path).ok())
388380
{
389-
return Ok(endpoint);
390-
}
391-
392-
if let Some(provider_endpoint) = provided_endpoint {
393-
provider_endpoint
394-
.parse()
395-
.map_err(|er: http::uri::InvalidUri| {
396-
ExporterBuildError::InvalidUri(provider_endpoint, er.to_string())
397-
})
381+
// if signal env var is not set, then we check if the OTEL_EXPORTER_OTLP_ENDPOINT env var is set
382+
Ok(endpoint)
398383
} else {
399384
build_endpoint_uri(
400385
OTEL_EXPORTER_OTLP_HTTP_ENDPOINT_DEFAULT,
@@ -481,12 +466,9 @@ mod tests {
481466
run_env_test(
482467
vec![(OTEL_EXPORTER_OTLP_ENDPOINT, "http://example.com")],
483468
|| {
484-
let endpoint = resolve_http_endpoint(
485-
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
486-
"/v1/traces",
487-
Some("http://localhost:4317".to_string()),
488-
)
489-
.unwrap();
469+
let endpoint =
470+
resolve_http_endpoint(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "/v1/traces", None)
471+
.unwrap();
490472
assert_eq!(endpoint, "http://example.com/v1/traces");
491473
},
492474
)
@@ -496,20 +478,36 @@ mod tests {
496478
fn test_not_append_signal_path_to_signal_env() {
497479
run_env_test(
498480
vec![(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "http://example.com")],
481+
|| {
482+
let endpoint =
483+
resolve_http_endpoint(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "/v1/traces", None)
484+
.unwrap();
485+
assert_eq!(endpoint, "http://example.com");
486+
},
487+
)
488+
}
489+
490+
#[test]
491+
fn test_priority_of_signal_env_over_generic_env() {
492+
run_env_test(
493+
vec![
494+
(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "http://example.com"),
495+
(OTEL_EXPORTER_OTLP_ENDPOINT, "http://wrong.com"),
496+
],
499497
|| {
500498
let endpoint = super::resolve_http_endpoint(
501499
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
502500
"/v1/traces",
503-
Some("http://localhost:4317".to_string()),
501+
None,
504502
)
505503
.unwrap();
506504
assert_eq!(endpoint, "http://example.com");
507505
},
508-
)
506+
);
509507
}
510508

511509
#[test]
512-
fn test_priority_of_signal_env_over_generic_env() {
510+
fn test_priority_of_code_based_config_over_envs() {
513511
run_env_test(
514512
vec![
515513
(OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, "http://example.com"),
@@ -519,24 +517,20 @@ mod tests {
519517
let endpoint = super::resolve_http_endpoint(
520518
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
521519
"/v1/traces",
522-
Some("http://localhost:4317".to_string()),
520+
Some("http://localhost:4317"),
523521
)
524522
.unwrap();
525-
assert_eq!(endpoint, "http://example.com");
523+
assert_eq!(endpoint, "http://localhost:4317");
526524
},
527525
);
528526
}
529527

530528
#[test]
531-
fn test_use_provided_or_default_when_others_missing() {
529+
fn test_use_default_when_others_missing() {
532530
run_env_test(vec![], || {
533-
let endpoint = super::resolve_http_endpoint(
534-
"NON_EXISTENT_VAR",
535-
"/v1/traces",
536-
Some("http://localhost:4317".to_string()),
537-
)
538-
.unwrap();
539-
assert_eq!(endpoint, "http://localhost:4317/");
531+
let endpoint =
532+
super::resolve_http_endpoint("NON_EXISTENT_VAR", "/v1/traces", None).unwrap();
533+
assert_eq!(endpoint, "http://localhost:4318/v1/traces");
540534
});
541535
}
542536

@@ -568,7 +562,7 @@ mod tests {
568562
let endpoint = super::resolve_http_endpoint(
569563
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
570564
"/v1/traces",
571-
Some("http://localhost:4317".to_string()),
565+
None,
572566
)
573567
.unwrap();
574568
assert_eq!(endpoint, "http://example.com/v1/traces");
@@ -582,7 +576,7 @@ mod tests {
582576
let result = super::resolve_http_endpoint(
583577
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
584578
"/v1/traces",
585-
Some("-*/*-/*-//-/-/yet-another-invalid-uri".to_string()),
579+
Some("-*/*-/*-//-/-/yet-another-invalid-uri"),
586580
);
587581
assert!(result.is_err());
588582
// You may also want to assert on the specific error type if applicable
@@ -722,7 +716,7 @@ mod tests {
722716
let url = resolve_http_endpoint(
723717
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
724718
"/v1/traces",
725-
exporter.exporter_config.endpoint,
719+
exporter.exporter_config.endpoint.as_deref(),
726720
)
727721
.unwrap();
728722

@@ -737,7 +731,7 @@ mod tests {
737731
let url = resolve_http_endpoint(
738732
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
739733
"/v1/traces",
740-
exporter.exporter_config.endpoint,
734+
exporter.exporter_config.endpoint.as_deref(),
741735
)
742736
.unwrap();
743737

0 commit comments

Comments
 (0)