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

Fix incorrect "all" and "resource" definition for Schema File #3777

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Do not silently drop unknown schema data with `Parse` in `go.opentelemetry.io/otel/schema/v1.1`. (#3743)
- Data race issue in OTLP exporter retry mechanism. (#3756)
- Fixes wrapping a nil error in some cases (#????)
- Fix incorrect "all" and "resource" definition for Schema File (#3777)

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion schema/v1.0/ast/ast_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ type Attributes struct {

// AttributeChange corresponds to a section representing attribute changes.
type AttributeChange struct {
RenameAttributes *AttributeMap `yaml:"rename_attributes"`
RenameAttributes *RenameAttributes `yaml:"rename_attributes"`
}
50 changes: 27 additions & 23 deletions schema/v1.0/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,29 @@ func TestParseSchemaFile(t *testing.T) {
All: ast.Attributes{
Changes: []ast.AttributeChange{
{
RenameAttributes: &ast.AttributeMap{
"k8s.cluster.name": "kubernetes.cluster.name",
"k8s.namespace.name": "kubernetes.namespace.name",
"k8s.node.name": "kubernetes.node.name",
"k8s.node.uid": "kubernetes.node.uid",
"k8s.pod.name": "kubernetes.pod.name",
"k8s.pod.uid": "kubernetes.pod.uid",
"k8s.container.name": "kubernetes.container.name",
"k8s.replicaset.name": "kubernetes.replicaset.name",
"k8s.replicaset.uid": "kubernetes.replicaset.uid",
"k8s.cronjob.name": "kubernetes.cronjob.name",
"k8s.cronjob.uid": "kubernetes.cronjob.uid",
"k8s.job.name": "kubernetes.job.name",
"k8s.job.uid": "kubernetes.job.uid",
"k8s.statefulset.name": "kubernetes.statefulset.name",
"k8s.statefulset.uid": "kubernetes.statefulset.uid",
"k8s.daemonset.name": "kubernetes.daemonset.name",
"k8s.daemonset.uid": "kubernetes.daemonset.uid",
"k8s.deployment.name": "kubernetes.deployment.name",
"k8s.deployment.uid": "kubernetes.deployment.uid",
"service.namespace": "service.namespace.name",
RenameAttributes: &ast.RenameAttributes{
AttributeMap: ast.AttributeMap{
"k8s.cluster.name": "kubernetes.cluster.name",
"k8s.namespace.name": "kubernetes.namespace.name",
"k8s.node.name": "kubernetes.node.name",
"k8s.node.uid": "kubernetes.node.uid",
"k8s.pod.name": "kubernetes.pod.name",
"k8s.pod.uid": "kubernetes.pod.uid",
"k8s.container.name": "kubernetes.container.name",
"k8s.replicaset.name": "kubernetes.replicaset.name",
"k8s.replicaset.uid": "kubernetes.replicaset.uid",
"k8s.cronjob.name": "kubernetes.cronjob.name",
"k8s.cronjob.uid": "kubernetes.cronjob.uid",
"k8s.job.name": "kubernetes.job.name",
"k8s.job.uid": "kubernetes.job.uid",
"k8s.statefulset.name": "kubernetes.statefulset.name",
"k8s.statefulset.uid": "kubernetes.statefulset.uid",
"k8s.daemonset.name": "kubernetes.daemonset.name",
"k8s.daemonset.uid": "kubernetes.daemonset.uid",
"k8s.deployment.name": "kubernetes.deployment.name",
"k8s.deployment.uid": "kubernetes.deployment.uid",
"service.namespace": "service.namespace.name",
},
},
},
},
Expand All @@ -68,8 +70,10 @@ func TestParseSchemaFile(t *testing.T) {
Resources: ast.Attributes{
Changes: []ast.AttributeChange{
{
RenameAttributes: &ast.AttributeMap{
"telemetry.auto.version": "telemetry.auto_instr.version",
RenameAttributes: &ast.RenameAttributes{
AttributeMap: ast.AttributeMap{
"telemetry.auto.version": "telemetry.auto_instr.version",
},
},
},
},
Expand Down
54 changes: 28 additions & 26 deletions schema/v1.0/testdata/valid-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,43 @@ versions:
all:
changes:
- rename_attributes:
# Mapping of attribute names (label names for metrics). The key is the old name
# used prior to this version, the value is the new name starting from this version.
attribute_map:
# Mapping of attribute names (label names for metrics). The key is the old name
# used prior to this version, the value is the new name starting from this version.

# Rename k8s.* to kubernetes.*
k8s.cluster.name: kubernetes.cluster.name
k8s.namespace.name: kubernetes.namespace.name
k8s.node.name: kubernetes.node.name
k8s.node.uid: kubernetes.node.uid
k8s.pod.name: kubernetes.pod.name
k8s.pod.uid: kubernetes.pod.uid
k8s.container.name: kubernetes.container.name
k8s.replicaset.name: kubernetes.replicaset.name
k8s.replicaset.uid: kubernetes.replicaset.uid
k8s.cronjob.name: kubernetes.cronjob.name
k8s.cronjob.uid: kubernetes.cronjob.uid
k8s.job.name: kubernetes.job.name
k8s.job.uid: kubernetes.job.uid
k8s.statefulset.name: kubernetes.statefulset.name
k8s.statefulset.uid: kubernetes.statefulset.uid
k8s.daemonset.name: kubernetes.daemonset.name
k8s.daemonset.uid: kubernetes.daemonset.uid
k8s.deployment.name: kubernetes.deployment.name
k8s.deployment.uid: kubernetes.deployment.uid
# Rename k8s.* to kubernetes.*
k8s.cluster.name: kubernetes.cluster.name
k8s.namespace.name: kubernetes.namespace.name
k8s.node.name: kubernetes.node.name
k8s.node.uid: kubernetes.node.uid
k8s.pod.name: kubernetes.pod.name
k8s.pod.uid: kubernetes.pod.uid
k8s.container.name: kubernetes.container.name
k8s.replicaset.name: kubernetes.replicaset.name
k8s.replicaset.uid: kubernetes.replicaset.uid
k8s.cronjob.name: kubernetes.cronjob.name
k8s.cronjob.uid: kubernetes.cronjob.uid
k8s.job.name: kubernetes.job.name
k8s.job.uid: kubernetes.job.uid
k8s.statefulset.name: kubernetes.statefulset.name
k8s.statefulset.uid: kubernetes.statefulset.uid
k8s.daemonset.name: kubernetes.daemonset.name
k8s.daemonset.uid: kubernetes.daemonset.uid
k8s.deployment.name: kubernetes.deployment.name
k8s.deployment.uid: kubernetes.deployment.uid

service.namespace: service.namespace.name
service.namespace: service.namespace.name

# Like "all" the "resources" section may contain only attribute renaming translations.
# The only translation possible in this section is renaming of attributes in
# versions.
resources:
changes:
- rename_attributes:
# Mapping of attribute names. The key is the old name
# used prior to this version, the value is the new name starting from this version.
telemetry.auto.version: telemetry.auto_instr.version
attribute_map:
# Mapping of attribute names. The key is the old name
# used prior to this version, the value is the new name starting from this version.
telemetry.auto.version: telemetry.auto_instr.version

spans:
changes:
Expand Down
50 changes: 27 additions & 23 deletions schema/v1.1/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,29 @@ func TestParseSchemaFile(t *testing.T) {
All: ast10.Attributes{
Changes: []ast10.AttributeChange{
{
RenameAttributes: &ast10.AttributeMap{
"k8s.cluster.name": "kubernetes.cluster.name",
"k8s.namespace.name": "kubernetes.namespace.name",
"k8s.node.name": "kubernetes.node.name",
"k8s.node.uid": "kubernetes.node.uid",
"k8s.pod.name": "kubernetes.pod.name",
"k8s.pod.uid": "kubernetes.pod.uid",
"k8s.container.name": "kubernetes.container.name",
"k8s.replicaset.name": "kubernetes.replicaset.name",
"k8s.replicaset.uid": "kubernetes.replicaset.uid",
"k8s.cronjob.name": "kubernetes.cronjob.name",
"k8s.cronjob.uid": "kubernetes.cronjob.uid",
"k8s.job.name": "kubernetes.job.name",
"k8s.job.uid": "kubernetes.job.uid",
"k8s.statefulset.name": "kubernetes.statefulset.name",
"k8s.statefulset.uid": "kubernetes.statefulset.uid",
"k8s.daemonset.name": "kubernetes.daemonset.name",
"k8s.daemonset.uid": "kubernetes.daemonset.uid",
"k8s.deployment.name": "kubernetes.deployment.name",
"k8s.deployment.uid": "kubernetes.deployment.uid",
"service.namespace": "service.namespace.name",
RenameAttributes: &ast10.RenameAttributes{
AttributeMap: ast10.AttributeMap{
"k8s.cluster.name": "kubernetes.cluster.name",
"k8s.namespace.name": "kubernetes.namespace.name",
"k8s.node.name": "kubernetes.node.name",
"k8s.node.uid": "kubernetes.node.uid",
"k8s.pod.name": "kubernetes.pod.name",
"k8s.pod.uid": "kubernetes.pod.uid",
"k8s.container.name": "kubernetes.container.name",
"k8s.replicaset.name": "kubernetes.replicaset.name",
"k8s.replicaset.uid": "kubernetes.replicaset.uid",
"k8s.cronjob.name": "kubernetes.cronjob.name",
"k8s.cronjob.uid": "kubernetes.cronjob.uid",
"k8s.job.name": "kubernetes.job.name",
"k8s.job.uid": "kubernetes.job.uid",
"k8s.statefulset.name": "kubernetes.statefulset.name",
"k8s.statefulset.uid": "kubernetes.statefulset.uid",
"k8s.daemonset.name": "kubernetes.daemonset.name",
"k8s.daemonset.uid": "kubernetes.daemonset.uid",
"k8s.deployment.name": "kubernetes.deployment.name",
"k8s.deployment.uid": "kubernetes.deployment.uid",
"service.namespace": "service.namespace.name",
},
},
},
},
Expand All @@ -69,8 +71,10 @@ func TestParseSchemaFile(t *testing.T) {
Resources: ast10.Attributes{
Changes: []ast10.AttributeChange{
{
RenameAttributes: &ast10.AttributeMap{
"telemetry.auto.version": "telemetry.auto_instr.version",
RenameAttributes: &ast10.RenameAttributes{
AttributeMap: ast10.AttributeMap{
"telemetry.auto.version": "telemetry.auto_instr.version",
},
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion schema/v1.1/testdata/unsupported-file-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ versions:
all:
changes:
- rename_attributes:
k8s.cluster.name: kubernetes.cluster.name
attribute_map:
k8s.cluster.name: kubernetes.cluster.name
1.0.0:
54 changes: 28 additions & 26 deletions schema/v1.1/testdata/valid-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,43 @@ versions:
all:
changes:
- rename_attributes:
# Mapping of attribute names (label names for metrics). The key is the old name
# used prior to this version, the value is the new name starting from this version.
attribute_map:
# Mapping of attribute names (label names for metrics). The key is the old name
# used prior to this version, the value is the new name starting from this version.

# Rename k8s.* to kubernetes.*
k8s.cluster.name: kubernetes.cluster.name
k8s.namespace.name: kubernetes.namespace.name
k8s.node.name: kubernetes.node.name
k8s.node.uid: kubernetes.node.uid
k8s.pod.name: kubernetes.pod.name
k8s.pod.uid: kubernetes.pod.uid
k8s.container.name: kubernetes.container.name
k8s.replicaset.name: kubernetes.replicaset.name
k8s.replicaset.uid: kubernetes.replicaset.uid
k8s.cronjob.name: kubernetes.cronjob.name
k8s.cronjob.uid: kubernetes.cronjob.uid
k8s.job.name: kubernetes.job.name
k8s.job.uid: kubernetes.job.uid
k8s.statefulset.name: kubernetes.statefulset.name
k8s.statefulset.uid: kubernetes.statefulset.uid
k8s.daemonset.name: kubernetes.daemonset.name
k8s.daemonset.uid: kubernetes.daemonset.uid
k8s.deployment.name: kubernetes.deployment.name
k8s.deployment.uid: kubernetes.deployment.uid
# Rename k8s.* to kubernetes.*
k8s.cluster.name: kubernetes.cluster.name
k8s.namespace.name: kubernetes.namespace.name
k8s.node.name: kubernetes.node.name
k8s.node.uid: kubernetes.node.uid
k8s.pod.name: kubernetes.pod.name
k8s.pod.uid: kubernetes.pod.uid
k8s.container.name: kubernetes.container.name
k8s.replicaset.name: kubernetes.replicaset.name
k8s.replicaset.uid: kubernetes.replicaset.uid
k8s.cronjob.name: kubernetes.cronjob.name
k8s.cronjob.uid: kubernetes.cronjob.uid
k8s.job.name: kubernetes.job.name
k8s.job.uid: kubernetes.job.uid
k8s.statefulset.name: kubernetes.statefulset.name
k8s.statefulset.uid: kubernetes.statefulset.uid
k8s.daemonset.name: kubernetes.daemonset.name
k8s.daemonset.uid: kubernetes.daemonset.uid
k8s.deployment.name: kubernetes.deployment.name
k8s.deployment.uid: kubernetes.deployment.uid

service.namespace: service.namespace.name
service.namespace: service.namespace.name

# Like "all" the "resources" section may contain only attribute renaming translations.
# The only translation possible in this section is renaming of attributes in
# versions.
resources:
changes:
- rename_attributes:
# Mapping of attribute names. The key is the old name
# used prior to this version, the value is the new name starting from this version.
telemetry.auto.version: telemetry.auto_instr.version
attribute_map:
# Mapping of attribute names. The key is the old name
# used prior to this version, the value is the new name starting from this version.
telemetry.auto.version: telemetry.auto_instr.version

spans:
changes:
Expand Down