Skip to content

Commit b688e7a

Browse files
authored
[semconv] update template to remove deprecated semconv attributes (#10829)
This PR is updating the jinja template to ignore deprecated attributes as was done in open-telemetry/opentelemetry-go#5476. Additonally, generate v1.26.0 semconv package This replaces #10249 Fixes #10813 NOTE: This leaves empty resource/trace/event files, but I'd rather not remove the methods they expose in this change --------- Signed-off-by: Alex Boten <[email protected]>
1 parent 91d6525 commit b688e7a

File tree

9 files changed

+5415
-4
lines changed

9 files changed

+5415
-4
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: semconv
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add v1.26.0 semantic conventions package
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10249,10829]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

semconv/semconv_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ func TestAllSemConvFilesAreCrated(t *testing.T) {
2222
constraints, err := version.NewConstraint("> v1.16.0")
2323
assert.NoError(t, err)
2424

25+
attrgroupconstraints, err := version.NewConstraint("> v1.22.0")
26+
assert.NoError(t, err)
27+
2528
for _, f := range files {
2629
if !f.IsDir() {
2730
continue
@@ -37,6 +40,10 @@ func TestAllSemConvFilesAreCrated(t *testing.T) {
3740
expected[len(expected)-1] = "generated_event.go"
3841
}
3942

43+
if attrgroupconstraints.Check(ver) {
44+
assert.FileExists(t, filepath.Join(".", f.Name(), "generated_attribute_group.go"))
45+
}
46+
4047
for _, ef := range expected {
4148
assert.FileExists(t, filepath.Join(".", f.Name(), ef))
4249
}

semconv/template.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ Note: {{ attr.note | render_markdown(paragraph="{0}", code="{0}", link="{1}", em
4747
package semconv
4848

4949
{% for semconv in semconvs -%}
50-
{%- if semconvs[semconv].attributes | rejectattr("ref") | selectattr("is_local") | sort(attribute=fqn) | length > 0 -%}
50+
{%- if semconvs[semconv].attributes | rejectattr("ref") | rejectattr("deprecated") | selectattr("is_local") | sort(attribute=fqn) | length > 0 -%}
5151
// {{ sentence_case(semconvs[semconv].brief | replace("This document defines ", "")) | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
5252
const (
53-
{% for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
53+
{% for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated -%}
5454
// {{ godoc(attr) | wordwrap | indent(3) | replace(" ", "\t// ") | replace("// //", "//") }}
5555
Attribute{{to_go_name(attr.fqn)}} = "{{attr.fqn}}"
5656
{% endfor %}
5757
)
58-
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
58+
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated -%}
5959
{%- if attr.attr_type is not string %}
6060

6161
const (
@@ -73,7 +73,7 @@ const (
7373
func Get{{ conventionType | title }}SemanticConventionAttributeNames() []string {
7474
return []string{
7575
{% for semconv in semconvs -%}
76-
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref -%}
76+
{%- for attr in semconvs[semconv].attributes if attr.is_local and not attr.ref and not attr.deprecated -%}
7777
Attribute{{to_go_name(attr.fqn)}},
7878
{% endfor %}
7979
{%- endfor %}

semconv/v1.26.0/doc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Package semconv implements OpenTelemetry semantic conventions.
5+
//
6+
// OpenTelemetry semantic conventions are agreed standardized naming
7+
// patterns for OpenTelemetry things. This package represents the v1.26.0
8+
// version of the OpenTelemetry semantic conventions.
9+
package semconv // import "go.opentelemetry.io/collector/semconv/v1.26.0"

0 commit comments

Comments
 (0)