Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tee/attestation_fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
pbeza committed Aug 8, 2024
2 parents 5a063b9 + 7ae07e4 commit 3caf0f1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion core/lib/vlog/src/opentelemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use opentelemetry_sdk::{
Resource,
};
use opentelemetry_semantic_conventions::resource::{
K8S_NAMESPACE_NAME, K8S_POD_NAME, SERVICE_NAME,
DEPLOYMENT_ENVIRONMENT, K8S_CLUSTER_NAME, K8S_NAMESPACE_NAME, K8S_POD_NAME, SERVICE_NAME,
};
use tracing_subscriber::{registry::LookupSpan, EnvFilter, Layer};
use url::Url;
Expand All @@ -27,6 +27,11 @@ pub struct ServiceDescriptor {
pub k8s_pod_name: String,
/// Name of the k8s namespace.
pub k8s_namespace_name: String,
/// Name of the k8s cluster.
pub k8s_cluster_name: String,
/// Name of the deployment environment.
/// Note that the single deployment environment can be spread among multiple clusters.
pub deployment_environment: String,
/// Name of the service.
pub service_name: String,
}
Expand All @@ -42,12 +47,20 @@ impl ServiceDescriptor {
pub const K8S_POD_NAME_ENV_VAR: &'static str = "POD_NAME";
/// Environment variable to fetch the k8s namespace name.
pub const K8S_NAMESPACE_NAME_ENV_VAR: &'static str = "POD_NAMESPACE";
/// Environment variable to fetch the k8s cluster name.
pub const K8S_CLUSTER_NAME_ENV_VAR: &'static str = "CLUSTER_NAME";
/// Environment variable to fetch the deployment environment.
pub const DEPLOYMENT_ENVIRONMENT_ENV_VAR: &'static str = "DEPLOYMENT_ENVIRONMENT";
/// Environment variable to fetch the service name.
pub const SERVICE_NAME_ENV_VAR: &'static str = "SERVICE_NAME";
/// Default value for the k8s pod name.
pub const DEFAULT_K8S_POD_NAME: &'static str = "zksync-0";
/// Default value for the k8s namespace name.
pub const DEFAULT_K8S_NAMESPACE_NAME: &'static str = "local";
/// Default value for the k8s cluster name.
pub const DEFAULT_K8S_CLUSTER_NAME: &'static str = "local";
/// Default value for the deployment environment.
pub const DEFAULT_DEPLOYMENT_ENVIRONMENT: &'static str = "local";
/// Default value for the service name.
pub const DEFAULT_SERVICE_NAME: &'static str = "zksync";

Expand All @@ -64,6 +77,14 @@ impl ServiceDescriptor {
Self::K8S_NAMESPACE_NAME_ENV_VAR,
Self::DEFAULT_K8S_NAMESPACE_NAME,
),
k8s_cluster_name: env_or(
Self::K8S_CLUSTER_NAME_ENV_VAR,
Self::DEFAULT_K8S_CLUSTER_NAME,
),
deployment_environment: env_or(
Self::DEPLOYMENT_ENVIRONMENT_ENV_VAR,
Self::DEFAULT_DEPLOYMENT_ENVIRONMENT,
),
service_name: env_or(Self::SERVICE_NAME_ENV_VAR, Self::DEFAULT_SERVICE_NAME),
}
}
Expand Down Expand Up @@ -93,6 +114,8 @@ impl ServiceDescriptor {
let attributes = vec![
KeyValue::new(K8S_POD_NAME, self.k8s_pod_name),
KeyValue::new(K8S_NAMESPACE_NAME, self.k8s_namespace_name),
KeyValue::new(K8S_CLUSTER_NAME, self.k8s_cluster_name),
KeyValue::new(DEPLOYMENT_ENVIRONMENT, self.deployment_environment),
KeyValue::new(SERVICE_NAME, self.service_name),
];
Resource::new(attributes)
Expand Down

0 comments on commit 3caf0f1

Please sign in to comment.