-
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
remote config: more code review comments #83
Closed
dgoffredo
wants to merge
22
commits into
dmehala/remote-config-impl
from
david.goffredo/reviews/dmehala/remote-config-impl
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e4d44b9
update fuzz documentation
dgoffredo b7c0d0e
revise the base64 decoder
dgoffredo e3f0ce3
move ConfigManager into its own .cpp
dgoffredo 6d1553b
remove namespace httputil::header
dgoffredo ea1611f
more specific error code
dgoffredo a156703
RuntimeID rc_id_ --> std::string client_id_
dgoffredo 2353171
TracerId --> TracerID
dgoffredo 34ad10f
remove disambiguating "template" keyword
dgoffredo fd76ec4
document k_apm_capabilities
dgoffredo 7c421ba
missed a spot when removing namespace httputil::header
dgoffredo 197063b
no need to optimize target file lookup
dgoffredo 06aace8
slightly safer product parsing
dgoffredo b1dc9cf
mention missing config path in error message
dgoffredo c32d861
use line comments
dgoffredo 1c8a665
remove trailing whitespace
dgoffredo 5dfe43e
question about remote config response
dgoffredo 1f34fca
Merge branch 'dmehala/remote-config-impl' into david.goffredo/reviews…
dgoffredo 322061d
TracerID --> TracerSignature
dgoffredo 4e7f4ac
bin/format
dgoffredo 7618291
add documentation TODOs
dgoffredo 270d376
fix up pragmas and includes
dgoffredo 5b4d1ac
bin/format
dgoffredo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#include "config_manager.h" | ||
|
||
#include "trace_sampler.h" | ||
|
||
namespace datadog { | ||
namespace tracing { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "tracer_signature.h" | ||
|
||
#include "version.h" | ||
|
||
namespace datadog { | ||
namespace tracing { | ||
|
||
TracerSignature::TracerSignature(const RuntimeID& runtime_id, | ||
const std::string& default_service, | ||
const std::string& default_environment) | ||
: runtime_id_(runtime_id), | ||
default_service_(default_service), | ||
default_environment_(default_environment) {} | ||
|
||
const RuntimeID& TracerSignature::runtime_id() const { return runtime_id_; } | ||
|
||
StringView TracerSignature::default_service() const { return default_service_; } | ||
|
||
StringView TracerSignature::default_environment() const { | ||
return default_environment_; | ||
} | ||
|
||
StringView TracerSignature::library_version() const { return tracer_version; } | ||
|
||
StringView TracerSignature::library_language() const { return "cpp"; } | ||
|
||
StringView TracerSignature::library_language_version() const { | ||
static const std::string value = std::to_string(__cplusplus); | ||
return value; | ||
} | ||
|
||
} // namespace tracing | ||
} // namespace datadog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
|
||
// This component provides a class, `TracerSignature`, that contains the parts | ||
// of a tracer's configuration that are used to refer to the tracer in Datadog's | ||
// telemetry and remote configuration APIs. | ||
// | ||
// `TracerSignature` is used in three contexts: | ||
// | ||
// 1. When telemetry is sent to the Datadog Agent, the tracer signature is | ||
// included in the request payload. See | ||
// `TracerTelemetry::generate_telemetry_body` in `tracer_telemetry.cpp`. | ||
// 2. When the Datadog Agent is polled for configuration updates, part of the | ||
// tracer signature (all but the language version) is included in the request | ||
// payload. See `RemoteConfigurationManager::make_request_payload` in | ||
// `remote_config.h`. | ||
// 3. When the Datadog Agent responds with configuration updates, the service | ||
// and environment of the tracer signature are used to determine whether the | ||
// updates are relevant to the `Tracer` that created the collector that is | ||
// polling the Datadog Agent. See | ||
// `RemoteConfigurationManager::process_response` in `remote_config.h`. | ||
|
||
#include <string> | ||
|
||
#include "runtime_id.h" | ||
#include "string_view.h" | ||
|
||
namespace datadog { | ||
namespace tracing { | ||
|
||
class TracerSignature { | ||
RuntimeID runtime_id_; | ||
std::string default_service_; | ||
std::string default_environment_; | ||
|
||
public: | ||
// Create a tracer signature having the specified `runtime_id`, | ||
// `default_service`, and `default_environment`. `default_service` and | ||
// `default_environment` refer to the corresponding fields from | ||
// `SpanDefaults`. | ||
TracerSignature(const RuntimeID& runtime_id, | ||
const std::string& default_service, | ||
const std::string& default_environment); | ||
|
||
// Return the runtime ID with which the tracer was configured. | ||
const RuntimeID& runtime_id() const; | ||
// Return the `SpanDefaults::service` with which the tracer was configured. | ||
StringView default_service() const; | ||
// Return the `SpanDefaults::environment` with which the tracer was | ||
// configured. | ||
StringView default_environment() const; | ||
// Return the version of this tracing library (`tracer_version` from | ||
// `version.h`). | ||
StringView library_version() const; | ||
// Return the name of the programming language in which this library is | ||
// written: "cpp". | ||
StringView library_language() const; | ||
// Return the version of C++ standard used to compile this library. It should | ||
// be "201703". | ||
StringView library_language_version() const; | ||
}; | ||
|
||
} // namespace tracing | ||
} // namespace datadog |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does it have to be a
class
with getter?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.
Looking at the two (well, more than two) JSON payloads that use
service
,environment
, andruntime_id
, I saw that library language, library version, and library language version (all constants) were also there on an equal footing. Who's to say that those are not also part of the signature?So, either I would keep it a
struct
having only the three fields, and leave the code that pulls the other values from the appropriate constants; or, I could wrap those constants into the type. I chose the latter, but am not committed to the idea.I justified it to myself by saying "this makes the notion of a tracer signature more substantial."
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.
How about a third option where it's still a
struct
orclass
but with all fields accessible: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.
That works.
__cplusplus
is an integer literal, though.Options that I considered:
std::string
. That would work.__cplusplus
. This works, but then you get a trailing "L" due to the definition of the__cplusplus
token. :(It also ever so slightly bothers me that
library_*
as data members implies that the values might mutate, when in actuality they never will. Maybe this is an indication that it's not such a good idea to put them inTraceSignature
after all.const
data members aren't worth the trouble, seeing how they disable assignments and moves, though that might not matter forTracerSignature
's usage.Anything will do.
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.
Too cute? :P
https://godbolt.org/z/6xbY5c4Mf
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.
Perfect. Will replace
substr
with: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.
std::string_view version = "most likely 201703";
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 have no idea if it compiles.