Skip to content

Commit

Permalink
fix api breakage (#186)
Browse files Browse the repository at this point in the history
I'm not convinced the otel stuff is right, the API here changed a ton
between 0.26 and 0.27. I'm going to read more carefully but this was
what I could infer off READMEs.

There's no upgrading guide.
  • Loading branch information
paultag authored Nov 14, 2024
1 parent e674b9b commit d35ff6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions src/bin/machine-api/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use anyhow::Result;
use clap::{Parser, Subcommand};
use opentelemetry::{trace::TracerProvider, KeyValue};
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::Resource;
use opentelemetry::trace::TracerProvider;
use tracing_subscriber::prelude::*;

mod config;
Expand Down Expand Up @@ -129,19 +127,12 @@ async fn main() -> Result<()> {
)
};

let otlp_host = match std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT") {
Ok(val) => val,
Err(_) => "http://localhost:4317".to_string(),
};

let provider = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(opentelemetry_otlp::new_exporter().tonic().with_endpoint(otlp_host))
.with_trace_config(
opentelemetry_sdk::trace::Config::default()
.with_resource(Resource::new(vec![KeyValue::new("service.name", "machine-api")])),
let provider = opentelemetry_sdk::trace::TracerProvider::builder()
.with_batch_exporter(
opentelemetry_otlp::SpanExporter::builder().with_tonic().build()?,
opentelemetry_sdk::runtime::Tokio,
)
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
.build();

opentelemetry::global::set_tracer_provider(provider.clone());
let tracer = provider.tracer("tracing-otel-subscriber");
Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub async fn create_server(
/// Get the OpenAPI specification for the server.
pub fn get_openapi(api: &mut ApiDescription<Arc<Context>>) -> Result<serde_json::Value> {
// Create the API schema.
let mut definition = api.openapi("machine-api", clap::crate_version!());
let mut definition = api.openapi("machine-api", clap::crate_version!().parse()?);
definition
.description("")
.contact_url("https://zoo.dev")
Expand Down

0 comments on commit d35ff6d

Please sign in to comment.