Skip to content

Commit

Permalink
tdiy
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Sep 19, 2024
1 parent 77522b7 commit f2a1891
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/append/opentelemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,26 @@ impl OpentelemetryLogBuilder {
}

/// Add a label to the resource.
pub fn add_label(mut self, key: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>>) -> Self {
pub fn add_label(
mut self,
key: impl Into<Cow<'static, str>>,
value: impl Into<Cow<'static, str>>,
) -> Self {
self.labels.push((key.into(), value.into()));
self
}

/// Build the [`OpentelemetryLog`] appender.
pub fn build(self) -> Result<OpentelemetryLog, opentelemetry::logs::LogError> {
let OpentelemetryLogBuilder { name, endpoint, protocol, labels } = self;
let OpentelemetryLogBuilder {
name,
endpoint,
protocol,
labels,
} = self;

let collector_timeout = Duration::from_secs(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT);
let collector_timeout =
Duration::from_secs(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT);
let exporter = match protocol {
Protocol::Grpc => opentelemetry_otlp::new_exporter()
.tonic()
Expand Down Expand Up @@ -141,7 +151,7 @@ impl Append for OpentelemetryLog {
let mut record = LogRecord::default();
record.observed_timestamp = Some(SystemTime::now());
record.severity_number = Some(log_level_to_otel_severity(log_record.level()));
record.severity_text = Some(log_record.level().as_str().into());
record.severity_text = Some(log_record.level().as_str());
record.target = Some(log_record.target().to_string().into());
record.body = Some(AnyValue::from(log_record.args().to_string()));

Expand Down
1 change: 0 additions & 1 deletion src/append/rolling_file/non_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ impl NonBlocking {
}

pub(super) fn send(&self, record: Vec<u8>) -> anyhow::Result<()> {
// TODO(tisonkun): consider drop the message if the channel is full
self.sender
.send(Message::Record(record))
.context("failed to send log message")
Expand Down

0 comments on commit f2a1891

Please sign in to comment.