Skip to content

Commit

Permalink
Add attribute_group type to share attributes across signals (#124)
Browse files Browse the repository at this point in the history
Fixes #123

Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
  • Loading branch information
lmolkova and arminru committed Dec 13, 2022
1 parent 38470a0 commit 3b9a9d3
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 5 deletions.
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 generic attribute group ("attribute_group")
([#124](https://github.com/open-telemetry/build-tools/pull/124)).

## v0.14.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 @@ -52,7 +52,8 @@
"resource",
"metric",
"event",
"scope"
"scope",
"attribute_group"
],
"description": "The (signal) type of the semantic convention"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ class ScopeSemanticConvention(BaseSemanticConvention):
GROUP_TYPE_NAME = "scope"


class AttributeGroupConvention(BaseSemanticConvention):
GROUP_TYPE_NAME = "attribute_group"


class SpanSemanticConvention(BaseSemanticConvention):
GROUP_TYPE_NAME = "span"

Expand Down Expand Up @@ -531,5 +535,6 @@ def attributes(self):
MetricSemanticConvention,
UnitSemanticConvention,
ScopeSemanticConvention,
AttributeGroupConvention,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
groups:
- id: attributes
prefix: "foo"
type: attribute_group
brief: Attribute group
attributes:
- id: bar
type: string
requirement_level:
recommended: if available
brief: Attribute 1
examples: ['baz']

- id: derived_attributes
type: attribute_group
extends: attributes
prefix: "foo"
brief: Derived attribute group
attributes:
- id: qux
type: int
requirement_level:
conditionally_required: if available
brief: Attribute 2
examples: [42]

- id: span_attribute_group
prefix: ""
type: span
brief: A span
attributes:
- ref: foo.bar
- ref: foo.qux
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Attribute Group Example

<!-- semconv span_attribute_group -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `foo.bar` | string | Attribute 1 | `baz` | Recommended: if available |
| `foo.qux` | int | Attribute 2 | `42` | Conditionally Required: if available |
<!-- endsemconv -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Attribute Group Example

<!-- semconv span_attribute_group -->
<!-- endsemconv -->
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def testSamplingRelevant(self):
def test_scope(self):
self.check("markdown/scope/")

def test_attribute_group(self):
self.check("markdown/attribute_group/")

def check(
self,
input_dir: str,
Expand Down
13 changes: 10 additions & 3 deletions semantic-conventions/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ semconv ::= id [convtype] brief [note] [prefix] [extends] [stability] [deprecate
id ::= string
convtype ::= "span" # Default if not specified
| "resource" # see spanspecificfields
| "event" # see eventspecificfields
| "resource" # see spanfields
| "event" # see eventfields
| "metric" # (currently non-functional)
| "scope"
| "scope" # no specific fields defined
| "attribute_group" # no specific fields defined
brief ::= string
note ::= string
Expand Down Expand Up @@ -168,6 +169,12 @@ The following is only valid if `type` is `event`:
If not specified, the `prefix` is used. If `prefix` is empty (or unspecified),
`name` is required.

#### Attribute group semantic convention

Attribute group (`attribute_group` type) defines a set of attributes that can be
declared once and referenced by semantic conventions for different signals, for example spans and logs.
Attribute groups don't have any specific fields and follow the general `semconv` semantics.

### Attributes

An attribute is defined by:
Expand Down

0 comments on commit 3b9a9d3

Please sign in to comment.