Skip to content

Commit

Permalink
Bump opentelemetry-prometheus from 0.17.0 to 0.27.0 in the openteleme…
Browse files Browse the repository at this point in the history
…try group (#1448)

* Bump opentelemetry-prometheus in the opentelemetry group

Bumps the opentelemetry group with 1 update: [opentelemetry-prometheus](https://github.com/open-telemetry/opentelemetry-rust).


Updates `opentelemetry-prometheus` from 0.17.0 to 0.27.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-rust/releases)
- [Commits](open-telemetry/opentelemetry-rust@opentelemetry-prometheus-0.17.0...opentelemetry-prometheus-0.27.0)

---
updated-dependencies:
- dependency-name: opentelemetry-prometheus
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: opentelemetry
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update opentelemetry, opentelemetry-sdk too.

And a few code changes to make things compile.

* Also bump opentelemetry-otlp.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brandon Pitman <[email protected]>
  • Loading branch information
dependabot[bot] and branlwyd authored Dec 19, 2024
1 parent 99385c3 commit eaab48c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 33 deletions.
46 changes: 31 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ api-mocks = ["dep:trillium-testing"]
integration-testing = []
otlp-trace = ["opentelemetry/trace", "opentelemetry-otlp", "opentelemetry_sdk/trace", "trillium-opentelemetry/trace"]


[dependencies]
aes-gcm = "0.10.3"
async-lock = "3.4.0"
Expand All @@ -43,10 +42,8 @@ futures-lite = "2.5.0"
git-version = "0.3.9"
janus_messages = "0.7.45"
log = "0.4.22"
opentelemetry = { version = "0.24.0", features = ["metrics", "logs"] }
opentelemetry-prometheus = { version = "0.17.0", features = [
"prometheus-encoding",
] }
opentelemetry = { version = "0.27.1", features = ["metrics", "logs"] }
opentelemetry-prometheus = { version = "0.27.0", features = ["prometheus-encoding"] }
prio = "0.16.7"
prometheus = "0.13.4"
querystrong = "0.3.0"
Expand Down Expand Up @@ -93,8 +90,8 @@ url = "2.5.2"
uuid = { version = "1.11.0", features = ["v4", "fast-rng", "serde"] }
validator = { version = "0.19.0", features = ["derive"] }
trillium-opentelemetry = { version = "0.9.0", default-features = false, features = ["metrics"] }
opentelemetry_sdk = { version = "0.24.1", features = ["rt-tokio", "logs", "metrics"] }
opentelemetry-otlp = { version = "0.17.0", optional = true }
opentelemetry_sdk = { version = "0.27.1", features = ["rt-tokio", "logs", "metrics"] }
opentelemetry-otlp = { version = "0.27.0", optional = true }

[dependencies.oauth2]
version = "4.4.2"
Expand Down
26 changes: 15 additions & 11 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use git_version::git_version;
use opentelemetry::{global, metrics::MetricsError, KeyValue};
use opentelemetry_sdk::{metrics::SdkMeterProvider, Resource};
use opentelemetry::{global, KeyValue};
use opentelemetry_sdk::{
metrics::{MetricError, SdkMeterProvider},
Resource,
};
use prometheus::Registry;

/// Install a Prometheus metrics provider and exporter. The
/// OpenTelemetry global API can be used to create and update
/// instruments, and they will be sent through this exporter.
pub fn metrics_exporter() -> Result<impl trillium::Handler, MetricsError> {
pub fn metrics_exporter() -> Result<impl trillium::Handler, MetricError> {
let registry = Registry::new();
let exporter = opentelemetry_prometheus::exporter()
.with_registry(registry.clone())
Expand Down Expand Up @@ -42,14 +45,15 @@ pub fn metrics_exporter() -> Result<impl trillium::Handler, MetricsError> {
);

#[cfg(feature = "otlp-trace")]
global::set_tracer_provider(
opentelemetry_otlp::new_pipeline()
.tracing()
.with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource(resource))
.with_exporter(opentelemetry_otlp::new_exporter().tonic())
.install_batch(opentelemetry_sdk::runtime::Tokio)
.unwrap(),
);
global::set_tracer_provider({
use opentelemetry_otlp::SpanExporter;
use opentelemetry_sdk::{runtime::Tokio, trace::TracerProvider};

TracerProvider::builder()
.with_resource(resource)
.with_batch_exporter(SpanExporter::builder().with_tonic().build().unwrap(), Tokio)
.build()
});

Ok(trillium_prometheus::text_format_handler(registry))
}

0 comments on commit eaab48c

Please sign in to comment.