Skip to content

Commit bed7174

Browse files
Wen Kokkewenkokke
authored andcommitted
refactor(eventlog-live-otelcol): use YAML anchors to define defaults
1 parent e641247 commit bed7174

File tree

3 files changed

+74
-38
lines changed

3 files changed

+74
-38
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"yaml.schemas": {
3+
"./eventlog-live-otelcol/data/config.schema.json": "./eventlog-live-otelcol/data/default.yaml"
4+
}
5+
}

eventlog-live-otelcol/data/config.schema.json

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"processors": {
88
"type": "object",
99
"properties": {
10+
"defaults": { "#ref": "#/definitions/processor_defaults" },
1011
"metrics": {
1112
"type": "object",
1213
"properties": {
14+
"defaults": { "#ref": "#/definitions/metric_defaults" },
1315
"blocks_size": { "$ref": "#/definitions/metric" },
1416
"capability_usage": { "$ref": "#/definitions/metric" },
1517
"heap_allocated": { "$ref": "#/definitions/metric" },
@@ -19,14 +21,17 @@
1921
"mem_current": { "$ref": "#/definitions/metric" },
2022
"mem_needed": { "$ref": "#/definitions/metric" },
2123
"mem_returned": { "$ref": "#/definitions/metric" }
22-
}
24+
},
25+
"additionalProperties": false
2326
},
2427
"traces": {
2528
"type": "object",
2629
"properties": {
27-
"capability_usage": { "$ref": "#/definitions/span" },
28-
"thread_state": { "$ref": "#/definitions/span" }
29-
}
30+
"defaults": { "#ref": "#/definitions/trace_defaults" },
31+
"capability_usage": { "$ref": "#/definitions/trace" },
32+
"thread_state": { "$ref": "#/definitions/trace" }
33+
},
34+
"additionalProperties": false
3035
}
3136
}
3237
}
@@ -60,27 +65,46 @@
6065
"type": "string",
6166
"pattern": "^([0-9]+)(x)$"
6267
},
63-
"processor": {
64-
"type": "object",
68+
"processor_defaults": {
69+
"description": "An optional 'defaults' block for defining YAML anchors.",
6570
"properties": {
66-
"description": { "type": "string" },
67-
"enabled": { "type": "boolean" },
6871
"export": { "$ref": "#/definitions/export_strategy" },
69-
"name": { "type": "string" }
70-
}
72+
"aggregate": { "$ref": "#/definitions/aggregation_strategy" }
73+
},
74+
"additionalProperties": false
7175
},
7276
"metric": {
73-
"allOf": [
74-
{ "$ref": "#/definitions/processor" },
75-
{
76-
"properties": {
77-
"aggregate": { "$ref": "#/definitions/aggregation_strategy" }
78-
}
79-
}
80-
]
77+
"properties": {
78+
"name": { "type": "string" },
79+
"description": { "type": "string" },
80+
"export": { "$ref": "#/definitions/export_strategy" },
81+
"aggregate": { "$ref": "#/definitions/aggregation_strategy" }
82+
},
83+
"additionalProperties": false
8184
},
82-
"span": {
83-
"allOf": [{ "$ref": "#/definitions/processor" }]
85+
"metric_defaults": {
86+
"description": "An optional 'defaults' block for defining YAML anchors.",
87+
"properties": {
88+
"export": { "$ref": "#/definitions/export_strategy" },
89+
"aggregate": { "$ref": "#/definitions/aggregation_strategy" }
90+
},
91+
"additionalProperties": false
92+
},
93+
"trace": {
94+
"properties": {
95+
"name": { "type": "string" },
96+
"description": { "type": "string" },
97+
"export": { "$ref": "#/definitions/export_strategy" }
98+
},
99+
"additionalProperties": false
100+
},
101+
"trace_defaultss": {
102+
"description": "An optional 'defaults' block for defining YAML anchors.",
103+
"properties": {
104+
"export": { "$ref": "#/definitions/export_strategy" },
105+
"aggregate": { "$ref": "#/definitions/aggregation_strategy" }
106+
},
107+
"additionalProperties": false
84108
}
85109
}
86110
}

eventlog-live-otelcol/data/default.yaml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,51 +49,58 @@
4949
#
5050
processors:
5151
metrics:
52+
defaults:
53+
aggregate:
54+
# one of [boolean, `${number}x`]
55+
&default_aggregate 1x
56+
export:
57+
# one of [boolean, `${number}x`]
58+
&default_export 60x
5259
blocks_size:
5360
name: ghc_eventlog_BlocksSize
5461
description: The current heap size, calculated by the allocated number of blocks.
55-
aggregate: 1x # one of [boolean, `${number}x`]
56-
export: 60x # one of [boolean, `${number}x`]
62+
aggregate: *default_aggregate
63+
export: *default_export
5764
capability_usage:
5865
name: ghc_eventlog_CapabilityUsageDuration
5966
description: The duration of each capability usage span.
60-
aggregate: 1x # one of [boolean, `${number}x`]
61-
export: 60x # one of [boolean, `${number}x`]
67+
aggregate: *default_aggregate
68+
export: *default_export
6269
heap_allocated:
6370
name: ghc_eventlog_HeapAllocated
6471
description: The size of a newly allocated chunk of heap.
65-
aggregate: 1x # one of [boolean, `${number}x`]
66-
export: 60x # one of [boolean, `${number}x`]
72+
aggregate: *default_aggregate
73+
export: *default_export
6774
heap_live:
6875
name: ghc_eventlog_HeapLive
6976
description: The current heap size, calculated by the allocated number of megablocks.
70-
aggregate: 1x # one of [boolean, `${number}x`]
71-
export: 60x # one of [boolean, `${number}x`]
77+
aggregate: *default_aggregate
78+
export: *default_export
7279
heap_prof_sample:
7380
name: ghc_eventlog_HeapProfSample
7481
description: A heap profile sample.
75-
aggregate: 1x # one of [boolean, `${number}x`]
76-
export: 60x # one of [boolean, `${number}x`]
82+
aggregate: *default_aggregate
83+
export: *default_export
7784
heap_size:
7885
name: ghc_eventlog_HeapSize
7986
description: The current heap size, calculated by the allocated number of megablocks.
80-
aggregate: 1x # one of [boolean, `${number}x`]
81-
export: 60x # one of [boolean, `${number}x`]
87+
aggregate: *default_aggregate
88+
export: *default_export
8289
mem_current:
8390
name: ghc_eventlog_MemCurrent
8491
description: The number of megablocks currently allocated.
85-
aggregate: 1x # one of [boolean, `${number}x`]
86-
export: 60x # one of [boolean, `${number}x`]
92+
aggregate: *default_aggregate
93+
export: *default_export
8794
mem_needed:
8895
name: ghc_eventlog_MemNeeded
8996
description: The number of megablocks currently needed.
90-
aggregate: 1x # one of [boolean, `${number}x`]
91-
export: 60x # one of [boolean, `${number}x`]
97+
aggregate: *default_aggregate
98+
export: *default_export
9299
mem_returned:
93100
name: ghc_eventlog_MemReturned
94101
description: The number of megablocks currently being returned to the OS.
95-
aggregate: 1x # one of [boolean, `${number}x`]
96-
export: 60x # one of [boolean, `${number}x`]
102+
aggregate: *default_aggregate
103+
export: *default_export
97104
traces:
98105
capability_usage:
99106
name: ghc_eventlog_CapabilityUsage

0 commit comments

Comments
 (0)