-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Added static registration for http tracers. (#967) #994
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
485f5d3
Added static registration for http tracers. (#967)
mrice32 597a76f
Addresses review comments, PTAL.
mrice32 4963472
Corrected static initialization.
mrice32 402a4e9
Corrected formatting errors.
mrice32 7f59e9b
Modified static registration to use unordered_map
mrice32 050c7d0
Deprecated and added back list registration behavior for filters and …
mrice32 1090023
fixed formatting
mrice32 cb97780
Added tests to ensure deprecated registration style continues to work.
mrice32 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
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 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,46 @@ | ||
#include "server/config/http/lightstep_http_tracer.h" | ||
|
||
#include <string> | ||
|
||
#include "common/common/utility.h" | ||
#include "common/tracing/http_tracer_impl.h" | ||
#include "common/tracing/lightstep_tracer_impl.h" | ||
|
||
#include "lightstep/options.h" | ||
#include "lightstep/tracer.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
namespace Configuration { | ||
|
||
Tracing::HttpTracerPtr | ||
LightstepHttpTracerFactory::createHttpTracer(const Json::Object& json_config, | ||
Server::Instance& server, | ||
Upstream::ClusterManager& cluster_manager) { | ||
|
||
Envoy::Runtime::RandomGenerator& rand = server.random(); | ||
|
||
std::unique_ptr<lightstep::TracerOptions> opts(new lightstep::TracerOptions()); | ||
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. Please include lightstep/options.h and lightstep/tracer.h |
||
opts->access_token = server.api().fileReadToEnd(json_config.getString("access_token_file")); | ||
StringUtil::rtrim(opts->access_token); | ||
|
||
opts->tracer_attributes["lightstep.component_name"] = server.localInfo().clusterName(); | ||
opts->guid_generator = [&rand]() { return rand.random(); }; | ||
|
||
Tracing::DriverPtr lightstep_driver( | ||
new Tracing::LightStepDriver(json_config, cluster_manager, server.stats(), | ||
server.threadLocal(), server.runtime(), std::move(opts))); | ||
return Tracing::HttpTracerPtr( | ||
new Tracing::HttpTracerImpl(std::move(lightstep_driver), server.localInfo())); | ||
} | ||
|
||
std::string LightstepHttpTracerFactory::name() { return "lightstep"; } | ||
|
||
/** | ||
* Static registration for the lightstep http tracer. @see RegisterHttpTracerFactory. | ||
*/ | ||
static RegisterHttpTracerFactory<LightstepHttpTracerFactory> register_; | ||
|
||
} // Configuration | ||
} // Server | ||
} // Envoy |
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,27 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/server/instance.h" | ||
|
||
#include "server/configuration_impl.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
namespace Configuration { | ||
|
||
/** | ||
* Config registration for the lightstep tracer. @see HttpTracerFactory. | ||
*/ | ||
class LightstepHttpTracerFactory : public HttpTracerFactory { | ||
public: | ||
// HttpTracerFactory | ||
Tracing::HttpTracerPtr createHttpTracer(const Json::Object& json_config, Server::Instance& server, | ||
Upstream::ClusterManager& cluster_manager) override; | ||
|
||
std::string name() override; | ||
}; | ||
|
||
} // Configuration | ||
} // Server | ||
} // Envoy |
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
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.
Unrelated to the review, a question that came up recently while discussing filters with @alyssawilk. Why is Envoy filter config structured such that (1) filters know their
HttpFilterType
yet (2) the type is specified in the config as well, meaning we need to check consistency. It seems this could be elided from the config. The only thing I can think of is that some filters might work as encoder/decoder depending upon configuration... @RomanDzhabarov @ccaraman @junr03 for insight here.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.
@htuch cannot think about anything else, but fwiw, currently, no HTTP filters support this behavior.