You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OpenTelemetry-Appender-Tracing is currently ignoring the target from the Metadata. It is stored as an attribute "log.target" when using experimental feature flag.
target from tracing is what OTel calls instrumentation scope's name. Hence, the target should be stored as instrumentation_scope.name.
Currently, the instrumentation_scope is hardcoded to be "opentelemetry-appender-tracing", which makes it less useful, as everyLogRecord will have the same information, defeating the purpose of scope/target in OpenTelemetry.
Suggested fixes:
Modify the appender to use a different Logger for each target it encounters. This would likely kill perf/throughput due to the need of a read or read+insert to a lock-protected-hashmap in the hotpath. This could be mitigated via thread-local hashmap, so the contention can be solved at the expense of more memory. (IIUC, OTel Java uses this approach, but not sure if they use thread-local optimization or not)
Store target as a special attribute _tracing.target in the LogRecord. In the OTLP Exporter thread, specially treat "_tracing.target" and use that to construct instrumentation_scope_name. (and then do not export this special attribute). OTel .NET does something like this to avoid performance bottleneck: [OTLP] Export LogRecord.CategoryName as InstrumentationScope name opentelemetry-dotnet#4941
The text was updated successfully, but these errors were encountered:
I tried the below example, slightly modified from example, and can see that target is coming as "basic", "basic::foo", and "basic::foo::baz" respectively...
//! run with `$ cargo run --example basic
use opentelemetry::KeyValue;
use opentelemetry_appender_tracing::layer;
use opentelemetry_sdk::{
logs::{Config, LoggerProvider},
Resource,
};
use tracing::error;
use tracing_subscriber::prelude::*;
use crate::foo::bar;
fn main() {
let exporter = opentelemetry_stdout::LogExporter::default();
let provider: LoggerProvider = LoggerProvider::builder()
.with_config(
Config::default().with_resource(Resource::new(vec![KeyValue::new(
"service.name",
"log-appender-tracing-example",
)])),
)
.with_simple_exporter(exporter)
.build();
let layer = layer::OpenTelemetryTracingBridge::new(&provider);
tracing_subscriber::registry().with(layer).init();
error!(name: "my-event-name", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io");
foo::bar();
foo::baz::qux();
drop(provider);
}
mod foo {
use tracing::error;
pub fn bar() {
error!(name: "my-event-name", event_id = 21, user_name = "otel");
}
pub(crate) mod baz {
use tracing::error;
pub fn qux() {
error!(name: "my-event-name", event_id = 22, user_name = "otel");
}
}
}
OpenTelemetry-Appender-Tracing is currently ignoring the
target
from the Metadata. It is stored as an attribute "log.target" when using experimental feature flag.target
fromtracing
is what OTel calls instrumentation scope's name. Hence, thetarget
should be stored as instrumentation_scope.name.Currently, the instrumentation_scope is hardcoded to be "opentelemetry-appender-tracing", which makes it less useful, as every
LogRecord
will have the same information, defeating the purpose of scope/target in OpenTelemetry.Suggested fixes:
target
it encounters. This would likely kill perf/throughput due to the need of a read or read+insert to a lock-protected-hashmap in the hotpath. This could be mitigated via thread-local hashmap, so the contention can be solved at the expense of more memory. (IIUC, OTel Java uses this approach, but not sure if they use thread-local optimization or not)target
as a special attribute_tracing.target
in the LogRecord. In the OTLP Exporter thread, specially treat "_tracing.target" and use that to construct instrumentation_scope_name. (and then do not export this special attribute). OTel .NET does something like this to avoid performance bottleneck: [OTLP] Export LogRecord.CategoryName as InstrumentationScope name opentelemetry-dotnet#4941The text was updated successfully, but these errors were encountered: