Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig(
envoy::type::FractionalPercent random_sampling;
// TODO: Random sampling historically was an integer and default to out of 10,000. We should
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the TODO comment still relevant?

// deprecate that and move to a straight fractional percent config.
random_sampling.set_numerator(
tracing_config.has_random_sampling() ? tracing_config.random_sampling().value() : 10000);
uint64_t random_sampling_numerator{PROTOBUF_PERCENT_TO_ROUNDED_INTEGER_OR_DEFAULT(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my sanity...
if tracing_config().random_sampling().value() == 100 then This thing will return MAX_VALUE == 10000
which would set the numerator correctly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see the test that I added.

tracing_config, random_sampling, 10000, 10000)};
random_sampling.set_numerator(random_sampling_numerator);
random_sampling.set_denominator(envoy::type::FractionalPercent::TEN_THOUSAND);
envoy::type::FractionalPercent overall_sampling;
overall_sampling.set_numerator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,48 @@ TEST_F(HttpConnectionManagerConfigTest, SamplingConfigured) {
EXPECT_EQ(1, config.tracingConfig()->client_sampling_.numerator());
EXPECT_EQ(envoy::type::FractionalPercent::HUNDRED,
config.tracingConfig()->client_sampling_.denominator());
EXPECT_EQ(2, config.tracingConfig()->random_sampling_.numerator());
EXPECT_EQ(200, config.tracingConfig()->random_sampling_.numerator());
EXPECT_EQ(envoy::type::FractionalPercent::TEN_THOUSAND,
config.tracingConfig()->random_sampling_.denominator());
EXPECT_EQ(3, config.tracingConfig()->overall_sampling_.numerator());
EXPECT_EQ(envoy::type::FractionalPercent::HUNDRED,
config.tracingConfig()->overall_sampling_.denominator());
}

TEST_F(HttpConnectionManagerConfigTest, FractionalSamplingConfigured) {
const std::string yaml_string = R"EOF(
stat_prefix: ingress_http
internal_address_config:
unix_sockets: true
route_config:
name: local_route
tracing:
operation_name: ingress
client_sampling:
value: 0.1
random_sampling:
value: 0.2
overall_sampling:
value: 0.3
http_filters:
- name: envoy.router
)EOF";

HttpConnectionManagerConfig config(parseHttpConnectionManagerFromV2Yaml(yaml_string), context_,
date_provider_, route_config_provider_manager_,
scoped_routes_config_provider_manager_);

EXPECT_EQ(0, config.tracingConfig()->client_sampling_.numerator());
EXPECT_EQ(envoy::type::FractionalPercent::HUNDRED,
config.tracingConfig()->client_sampling_.denominator());
EXPECT_EQ(20, config.tracingConfig()->random_sampling_.numerator());
EXPECT_EQ(envoy::type::FractionalPercent::TEN_THOUSAND,
config.tracingConfig()->random_sampling_.denominator());
EXPECT_EQ(0, config.tracingConfig()->overall_sampling_.numerator());
EXPECT_EQ(envoy::type::FractionalPercent::HUNDRED,
config.tracingConfig()->overall_sampling_.denominator());
}

TEST_F(HttpConnectionManagerConfigTest, UnixSocketInternalAddress) {
const std::string yaml_string = R"EOF(
stat_prefix: ingress_http
Expand Down