Skip to content

Commit

Permalink
fixing table
Browse files Browse the repository at this point in the history
  • Loading branch information
psandana committed Mar 14, 2024
1 parent ac2f992 commit 1018495
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
24 changes: 15 additions & 9 deletions opentelemetry-etw-logs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,29 @@ license = "Apache-2.0"
[dependencies]
tracelogging = "1.2.1"
tracelogging_dynamic = "1.2.1"
opentelemetry = { version = "0.21", features = ["logs"] }
opentelemetry_sdk = { version = "0.21", features = ["logs"] }
async-std = { version="1.6" }
async-trait = { version="0.1" }
chrono = { version="0.4", default-features = false, features=["std"] }
opentelemetry = { workspace = true, features = ["logs"] }
opentelemetry_sdk = { workspace = true, features = ["logs"] }
async-std = { version = "1.6" }
async-trait = { version = "0.1" }
chrono = { version = "0.4", default-features = false, features = ["std"] }
serde_json = "1.0.113"

[dev-dependencies]
opentelemetry-appender-tracing = { version = "0.2" }
opentelemetry-appender-tracing = { workspace = true }
tracing = { version = "0.1", default-features = false, features = ["std"] }
tracing-core = "0.1.31"
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["registry", "std"] }
tracing-subscriber = { version = "0.3.0", default-features = false, features = [
"registry",
"std",
] }
microbench = "0.5"

[features]
logs_level_enabled = ["opentelemetry/logs_level_enabled", "opentelemetry_sdk/logs_level_enabled"]
default=["logs_level_enabled"]
logs_level_enabled = [
"opentelemetry/logs_level_enabled",
"opentelemetry_sdk/logs_level_enabled",
]
default = ["logs_level_enabled"]

[[example]]
name = "basic"
Expand Down
5 changes: 3 additions & 2 deletions opentelemetry-etw-logs/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! run with `$ cargo run --example basic --all-features
use opentelemetry_appender_tracing::layer;
use opentelemetry_sdk::logs::LoggerProvider;
use opentelemetry_etw_logs::{ExporterConfig, ReentrantLogProcessor};
use opentelemetry_sdk::logs::LoggerProvider;
use std::collections::HashMap;
use tracing::error;
use tracing_subscriber::prelude::*;
Expand All @@ -12,7 +12,8 @@ fn init_logger() -> LoggerProvider {
default_keyword: 1,
keywords_map: HashMap::new(),
};
let reenterant_processor = ReentrantLogProcessor::new("test", None, exporter_config);
let reenterant_processor =
ReentrantLogProcessor::new("test", "table".into(), None, exporter_config);
LoggerProvider::builder()
.with_log_processor(reenterant_processor)
.build()
Expand Down
5 changes: 3 additions & 2 deletions opentelemetry-etw-logs/src/logs/converters.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use opentelemetry::logs::AnyValue;
use opentelemetry::{Key, OrderMap};
use opentelemetry::Key;
use serde_json::{json, Map, Value};
use std::collections::HashMap;

pub(super) trait IntoJson {
fn as_json_value(&self) -> Value;
Expand All @@ -20,7 +21,7 @@ impl IntoJson for AnyValue {
}
}

impl IntoJson for OrderMap<Key, AnyValue> {
impl IntoJson for HashMap<Key, AnyValue> {
fn as_json_value(&self) -> Value {
Value::Object(
self.iter()
Expand Down
14 changes: 6 additions & 8 deletions opentelemetry-etw-logs/src/logs/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl ExporterConfig {
pub(crate) struct ETWExporter {
provider: Pin<Arc<tld::Provider>>,
exporter_config: ExporterConfig,
event_name: String,
}

const EVENT_ID: &str = "event_id";
Expand All @@ -77,6 +78,7 @@ fn enabled_callback(
impl ETWExporter {
pub(crate) fn new(
provider_name: &str,
event_name: String,
_provider_group: ProviderGroup,
exporter_config: ExporterConfig,
) -> Self {
Expand All @@ -95,6 +97,7 @@ impl ETWExporter {
ETWExporter {
provider,
exporter_config,
event_name,
}
}

Expand Down Expand Up @@ -191,12 +194,7 @@ impl ETWExporter {
let mut event = tld::EventBuilder::new();

// reset
event.reset(
log_data.instrumentation.name.as_ref(),
level,
keyword,
event_tags,
);
event.reset(&self.event_name, level, keyword, event_tags);

event.add_u16("__csver__", 0x0401u16, tld::OutType::Hex, field_tag);

Expand All @@ -209,7 +207,7 @@ impl ETWExporter {
// Write event to ETW
event.write(&self.provider, None, None);

return Ok(());
Ok(())
}

fn populate_part_a(
Expand Down Expand Up @@ -333,7 +331,7 @@ impl ETWExporter {
}
}

return (event_id, event_name);
(event_id, event_name)
}
}

Expand Down
3 changes: 2 additions & 1 deletion opentelemetry-etw-logs/src/logs/reentrant_logprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ impl ReentrantLogProcessor {
/// constructor
pub fn new(
provider_name: &str,
event_name: String,
provider_group: ProviderGroup,
exporter_config: ExporterConfig,
) -> Self {
let exporter = ETWExporter::new(provider_name, provider_group, exporter_config);
let exporter = ETWExporter::new(provider_name, event_name, provider_group, exporter_config);
ReentrantLogProcessor {
event_exporter: exporter,
}
Expand Down

0 comments on commit 1018495

Please sign in to comment.