Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scope semantic conventions as a type #114

Merged
merged 9 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion semantic-conventions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Please update the changelog as part of any significant pull request.

## Unreleased

- ...
- Add a semantic convention type for Instrumentation Scope ("scope")
([#114](https://github.com/open-telemetry/build-tools/pull/114)).

## v0.13.0

Expand Down
3 changes: 2 additions & 1 deletion semantic-conventions/semconv.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"span",
"resource",
"metric",
"event"
"event",
"scope"
],
"description": "The (signal) type of the semantic convention"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ class ResourceSemanticConvention(BaseSemanticConvention):
GROUP_TYPE_NAME = "resource"


class ScopeSemanticConvention(BaseSemanticConvention):
GROUP_TYPE_NAME = "scope"
dashpole marked this conversation as resolved.
Show resolved Hide resolved
dashpole marked this conversation as resolved.
Show resolved Hide resolved


class SpanSemanticConvention(BaseSemanticConvention):
GROUP_TYPE_NAME = "span"

Expand Down Expand Up @@ -541,5 +545,6 @@ def attributes(self):
EventSemanticConvention,
MetricSemanticConvention,
UnitSemanticConvention,
ScopeSemanticConvention,
)
}
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 |
|---|---|---|---|---|
| `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 -->
13 changes: 13 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,13 @@
groups:
- id: scope
prefix: ""
type: scope
brief: >
dashpole marked this conversation as resolved.
Show resolved Hide resolved
Instrumentation Scope attributes
attributes:
- id: short_name
type: string
requirement_level: recommended
brief: >
The single-word name for the instrumentation scope.
examples: ['mylibrary']
13 changes: 13 additions & 0 deletions semantic-conventions/src/tests/data/yaml/scope.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
groups:
- id: scope-id
prefix: ""
type: 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']
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,24 @@ 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-id",
"prefix": "",
"type": "scope",
"extends": "",
"brief": "Instrumentation Scope attributes",
"n_constraints": 0,
"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 test_scope(self):
self.check("markdown/scope/")

def check(
self,
input_dir: str,
Expand Down
1 change: 1 addition & 0 deletions semantic-conventions/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ convtype ::= "span" # Default if not specified
| "resource" # see spanspecificfields
| "event" # see eventspecificfields
| "metric" # (currently non-functional)
| "scope"

brief ::= string
note ::= string
Expand Down