-
Notifications
You must be signed in to change notification settings - Fork 12
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
TraceSegment can outlive Tracer #89
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ Tracer::Tracer(const FinalizedTracerConfig& config) | |
Tracer::Tracer(const FinalizedTracerConfig& config, | ||
const std::shared_ptr<const IDGenerator>& generator) | ||
: logger_(config.logger), | ||
config_manager_(std::make_shared<ConfigManager>(config)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this up so that it occurs before |
||
collector_(/* see constructor body */), | ||
defaults_(std::make_shared<SpanDefaults>(config.defaults)), | ||
runtime_id_(config.runtime_id ? *config.runtime_id | ||
|
@@ -53,7 +54,6 @@ Tracer::Tracer(const FinalizedTracerConfig& config, | |
extraction_styles_(config.extraction_styles), | ||
hostname_(config.report_hostname ? get_hostname() : nullopt), | ||
tags_header_max_size_(config.tags_header_size), | ||
config_manager_(config), | ||
sampling_delegation_enabled_(config.delegate_trace_sampling) { | ||
if (auto* collector = | ||
std::get_if<std::shared_ptr<Collector>>(&config.collector)) { | ||
|
@@ -94,7 +94,7 @@ nlohmann::json Tracer::config_json() const { | |
}); | ||
// clang-format on | ||
|
||
config.merge_patch(config_manager_.config_json()); | ||
config.merge_patch(config_manager_->config_json()); | ||
|
||
if (hostname_) { | ||
config["hostname"] = *hostname_; | ||
|
@@ -122,7 +122,7 @@ Span Tracer::create_span(const SpanConfig& config) { | |
tracer_telemetry_->metrics().tracer.trace_segments_created_new.inc(); | ||
const auto segment = std::make_shared<TraceSegment>( | ||
logger_, collector_, tracer_telemetry_, | ||
config_manager_.get_trace_sampler(), span_sampler_, defaults_, | ||
config_manager_->get_trace_sampler(), span_sampler_, defaults_, | ||
runtime_id_, sampling_delegation_enabled_, | ||
false /* sampling_decision_was_delegated_to_me */, injection_styles_, | ||
hostname_, nullopt /* origin */, tags_header_max_size_, | ||
|
@@ -293,7 +293,7 @@ Expected<Span> Tracer::extract_span(const DictReader& reader, | |
tracer_telemetry_->metrics().tracer.trace_segments_created_continued.inc(); | ||
const auto segment = std::make_shared<TraceSegment>( | ||
logger_, collector_, tracer_telemetry_, | ||
config_manager_.get_trace_sampler(), span_sampler_, defaults_, | ||
config_manager_->get_trace_sampler(), span_sampler_, defaults_, | ||
runtime_id_, sampling_delegation_enabled_, delegate_sampling_decision, | ||
injection_styles_, hostname_, std::move(origin), tags_header_max_size_, | ||
std::move(trace_tags), std::move(sampling_decision), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
// obtained from a `TracerConfig` via the `finalize_config` function. See | ||
// `tracer_config.h`. | ||
|
||
#include <cstddef> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we use |
||
#include <memory> | ||
|
||
#include "clock.h" | ||
#include "config_manager.h" | ||
#include "error.h" | ||
|
@@ -32,6 +35,7 @@ class SpanSampler; | |
|
||
class Tracer { | ||
std::shared_ptr<Logger> logger_; | ||
std::shared_ptr<ConfigManager> config_manager_; | ||
std::shared_ptr<Collector> collector_; | ||
std::shared_ptr<const SpanDefaults> defaults_; | ||
RuntimeID runtime_id_; | ||
|
@@ -44,7 +48,6 @@ class Tracer { | |
std::vector<PropagationStyle> extraction_styles_; | ||
Optional<std::string> hostname_; | ||
std::size_t tags_header_max_size_; | ||
ConfigManager config_manager_; | ||
bool sampling_delegation_enabled_; | ||
|
||
public: | ||
|
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.
?
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 figured the comment contained a typo:
I'm not sure what the extra
/<
is doing, and "Identifier" should probably be "Identifies".Ok, suppose the comment is "Identifies a
RemoteConfigurationManager
." True enough, but that doesn't really help me understand whatclient_id_
is or is for. So, I thought about how best to describeclient_id_
in a comment. I didn't think of anything that was better than nothing, so I went with nothing.