forked from open-telemetry/semantic-conventions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check attribute/metric/event name format (open-telemetry#1302)
- Loading branch information
Showing
7 changed files
with
176 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
change_type: enhancement | ||
component: docs | ||
note: Add note on tooling limitations for attribute names and enforce name format. | ||
issues: [1124] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package after_resolution | ||
import future.keywords | ||
|
||
test_fails_on_const_name_collision if { | ||
collision := {"groups": [ | ||
{"id": "test1", "attributes": [{"name": "foo.bar.baz"}]}, | ||
{"id": "test2", "attributes": [{"name": "foo.bar_baz"}]} | ||
]} | ||
# each attribute counts as a collision, so there are 2 collisions | ||
count(deny) == 2 with input as collision | ||
} | ||
|
||
test_fails_on_namespace_collision if { | ||
collision := {"groups": [ | ||
{"id": "test1", "attributes": [{"name": "foo.bar.baz"}]}, | ||
{"id": "test2", "attributes": [{"name": "foo.bar"}]} | ||
]} | ||
count(deny) == 1 with input as collision | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package before_resolution | ||
|
||
import future.keywords | ||
|
||
test_fails_on_invalid_attribute_name if { | ||
every name in invalid_names { | ||
count(deny) == 1 with input as {"groups": create_attribute_group(name)} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_metric_name if { | ||
every name in invalid_names { | ||
count(deny) == 1 with input as {"groups": create_metric(name)} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_event_name if { | ||
every name in invalid_names { | ||
count(deny) == 1 with input as {"groups": create_event(name)} | ||
} | ||
} | ||
|
||
test_passes_on_valid_names if { | ||
every name in valid_names { | ||
count(deny) == 0 with input as {"groups": create_attribute_group(name)} | ||
count(deny) == 0 with input as {"groups": create_metric(name)} | ||
count(deny) == 0 with input as {"groups": create_event(name)} | ||
} | ||
} | ||
|
||
test_fails_if_prefix_is_present if { | ||
count(deny) == 1 with input as {"groups": [{"id": "test", "prefix": "foo"}]} | ||
} | ||
|
||
create_attribute_group(attr) = json { | ||
json := [{"id": "yaml_schema.test", "attributes": [{"id": attr}]}] | ||
} | ||
|
||
create_metric(name) = json { | ||
json := [{"id": "yaml_schema.test", "type": "metric", "metric_name": name}] | ||
} | ||
|
||
create_event(name) = json { | ||
json := [{"id": "yaml_schema.test", "type": "event", "name": name}] | ||
} | ||
|
||
invalid_names := [ | ||
"1foo.bar", | ||
"_foo.bar", | ||
".foo.bar", | ||
"foo.bar_", | ||
"foo.bar.", | ||
"foo..bar", | ||
"foo._bar", | ||
"foo__bar", | ||
"foo_.bar", | ||
"foo,bar", | ||
"fü.bär", | ||
] | ||
|
||
valid_names := [ | ||
"foo.bar", | ||
"foo.1bar", | ||
"foo_1.bar", | ||
"foo.bar.baz", | ||
"foo.bar_baz", | ||
] |