Skip to content

Commit bbdf107

Browse files
committed
custom dql syntax highlighting support
1 parent 123ac38 commit bbdf107

File tree

7 files changed

+157
-80
lines changed

7 files changed

+157
-80
lines changed

docs/07-operation-guide/01-setup.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The default directory for configuration files is named **config/**. This directo
2828
* Availability Zone File: If an availability zone is specified (either through the `$CADENCE_AVAILABILITY_ZONE` environment variable or as a command-line argument), a file named after the zone will be merged. For example, if you specify "az1" as the zone, `production_az1.yaml` will be used as well.
2929

3030
To merge `base.yaml`, `production.yaml`, and `production_az1.yaml` files, you need to specify "production" as the runtime environment and "az1" as the zone.
31-
```
31+
```log
3232
// base.yaml -> production.yaml -> production_az1.yaml = final configuration
3333
```
3434

@@ -115,7 +115,7 @@ For example, search for "EnableGlobalDomain" in Dynamic Configuration [Comments
115115
* `N/A` means no filters can be set. The config will be global.
116116

117117
For example, if you want to change the ratelimiting for List API, below is the config:
118-
```
118+
```clike
119119
// FrontendVisibilityListMaxQPS is max qps frontend can list open/close workflows
120120
// KeyName: frontend.visibilityListMaxQPS
121121
// Value type: Int
@@ -152,9 +152,9 @@ By default, Cadence uses file-based client to manage dynamic configurations. Fol
152152
cadence:
153153
image: ubercadence/server:master-auto-setup
154154
ports:
155-
...(don't change anything here)
155+
# ...(don't change anything here)
156156
environment:
157-
...(don't change anything here)
157+
# ...(don't change anything here)
158158
- "DYNAMIC_CONFIG_FILE_PATH=/etc/custom-dynamicconfig/development.yaml"
159159
volumes:
160160
- "/Users/<?>/cadence/config/dynamicconfig:/etc/custom-dynamicconfig"
@@ -175,7 +175,7 @@ After restarting Cadence instances, execute a command like this to let Cadence l
175175
`cadence --domain <> workflow list`
176176

177177
Then you should see the logs like below
178-
```
178+
```log
179179
cadence_1 | {"level":"info","ts":"2021-05-07T18:43:07.869Z","msg":"First loading dynamic config","service":"cadence-frontend","key":"frontend.visibilityListMaxQPS,domainName:sample,clusterName:primary","value":"10000","default-value":"10","logging-call-at":"config.go:93"}
180180
```
181181

docs/07-operation-guide/02-maintain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ There are a few things to know when using this feature:
3838
* Because of above, when scaling down the number of partitions, you must decrease the WritePartitions first, to wait for a certain time to ensure that tasks are drained, and then decrease ReadPartitions.
3939
* Both domain names and taskListName should be specified in the dynamic config. An example of using this feature. See more details about dynamic config format using file based [dynamic config](/docs/operation-guide/setup/#static-configuration).
4040

41-
```
41+
```yaml
4242
matching.numTasklistWritePartitions:
4343
- value: 10
4444
constraints:

docs/07-operation-guide/03-monitoring.md

Lines changed: 64 additions & 64 deletions
Large diffs are not rendered by default.

docs/07-operation-guide/05-migration.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,44 +129,44 @@ cadence --address <currentClusterAddress> --do <domain_name> domain update --clu
129129

130130
Run the command below to refresh the domain after adding a new cluster to the cluster list; we need to update the active_cluster to the same value that it appears to be.
131131

132-
```
132+
```bash
133133
cadence --address <currentClusterAddress> --do <domain_name> domain update --active_cluster <currentClusterName>
134134
```
135135

136136

137137
* 2.2 failover the domain to be active in new cluster
138-
```
138+
```bash
139139
cadence --address <currentClusterAddress> --do workflow-prototype domain update --active_cluster <newClusterName>
140140
```
141141

142142
Use the domain describe command to verify the entire domain is replicated to the new cluster.
143143

144-
```
144+
```bash
145145
cadence --address <newClusterAddress> --do <domain_name> domain describe
146146
```
147147
Find an open workflowID that we want to replicate (you can get it from the UI). Use this command to describe it to make sure it’s open and running:
148148

149-
```
149+
```bash
150150
cadence --address <initialClusterAddress> --do <domain_name> workflow describe --workflow_id <wfID>
151151
```
152152
Run a signal command against any workflow and check that it was replicated to the new cluster. Example:
153153

154-
```
154+
```bash
155155
cadence --address <initialClusterAddress> --do <domain_name> workflow signal --workflow_id <wfID> --name <anything not functional, e.g. replicationTriggeringSignal>
156156
```
157157
This command will send a noop signal to workflows to trigger a decision, which will trigger history replication if needed.
158158

159159

160160
Verify the workflow is replicated in the new cluster
161-
```
161+
```bash
162162
cadence --address <newClusterAddress> --st <adminOperationToken> --do <domain_name> workflow describe --workflow_id <wfID>
163163
```
164164
Also compare the history between the two clusters:
165-
```
165+
```bash
166166
cadence --address <newClusterAddress> --do <domain_name> workflow show --workflow_id <wfID>
167167
```
168168

169-
```
169+
```bash
170170
cadence --address <initialClusterAddress> --do <domain_name> workflow show --workflow_id <wfID>
171171
```
172172

@@ -178,7 +178,7 @@ You can repeat Step 2 for all the domains. Or you can use the managed failover f
178178
Because replication cannot be triggered without a decision. Again best way is to send a garbage signal to all the workflows.
179179

180180
If advanced visibility is enabled, then use batch signal command to start a batch job to trigger replication for all open workflows:
181-
```
181+
```bash
182182
cadence --address <initialClusterAddress> --do <domain_name> workflow batch start --batch_type signal --query “CloseTime = missing” --signal_name <anything, e.g. xdcTest> --reason <anything> --input <anything> --yes
183183
```
184184

@@ -193,7 +193,7 @@ A few things need to do in order to shutdown the old cluster.
193193
* Migrate all applications to connect to the frontend of new cluster instead of relying on the forwarding
194194
* Watch metric dashboard to make sure no any traffic is happening on the old cluster
195195
* Delete the old cluster from domain cluster list. This needs to be done for every domain.
196-
```
196+
```bash
197197
cadence --address <newHostAddress> --do <domain_name> domain update --clusters <newClusterName>
198198
```
199199
* Delete the old cluster from the configuration of the new cluster.

docusaurus.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ const config: Config = {
303303
prism: {
304304
theme: prismThemes.github,
305305
darkTheme: prismThemes.dracula,
306+
additionalLanguages: ['go', 'java', 'bash', 'markup', 'json', 'shell-session', 'yaml', 'gradle', 'log',],
307+
306308
},
307309
} satisfies Preset.ThemeConfig,
308310
};

src/theme/prism-dql.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Prism.languages.dql = {
2+
// For token definitions: https://prismjs.com/tokens.html
3+
// Syntax highlighting for DQL (Data Query Language) used in the DataDog logs
4+
'comment': [
5+
{
6+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
7+
lookbehind: true,
8+
greedy: true
9+
},
10+
{
11+
pattern: /(^|[^\\:])\/\/.*/,
12+
lookbehind: true,
13+
greedy: true
14+
}
15+
],
16+
'string': {
17+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
18+
greedy: true
19+
},
20+
'class-name': {
21+
pattern: /(\b(?:env|service|operation_name|resource_name|status|ingestion_reason|trace_id)\s+|\bcatch\s+\()[\w.\\]+/i,
22+
lookbehind: true,
23+
inside: {
24+
'punctuation': /[.\\]/
25+
}
26+
},
27+
'entity': /\b(?:env|service|operation_name|resource_name|status|ingestion_reason|trace_id)\b/,
28+
'keyword': /\b(?:by|in|and|not|count|count\sby|stddev|p\d\d)\b/i,
29+
'boolean': /\b(?:false|true)\b/i,
30+
'function': /(\b\w+(?=\())|(\w+(?=:))/,
31+
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?!\d*percentile)(?:e[+-]?\d+)?/i,
32+
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]|->|=>/i,
33+
'punctuation': /[{}[\];(),.:]/,
34+
'builtin': {
35+
pattern: /\b(\d{2}percentile)\b|\b(avg|max|min|sum|set|median|count|is_greater|is_less|is_between|quantile)\b/i,
36+
},
37+
'variable': /\$+(?:\w+\b|(?=\{))/,
38+
};
39+
40+
Prism.languages.insertBefore('dql', 'operator', {
41+
'literal-property': {
42+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
43+
lookbehind: true,
44+
alias: 'property'
45+
},
46+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import siteConfig from '@generated/docusaurus.config';
2+
export default function prismIncludeLanguages(PrismObject) {
3+
const {
4+
themeConfig: { prism },
5+
} = siteConfig;
6+
const { additionalLanguages } = prism;
7+
// Prism components work on the Prism instance on the window, while prism-
8+
// react-renderer uses its own Prism instance. We temporarily mount the
9+
// instance onto window, import components to enhance it, then remove it to
10+
// avoid polluting global namespace.
11+
// You can mutate PrismObject: registering plugins, deleting languages... As
12+
// long as you don't re-assign it
13+
const PrismBefore = globalThis.Prism;
14+
globalThis.Prism = PrismObject;
15+
additionalLanguages.forEach((lang) => {
16+
if (lang === 'php') {
17+
// eslint-disable-next-line global-require
18+
require('prismjs/components/prism-markup-templating.js');
19+
}
20+
// eslint-disable-next-line global-require, import/no-dynamic-require
21+
require(`prismjs/components/prism-${lang}`);
22+
});
23+
require('./prism-dql.js')
24+
// Clean up and eventually restore former globalThis.Prism object (if any)
25+
delete globalThis.Prism;
26+
if (typeof PrismBefore !== 'undefined') {
27+
globalThis.Prism = PrismObject;
28+
}
29+
}

0 commit comments

Comments
 (0)