Skip to content

Commit 11b5785

Browse files
Merge pull request #686 from karle-nishi/add-query-tags
Added query tags depending upon Simple Replay or Node Config
2 parents ca79aea + 66e7ef6 commit 11b5785

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/SimpleReplay/replay.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@
6868

6969
g_is_serverless = False
7070

71-
g_serverless_cluster_endpoint_pattern = r"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.amazonaws\.com:[0-9]{4,5}\/(.)+"
72-
g_cluster_endpoint_pattern = r"(.+)\.(.+)\.(.+).redshift(-serverless)?\.amazonaws\.com:[0-9]{4,5}\/(.)+"
71+
g_serverless_cluster_endpoint_pattern = (
72+
r"(.+)\.(.+)\.(.+).redshift-serverless(-dev)?\.amazonaws\.com:[0-9]{4,5}\/(.)+"
73+
)
74+
g_cluster_endpoint_pattern = (
75+
r"(.+)\.(.+)\.(.+).redshift(-serverless)?\.amazonaws\.com:[0-9]{4,5}\/(.)+"
76+
)
7377

7478

7579
class ConnectionLog:
@@ -393,11 +397,15 @@ def save_query_stats(self, starttime, endtime, xid, query_idx):
393397
)
394398

395399
def get_tagged_sql(self, query_text, idx, transaction, connection):
396-
json_tags = {
397-
"xid": transaction.xid,
398-
"query_idx": idx,
399-
"replay_start": g_replay_timestamp.isoformat(),
400-
}
400+
if g_config.get("source_tag", None):
401+
json_tags = {
402+
"xid": transaction.xid,
403+
"query_idx": idx,
404+
"replay_start": g_replay_timestamp.isoformat(),
405+
"source": g_config.get('source_tag', 'SimpleReplay'),
406+
}
407+
408+
401409
return "/* {} */ {}".format(json.dumps(json_tags), query_text)
402410

403411
def execute_transaction(self, transaction, connection):
@@ -2262,7 +2270,7 @@ def init_manager():
22622270
logger.info(
22632271
f"Replay finished in {datetime.datetime.now(tz=datetime.timezone.utc) - g_replay_timestamp}."
22642272
)
2265-
2273+
22662274
if g_config.get("analysis_iam_role") and g_config.get("analysis_output"):
22672275
try:
22682276
run_replay_analysis(

src/SimpleReplay/replay.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Optional - Custom identifier for this replay run
22
tag: ""
33

4+
# Optional - Identifier for queries executed
5+
source_tag: ""
6+
47
# Directory location of extracted workload, relative to current directory
58
workload_location: ""
69

710
# Endpoint and username of target cluster to replay queries on
811
target_cluster_endpoint: "host:port/database"
912
target_cluster_region: ""
1013
master_username: ""
11-
1214
# NLB or NAT endpoint for Simple Replay to connect to. This NLB or NAT should have connectivity to target_cluster_endpoint
1315
nlb_nat_dns: ""
1416

@@ -42,7 +44,7 @@ replay_output: ""
4244
analysis_output: ""
4345

4446
# Optional - Leaving this blank means UNLOADs will not be replayed. IAM role for UNLOADs to be performed with.
45-
unload_iam_role: ""
47+
unload_iam_role: ""
4648

4749
# Optional - Leaving this blank means analysis will not be run. IAM role for analysis needs UNLOAD access.
4850
analysis_iam_role: ""
@@ -71,7 +73,7 @@ filters:
7173
##
7274

7375
# Set the amount of logging
74-
log_level: "info"
76+
log_level: "INFO"
7577

7678
# number of proceses to use to parallelize the work. If omitted or null, uses
7779
# one process per cpu - 1
@@ -95,4 +97,4 @@ split_multi: true
9597

9698
# In case of Serverless, set up a secret to store admin username and password. Specify the name of the secret below
9799
# Note: This admin username maps to the username specified as `master_username` in this file. This will be updated to `admin_username` in a future release.
98-
secret_name: ""
100+
secret_name: ""

0 commit comments

Comments
 (0)