Skip to content
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

chore: comment all logging as they for some reason leak into the application #22

Merged
merged 2 commits into from
Sep 12, 2024
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
23 changes: 12 additions & 11 deletions initializer/odigos_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Setup the Sampler logger
sampler_logger = logging.getLogger(__name__)
sampler_logger.setLevel(logging.DEBUG)
# sampler_logger.setLevel(logging.DEBUG)
# handler = logging.StreamHandler()
# sampler_logger.addHandler(handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) or handler)
sampler_logger.disabled = True # Comment this line to enable the logger
Expand Down Expand Up @@ -38,10 +38,10 @@ def _trace_id_based_sampling(self, trace_id, fraction):

def should_sample(self, parent_context, trace_id, name, kind, attributes, links):
with self._lock:
sampler_logger.debug(f'Running Should_sample a span with the following attributes: {attributes}')
# sampler_logger.debug(f'Running Should_sample a span with the following attributes: {attributes}')

if self._config is None:
sampler_logger.debug('No configuration is set, returning RECORD_AND_SAMPLE')
# sampler_logger.debug('No configuration is set, returning RECORD_AND_SAMPLE')
return SamplingResult(Decision.RECORD_AND_SAMPLE)

rules = self._config.get('attributesAndSamplerRules', [])
Expand All @@ -50,7 +50,7 @@ def should_sample(self, parent_context, trace_id, name, kind, attributes, links)
for rule in rules: # The first attribute rule that evaluates to true is used to determine the sampling decision based on its fraction.
and_attributes_sampler_rules = rule.get('attributeConditions', [])

sampler_logger.debug(f'"AND" rule operands are: {and_attributes_sampler_rules}')
# sampler_logger.debug(f'"AND" rule operands are: {and_attributes_sampler_rules}')

and_rule_fraction = rule.get('fraction', 1) # default to 1 if not set which means always sample
and_rule_met = True
Expand All @@ -68,25 +68,26 @@ def should_sample(self, parent_context, trace_id, name, kind, attributes, links)

# Perform the corresponding operation
if operator in self._operations and self._operations[operator](attributes[key], value):
sampler_logger.debug(f'Operator {operator} is true for the attribute {key} with value {value}')
# sampler_logger.debug(f'Operator {operator} is true for the attribute {key} with value {value}')
pass
else:
sampler_logger.debug(f'Operator {operator} is false, setting the "AND" rule flag to false')
# sampler_logger.debug(f'Operator {operator} is false, setting the "AND" rule flag to false')
and_rule_met = False
else:
sampler_logger.debug(f'Attribute {key} is not present in the span attributes, setting the "AND" rule flag to false')
# sampler_logger.debug(f'Attribute {key} is not present in the span attributes, setting the "AND" rule flag to false')
and_rule_met = False

if and_rule_met:
# Perform the sampling decision
if self._trace_id_based_sampling(trace_id, and_rule_fraction):
sampler_logger.debug(f'Trace [{trace_id}] is sampled "And rules" are met with fraction {and_rule_fraction}')
# sampler_logger.debug(f'Trace [{trace_id}] is sampled "And rules" are met with fraction {and_rule_fraction}')
return SamplingResult(Decision.RECORD_AND_SAMPLE)
else:
sampler_logger.debug(f'Trace [{trace_id}] is dropped "And rules" are met but fraction {and_rule_fraction} not met')
# sampler_logger.debug(f'Trace [{trace_id}] is dropped "And rules" are met but fraction {and_rule_fraction} not met')
return SamplingResult(Decision.DROP)

# Fallback to the global fraction if no rule matches
sampler_logger.debug(f'No rule matched, falling back to the global fraction {global_fraction}')
# sampler_logger.debug(f'No rule matched, falling back to the global fraction {global_fraction}')
if self._trace_id_based_sampling(trace_id, global_fraction):
return SamplingResult(Decision.RECORD_AND_SAMPLE)
else:
Expand All @@ -98,5 +99,5 @@ def get_description(self):

def update_config(self, new_config):
with self._lock:
sampler_logger.debug(f'Updating the configuration with the new configuration: {new_config}')
# sampler_logger.debug(f'Updating the configuration with the new configuration: {new_config}')
self._config = new_config
2 changes: 1 addition & 1 deletion opamp/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def worker(self):
self.condition.wait(30)

def send_heartbeat(self) -> opamp_pb2.ServerToAgent: # type: ignore
opamp_logger.debug("Sending heartbeat to OpAMP server...")
# opamp_logger.debug("Sending heartbeat to OpAMP server...")
try:
agent_to_server = opamp_pb2.AgentToServer(remote_config_status=self.remote_config_status)
return self.send_agent_to_server_message(agent_to_server)
Expand Down
Loading