mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-12 10:04:29 +02:00
e72a235518
* 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. * Fixes based on PR comments * Rename "label" to "attributes" See https://github.com/open-telemetry/oteps/pull/181 * Fixes based on PR comments * Add README.md * Wrap the error in Parse() * Add docs for exporter types * Use yaml.NewDecoder * Verify parsed content in the test * Fix indentation in README example * Fix README spaces vs tabs * Correctly space imports * Add heading to README Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
1010 B
1010 B
Telemetry Schema Files
The schema
module contains packages that help to parse and validate
schema files.
Each major.minor
schema file format version is implemented as a separate package, with
the name of the package in the vmajor.minor
form.
To parse a schema file, first decide what file format version you want to parse,
then import the corresponding package and use the Parse
or ParseFile
functions
like this:
import schema "go.opentelemetry.io/otel/schema/v1.0"
// Load the schema from a file in v1.0.x file format.
func loadSchemaFromFile() error {
telSchema, err := schema.ParseFile("schema-file.yaml")
if err != nil {
return err
}
// Use telSchema struct here.
}
// Alternatively use schema.Parse to read the schema file from io.Reader.
func loadSchemaFromReader(r io.Reader) error {
telSchema, err := schema.Parse(r)
if err != nil {
return err
}
// Use telSchema struct here.
}