-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add span events #833
base: develop
Are you sure you want to change the base?
Add span events #833
Conversation
core/src/tracing/span.cpp
Outdated
|
||
for (const auto& [key, value] : events.attributes) { | ||
builder.Key(key); | ||
EventAttributeWriteVisitor write_visitor(builder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to use only one visitor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One visitor converts to JSON, and the other to a Span Event. A template visitor would still need to write two different functions, so I decided that this way there would be less code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed them to avoid confusion
otlp/src/otlp/logs/logger.cpp
Outdated
|
||
for (const auto& item : json_value) { | ||
tracing::Span::Event event{item.As<tracing::Span::Event>()}; | ||
GetAttributes(item, event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse attributes in Parse
function
after that, you do just json_value.As<std::vector<tracing::Span::Event>>()
(probably, use should include proper header for containers parsing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see
Fixed
core/src/tracing/span.cpp
Outdated
|
||
for (const auto& [key, value] : events.attributes) { | ||
builder.Key(key); | ||
std::visit(AttributeToJsonVisitor{builder}, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i implied that maybe you can create only one visitor object and reuse it in this loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/src/tracing/span_test.cpp
Outdated
|
||
const auto logs_raw = GetStreamString(); | ||
|
||
EXPECT_THAT(logs_raw, HasSubstr("events=[{\"name\":\"important_event\"")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно использовать R" чтобы не эскейпить все подряд
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавил использование
@@ -176,12 +273,17 @@ void Logger::Trace(logging::Level level, std::string_view msg) { | |||
if (key == "timestamp" || key == "text") { | |||
return true; | |||
} | |||
if (key == "events") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это место скоро поменяется, у меня уже есть патч на добавление JSON логов
подожди, пока он приземлится, и тогда нужно будет поменять это место
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ок
d55a8ba
to
72be837
Compare
Add span events to opentelemetry