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

chore(runtime): add otel support to runtime #2085

Conversation

NathanFlurry
Copy link
Member

Changes

Copy link
Member Author

NathanFlurry commented Feb 27, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds OpenTelemetry support to the Rivet runtime, enabling distributed tracing, metrics, and logging capabilities for improved observability.

  • Added new otel.rs module that configures tracer, meter, and logger providers with GRPC export to configurable endpoint
  • Simplified runtime initialization by removing RunConfig struct and replacing with direct run() calls
  • Fixed error handling in server main functions by correcting double question mark (??) issues
  • Added multiple OpenTelemetry-related dependencies in Cargo.toml including exporters and semantic conventions
  • Removed RivetRuntime error variant from ManagerError enum as part of error handling refactoring

8 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings | Greptile

opentelemetry = { version = "0.28", features = ["trace", "metrics", "logs"] }
opentelemetry-otlp = { version = "0.28", features = ["trace", "metrics", "logs", "grpc-tonic"] }
opentelemetry-semantic-conventions = { version = "0.28", features = ["semconv_experimental"] }
opentelemetry-stdout = { version = "0.28.0", features = ["trace", "metrics", "logs"] }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The version for opentelemetry-stdout includes a patch version (0.28.0) while other opentelemetry packages use just 0.28. Consider using consistent versioning across all opentelemetry packages.

@@ -1,157 +1,71 @@
use std::{env, future::Future, sync::Once, time::Duration};
use std::{env, future::Future, time::Duration, process};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The process module is imported but not used anywhere in the code

Suggested change
use std::{env, future::Future, time::Duration, process};
use std::{env, future::Future, time::Duration};

});

if let Ok(thread_stack_size) = env::var("TOKIO_THREAD_STACK_SIZE") {
rt_builder.thread_stack_size(thread_stack_size.parse().unwrap());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using unwrap() here will cause a panic if the environment variable contains an invalid integer. The previous implementation returned a Result with a proper error message.

}
})
if let Ok(worker_threads) = env::var("TOKIO_WORKER_THREADS") {
rt_builder.worker_threads(worker_threads.parse().unwrap());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Same issue with unwrap() - this will panic on invalid input rather than returning an error like the previous implementation

use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};

const SERVICE_NAME_ENV: &str = "RIVET_SERVICE_NAME";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: SERVICE_NAME_ENV is defined but never used in the code.

[
KeyValue::new(SERVICE_NAME, env!("CARGO_PKG_NAME")),
KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")),
KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, "develop"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Environment is hardcoded as "develop". Consider using an environment variable like RIVET_ENVIRONMENT to make this configurable.

attribute::{DEPLOYMENT_ENVIRONMENT_NAME, SERVICE_NAME, SERVICE_VERSION},
SCHEMA_URL,
};
use tracing_core::Level;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Level is imported from tracing_core but never used.

use opentelemetry_sdk::{
metrics::{MeterProviderBuilder, PeriodicReader, SdkMeterProvider, },
trace::{RandomIdGenerator, Sampler, SdkTracerProvider},
logs::SdkLoggerProvider,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Inconsistent indentation (tab instead of spaces) in the import block.

Suggested change
logs::SdkLoggerProvider,
logs::SdkLoggerProvider,

OtelGuard {
tracer_provider,
meter_provider,
logger_provider
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Inconsistent indentation (tab instead of spaces) in the struct initialization.

Suggested change
logger_provider
logger_provider

Copy link

cloudflare-workers-and-pages bot commented Feb 27, 2025

Deploying rivet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 76eab99
Status:🚫  Build failed.

View logs

@NathanFlurry NathanFlurry force-pushed the 02-21-chore_hub-embed_disable_all_node-related_code_if_hub_building_is_disabled branch from f299ca1 to 9b7cef1 Compare February 27, 2025 07:59
@NathanFlurry NathanFlurry force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 825aabc to 8b2c381 Compare February 27, 2025 07:59
@NathanFlurry NathanFlurry force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 8b2c381 to dd72a3b Compare February 27, 2025 08:23
Copy link

cloudflare-workers-and-pages bot commented Feb 27, 2025

Deploying rivet-hub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 76eab99
Status: ✅  Deploy successful!
Preview URL: https://33cee47f.rivet-hub-7jb.pages.dev
Branch Preview URL: https://02-26-chore-runtime-add-otel.rivet-hub-7jb.pages.dev

View logs

@MasterPtato MasterPtato force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from fb0e2b4 to 444a28f Compare March 5, 2025 20:55
@MasterPtato MasterPtato mentioned this pull request Mar 5, 2025
@NathanFlurry NathanFlurry force-pushed the 02-21-chore_hub-embed_disable_all_node-related_code_if_hub_building_is_disabled branch from b46b2d7 to eb7f667 Compare March 5, 2025 23:56
@NathanFlurry NathanFlurry force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 444a28f to 76eab99 Compare March 5, 2025 23:56
@MasterPtato MasterPtato force-pushed the 02-21-chore_hub-embed_disable_all_node-related_code_if_hub_building_is_disabled branch from eb7f667 to b46b2d7 Compare March 6, 2025 00:50
@MasterPtato MasterPtato force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 76eab99 to 444a28f Compare March 6, 2025 00:50
@NathanFlurry NathanFlurry force-pushed the 02-21-chore_hub-embed_disable_all_node-related_code_if_hub_building_is_disabled branch from b46b2d7 to eb7f667 Compare March 6, 2025 01:32
@NathanFlurry NathanFlurry force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 444a28f to 76eab99 Compare March 6, 2025 01:32
@MasterPtato MasterPtato force-pushed the 02-21-chore_hub-embed_disable_all_node-related_code_if_hub_building_is_disabled branch from eb7f667 to b46b2d7 Compare March 6, 2025 02:38
@MasterPtato MasterPtato force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 76eab99 to 444a28f Compare March 6, 2025 02:38
@NathanFlurry NathanFlurry force-pushed the 02-21-chore_hub-embed_disable_all_node-related_code_if_hub_building_is_disabled branch from b46b2d7 to eb7f667 Compare March 6, 2025 03:30
@NathanFlurry NathanFlurry force-pushed the 02-26-chore_runtime_add_otel_support_to_runtime branch from 444a28f to 76eab99 Compare March 6, 2025 03:30
Copy link
Contributor

graphite-app bot commented Mar 6, 2025

Merge activity

  • Mar 5, 10:33 PM EST: A user added this pull request to the Graphite merge queue.
  • Mar 5, 10:35 PM EST: CI is running for this PR on a draft PR: #2125
  • Mar 5, 10:37 PM EST: A user merged this pull request with the Graphite merge queue via draft PR: #2125.

graphite-app bot pushed a commit that referenced this pull request Mar 6, 2025
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
@graphite-app graphite-app bot closed this Mar 6, 2025
@graphite-app graphite-app bot deleted the 02-26-chore_runtime_add_otel_support_to_runtime branch March 6, 2025 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant