Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to parse Schema files according to OTEP 0152
The parser and parsed representation (AST) are placed in a separate Go module so that they are can be consumed independently without the need to bring the rest of the SDK. Ability to use the parsed representation for schema conversions can be added later.
- Loading branch information
1 parent
099df58
commit 4c60e21
Showing
43 changed files
with
664 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 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/ast" | ||
|
||
import "go.opentelemetry.io/otel/schema/types" | ||
|
||
const FileFormat = "1.0.0" | ||
|
||
// Schema represents a Schema file in FileFormat 1.0.0 as defined in | ||
// https://github.com/open-telemetry/oteps/blob/main/text/0152-telemetry-schemas.md | ||
type Schema struct { | ||
// Schema file format. SHOULD be 1.0.0 for the current specification version. | ||
// See https://github.com/open-telemetry/oteps/blob/main/text/0152-telemetry-schemas.md#schema-file-format-number | ||
FileFormat string `yaml:"file_format"` | ||
|
||
// Schema URL is an identifier of a Schema. The URL specifies a location of this | ||
// Schema File that can be retrieved (so it is a URL and not just a URI) using HTTP | ||
// or HTTPS protocol. | ||
// See https://github.com/open-telemetry/oteps/blob/main/text/0152-telemetry-schemas.md#schema-url | ||
SchemaURL string `yaml:"schema_url"` | ||
|
||
// Versions section that lists changes that happened in each particular version. | ||
Versions map[types.TelemetryVersion]VersionDef | ||
} | ||
|
||
// 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 | ||
} | ||
|
||
// VersionOfAttributes corresponds to a section representing a list of changes that | ||
// happened in a particular version. | ||
type VersionOfAttributes struct { | ||
Changes []AttributeChanges | ||
} | ||
|
||
// AttributeChanges corresponds to a section representing attribute changes. | ||
type AttributeChanges struct { | ||
RenameAttributes *MappingOfAttributes `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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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/ast" | ||
|
||
// VersionOfLogs corresponds to a section representing a list of changes that happened | ||
// to logs schema in a particular version. | ||
type VersionOfLogs 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"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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/types" | ||
|
||
// VersionOfMetrics corresponds to a section representing a list of changes that happened | ||
// to metrics schema in a particular version. | ||
type VersionOfMetrics 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"` | ||
} | ||
|
||
type LabelMapForMetrics struct { | ||
ApplyToMetrics []types.MetricName `yaml:"apply_to_metrics"` | ||
LabelMap map[string]string `yaml:"label_map"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// 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/ast" | ||
|
||
import "go.opentelemetry.io/otel/schema/types" | ||
|
||
// VersionOfSpans corresponds to a section representing a list of changes that happened | ||
// to spans schema in a particular version. | ||
type VersionOfSpans struct { | ||
Changes []SpansChange | ||
} | ||
|
||
// VersionOfSpanEvents corresponds to a section representing a list of changes that happened | ||
// to span events schema in a particular version. | ||
type VersionOfSpanEvents struct { | ||
Changes []SpanEventsChange | ||
} | ||
|
||
// SpansChange corresponds to a section representing spans change. | ||
type SpansChange struct { | ||
RenameAttributes *RenameSpanAttributes `yaml:"rename_attributes"` | ||
} | ||
|
||
// SpanEventsChange corresponds to a section representing span events change. | ||
type SpanEventsChange struct { | ||
RenameEvents *RenameSpanEvents `yaml:"rename_events"` | ||
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"` | ||
} | ||
|
||
type RenameSpanEventAttributes struct { | ||
ApplyToSpans []types.SpanName `yaml:"apply_to_spans"` | ||
ApplyToEvents []types.EventName `yaml:"apply_to_events"` | ||
AttributeMap map[string]string `yaml:"attribute_map"` | ||
} |
Oops, something went wrong.