Skip to content

Commit

Permalink
Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Aug 1, 2024
1 parent 0a7b27e commit ecba965
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
6 changes: 2 additions & 4 deletions core/lib/vlog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ impl ObservabilityBuilder {
let (otlp_tracing_provider, otlp_tracing_layer) = self
.opentelemetry_layer
.as_ref()
.map(|layer| layer.tracing_layer())
.flatten()
.and_then(|layer| layer.tracing_layer())
.unzip();
let (otlp_logging_provider, otlp_logging_layer) = self
.opentelemetry_layer
.map(|layer| layer.logs_layer())
.flatten()
.and_then(|layer| layer.logs_layer())
.unzip();

tracing_subscriber::registry()
Expand Down
18 changes: 7 additions & 11 deletions core/lib/vlog/src/opentelemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ impl ServiceDescriptor {
}

fn into_otlp_resource(self) -> Resource {
let mut attributes = vec![];
attributes.push(KeyValue::new(K8S_POD_NAME, self.k8s_pod_name));
attributes.push(KeyValue::new(K8S_NAMESPACE_NAME, self.k8s_namespace_name));
attributes.push(KeyValue::new(SERVICE_NAME, self.service_name));
let attributes = vec![
KeyValue::new(K8S_POD_NAME, self.k8s_pod_name),
KeyValue::new(K8S_NAMESPACE_NAME, self.k8s_namespace_name),
KeyValue::new(SERVICE_NAME, self.service_name),
];
Resource::new(attributes)
}
}
Expand Down Expand Up @@ -164,10 +165,7 @@ impl OpenTelemetry {
where
S: tracing::Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
{
let Some(logging_endpoint) = self.logging_endpoint.clone() else {
return None;
};

let logging_endpoint = self.logging_endpoint.clone()?;
let resource = self.service.clone().into_otlp_resource();

let exporter = opentelemetry_otlp::new_exporter()
Expand Down Expand Up @@ -195,9 +193,7 @@ impl OpenTelemetry {
where
S: tracing::Subscriber + for<'span> LookupSpan<'span> + Send + Sync,
{
let Some(tracing_endpoint) = self.tracing_endpoint.clone() else {
return None;
};
let tracing_endpoint = self.tracing_endpoint.clone()?;
// `otel::tracing` should be a level info to emit opentelemetry trace & span
// `otel` set to debug to log detected resources, configuration read and inferred
let filter = self
Expand Down

0 comments on commit ecba965

Please sign in to comment.