Skip to content

Commit

Permalink
Fixes based on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrannajaryan committed Oct 5, 2021
1 parent 6a62176 commit f82962e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 47 deletions.
23 changes: 9 additions & 14 deletions schema/v1.0/ast/ast_schema.go
Expand Up @@ -36,26 +36,21 @@ type Schema struct {
// VersionDef corresponds to a section representing one version under the "versions"
// top-level key.
type VersionDef struct {
All VersionOfAttributes
Resources VersionOfAttributes
Spans VersionOfSpans
SpanEvents VersionOfSpanEvents `yaml:"span_events"`
Logs VersionOfLogs
Metrics VersionOfMetrics
All Attributes
Resources Attributes
Spans Spans
SpanEvents SpanEvents `yaml:"span_events"`
Logs Logs
Metrics Metrics
}

// VersionOfAttributes corresponds to a section representing a list of changes that
// Attributes corresponds to a section representing a list of changes that
// happened in a particular version.
type VersionOfAttributes struct {
type Attributes struct {
Changes []AttributeChanges
}

// AttributeChanges corresponds to a section representing attribute changes.
type AttributeChanges struct {
RenameAttributes *MappingOfAttributes `yaml:"rename_attributes"`
RenameAttributes *AttributeMap `yaml:"rename_attributes"`
}

// MappingOfAttributes corresponds to a section representing a mapping of attribute names.
// The keys are the old attribute name used the previous version, the values are the
// new attribute name starting from this version.
type MappingOfAttributes map[string]string
25 changes: 25 additions & 0 deletions schema/v1.0/ast/common.go
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ast // import "go.opentelemetry.io/otel/schema/v1.0/ast"

// RenameAttributes corresponds to a section that describes attribute renaming.
type RenameAttributes struct {
AttributeMap AttributeMap `yaml:"attribute_map"`
}

// AttributeMap corresponds to a section representing a mapping of attribute names.
// The keys are the old attribute name used in the previous version, the values are the
// new attribute name starting from this version.
type AttributeMap map[string]string
10 changes: 3 additions & 7 deletions schema/v1.0/ast/logs.go
Expand Up @@ -14,17 +14,13 @@

package ast // import "go.opentelemetry.io/otel/schema/v1.0/ast"

// VersionOfLogs corresponds to a section representing a list of changes that happened
// Logs corresponds to a section representing a list of changes that happened
// to logs schema in a particular version.
type VersionOfLogs struct {
type Logs struct {
Changes []LogsChange
}

// LogsChange corresponds to a section representing logs change.
type LogsChange struct {
RenameAttributes *RenameLogAttributes `yaml:"rename_attributes"`
}

type RenameLogAttributes struct {
AttributeMap map[string]string `yaml:"attribute_map"`
RenameAttributes *RenameAttributes `yaml:"rename_attributes"`
}
12 changes: 6 additions & 6 deletions schema/v1.0/ast/metrics.go
Expand Up @@ -16,19 +16,19 @@ package ast // import "go.opentelemetry.io/otel/schema/v1.0/ast"

import "go.opentelemetry.io/otel/schema/v1.0/types"

// VersionOfMetrics corresponds to a section representing a list of changes that happened
// Metrics corresponds to a section representing a list of changes that happened
// to metrics schema in a particular version.
type VersionOfMetrics struct {
type Metrics struct {
Changes []MetricsChange
}

// MetricsChange corresponds to a section representing metrics change.
type MetricsChange struct {
RenameMetrics map[types.MetricName]types.MetricName `yaml:"rename_metrics"`
RenameLabels *LabelMapForMetrics `yaml:"rename_labels"`
RenameMetrics map[types.MetricName]types.MetricName `yaml:"rename_metrics"`
RenameAttributes *AttributeMapForMetrics `yaml:"rename_labels"`
}

type LabelMapForMetrics struct {
type AttributeMapForMetrics struct {
ApplyToMetrics []types.MetricName `yaml:"apply_to_metrics"`
LabelMap map[string]string `yaml:"label_map"`
AttributeMap AttributeMap `yaml:"label_map"`
}
14 changes: 5 additions & 9 deletions schema/v1.0/ast/spans.go
Expand Up @@ -16,21 +16,21 @@ package ast // import "go.opentelemetry.io/otel/schema/v1.0/ast"

import "go.opentelemetry.io/otel/schema/v1.0/types"

// VersionOfSpans corresponds to a section representing a list of changes that happened
// Spans corresponds to a section representing a list of changes that happened
// to spans schema in a particular version.
type VersionOfSpans struct {
type Spans struct {
Changes []SpansChange
}

// VersionOfSpanEvents corresponds to a section representing a list of changes that happened
// SpanEvents corresponds to a section representing a list of changes that happened
// to span events schema in a particular version.
type VersionOfSpanEvents struct {
type SpanEvents struct {
Changes []SpanEventsChange
}

// SpansChange corresponds to a section representing spans change.
type SpansChange struct {
RenameAttributes *RenameSpanAttributes `yaml:"rename_attributes"`
RenameAttributes *RenameAttributes `yaml:"rename_attributes"`
}

// SpanEventsChange corresponds to a section representing span events change.
Expand All @@ -39,10 +39,6 @@ type SpanEventsChange struct {
RenameAttributes *RenameSpanEventAttributes `yaml:"rename_attributes"`
}

type RenameSpanAttributes struct {
AttributeMap map[string]string `yaml:"attribute_map"`
}

type RenameSpanEvents struct {
EventNameMap map[string]string `yaml:"name_map"`
}
Expand Down
11 changes: 0 additions & 11 deletions schema/v1.0/testdata/valid-example.yaml
Expand Up @@ -120,19 +120,8 @@ versions:

logs:
changes:
- rename_logs:
# map of key/values. The keys are the old log name used
# the previous version, the values are the new log name
# starting from this version.
ProcessStarted: otel.process.started
- rename_attributes:
attribute_map:
process.executable_name: process.executable.name
apply_to_logs:
# Optional. If it is missing the transformation is applied
# to all logs. If it is present the transformation is applied
# only to the logs with the name that is found in the sequence
# specified below.
- otel.process.started

1.0.0:
4 changes: 4 additions & 0 deletions versions.yaml
Expand Up @@ -45,6 +45,10 @@ module-sets:
- go.opentelemetry.io/otel/metric
- go.opentelemetry.io/otel/sdk/export/metric
- go.opentelemetry.io/otel/sdk/metric
experimental-schema:
version: v0.0.1
modules:
- go.opentelemetry.io/otel/schema
bridge:
version: v0.24.0
modules:
Expand Down

0 comments on commit f82962e

Please sign in to comment.