Skip to content

Commit

Permalink
add tests for scope attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Jul 29, 2022
1 parent b2af318 commit 17ac5cd
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Instrumentation Scope Semantic Conventions

<!-- semconv scope -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `scope.short_name` | string | The single-word name for the instrumentation scope. | `mylibrary` | Recommended |
<!-- endsemconv -->
4 changes: 4 additions & 0 deletions semantic-conventions/src/tests/data/markdown/scope/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Instrumentation Scope Semantic Conventions

<!-- semconv scope -->
<!-- endsemconv -->
12 changes: 12 additions & 0 deletions semantic-conventions/src/tests/data/markdown/scope/scope.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
groups:
- id: scope
prefix: scope
brief: >
Instrumentation Scope attributes
attributes:
- id: short_name
type: string
requirement_level: recommended
brief: >
The single-word name for the instrumentation scope.
examples: ['mylibrary']
12 changes: 12 additions & 0 deletions semantic-conventions/src/tests/data/yaml/scope.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
groups:
- id: scope
prefix: scope
brief: >
Instrumentation Scope attributes
attributes:
- id: short_name
type: string
requirement_level: recommended
brief: >
The single-word name for the instrumentation scope.
examples: ['mylibrary']
15 changes: 15 additions & 0 deletions semantic-conventions/src/tests/semconv/model/test_correct_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,21 @@ def semantic_convention_check(self, s, expected):
self.assertEqual(expected["n_constraints"], len(s.constraints))
self.assertEqual(expected["attributes"], [a.fqn for a in s.attributes])

def test_scope_attribute(self):
semconv = SemanticConventionSet(debug=False)
semconv.parse(self.load_file("yaml/scope.yaml"))
self.assertEqual(len(semconv.models), 1)

expected = {
"id": "scope",
"prefix": "scope",
"brief": "Instrumentation Scope attributes",
"attributes": [
"short_name",
],
}
self.semantic_convention_check(list(semconv.models.values())[0], expected)

_TEST_DIR = os.path.dirname(__file__)

def load_file(self, filename):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def test_event_renamed(self):
def testSamplingRelevant(self):
self.check("markdown/sampling_relevant/")

def testScope(self):
self.check("markdown/scope/")

def check(
self,
input_dir: str,
Expand Down

0 comments on commit 17ac5cd

Please sign in to comment.