Skip to content

Commit

Permalink
Include span_context in log
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljharvey committed Sep 13, 2023
1 parent 6b1ecb3 commit e24822e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rust-connector-sdk/src/connector/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::BTreeMap;
use async_trait::async_trait;
use opentelemetry::logs::Logger;
use opentelemetry::logs::LoggerProvider;
use opentelemetry::trace::TraceContextExt;
use tracing::info_span;
use tracing::Instrument;

Expand Down Expand Up @@ -54,8 +55,11 @@ impl Connector for Example {

let logger = provider.logger("ndc_hub_example");

let context = opentelemetry::Context::current();

let log_record = opentelemetry::logs::LogRecordBuilder::new()
.with_severity_number(opentelemetry::logs::Severity::Info)
.with_span_context(context.span().span_context())
.with_attribute("event.name", "health-check-success")
.with_attribute("event.domain", "database")
.with_body("Health check OK!".into())
Expand Down

0 comments on commit e24822e

Please sign in to comment.