Comments (8)
After registering layers, you should call init()
.
tracing_subscriber::registry()
.with(stdout_layer)
.with(another_layer)
.with(another_another_layer)
.with(tracing_elastic_apm_layer)
.init(); // you should call init here
from tracing-elastic-apm.
@krojew
Calling init()
sets the subscriber as the global default one which is exactly what I don't want to do. This issue is indeed about the fact that the tracing-elastic-apm
works when the subscriber is global but it does not work when using a default non-global one:
let _guard = tracing::subscriber::set_default(subscriber);
from tracing-elastic-apm.
What other layers you found working in such case?
from tracing-elastic-apm.
This is a small snippet of our real code:
// Log to a file
let file_appender = tracing_appender::rolling::never(dir, filename);
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
let file_layer = Layer::new().with_ansi(false).with_writer(non_blocking);
// Log to stdout
let (non_blocking, stdout_guard) = tracing_appender::non_blocking(std::io::stdout());
let stdout_layer = Layer::new().with_ansi(false).with_writer(non_blocking);
let subscriber = tracing_subscriber::registry()
.with(env_filter) // EnvFilter
.with(file_layer)
.with(apm_layer)
.with(stdout_layer);
everything works except the apm_layer
.
from tracing-elastic-apm.
Can you try calling set_default()
directly on subscriber
, rather than tracing::subscriber::set_default(subscriber)
?
from tracing-elastic-apm.
Tried, the issue is still present.
from tracing-elastic-apm.
After some investigation, it looks like https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/fmt/struct.Layer.html works a bit differently than this crate. It's hard to tell if this is the reason, or if any of those two behaviors is wrong. If you use with_writer
, everything that happens to spans gets converted to events and written to given writer (https://docs.rs/tracing-subscriber/0.2.20/src/tracing_subscriber/fmt/fmt_layer.rs.html#587). tracing-elastic-apm
, on the other hand, distinguishes between events and spans, and sends span data only when a span gets closed.
Therefore we're left with some open questions:
- Is this the reason for this behavior?
- Is
fmt::Layer
implementation actually correct?
It's possible you found either a bug or undocumented behavior in tracing-subscriber
. I'm not sure if there's anything I can do in this case.
from tracing-elastic-apm.
@krojew
After in-depth investigations, we found that the issue is not in this crate but, somehow, in tracing-actix-web that does not log the HTTP request info when the subscriber is not global.
from tracing-elastic-apm.
Related Issues (9)
- Error: relative URL without a base with example configuration HOT 3
- No event are reported except for `ERROR` HOT 2
- Formatting Incorrect in apm HOT 4
- Authorization header for ApiKey authentication is wrongly formatted HOT 1
- Random Mutex poisoned Error HOT 1
- Errors in send_batch() will cause infinite errors to be logged
- Infinite loop? HOT 2
- Is there any way to update the name of the outer transaction span at the end of a request? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tracing-elastic-apm.