forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,70 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"embed" | ||
"flag" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"text/template" | ||
) | ||
|
||
var ( | ||
out = flag.String("output", "./", "output directory") | ||
tag = flag.String("tag", "", "OpenTelemetry tagged version") | ||
|
||
//go:embed templates/*.tmpl | ||
rootFS embed.FS | ||
) | ||
|
||
// SemanticConventions are information about the semantic conventions being | ||
// generated. | ||
type SemanticConventions struct { | ||
// TagVer is the tagged version (i.e. v1.7.0 and not 1.7.0). | ||
TagVer string | ||
} | ||
|
||
func (sc SemanticConventions) SemVer() string { | ||
return strings.TrimPrefix(*tag, "v") | ||
} | ||
|
||
// render renders all templates to the dest directory using the data. | ||
func render(src, dest string, data *SemanticConventions) error { | ||
tmpls, err := template.ParseFS(rootFS, src) | ||
if err != nil { | ||
return err | ||
} | ||
for _, tmpl := range tmpls.Templates() { | ||
target := filepath.Join(dest, strings.TrimSuffix(tmpl.Name(), ".tmpl")) | ||
// nolint: gosec | ||
wr, err := os.Create(target) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = tmpl.Execute(wr, data) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
if *tag == "" { | ||
log.Fatalf("invalid tag: %q", *tag) | ||
} | ||
|
||
sc := &SemanticConventions{TagVer: *tag} | ||
|
||
if err := render("templates/*.tmpl", *out, sc); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
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,9 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package semconv implements OpenTelemetry semantic conventions. | ||
// | ||
// OpenTelemetry semantic conventions are agreed standardized naming | ||
// patterns for OpenTelemetry things. This package represents the {{.TagVer}} | ||
// version of the OpenTelemetry semantic conventions. | ||
package semconv // import "go.opentelemetry.io/collector/semconv/{{.TagVer}}" |
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,9 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package semconv // import "go.opentelemetry.io/collector/semconv/{{.TagVer}}" | ||
|
||
// SchemaURL is the schema URL that matches the version of the semantic conventions | ||
// that this package defines. Semconv packages starting from v1.4.0 must declare | ||
// non-empty schema URL in the form https://opentelemetry.io/schemas/<version> | ||
const SchemaURL = "https://opentelemetry.io/schemas/{{.SemVer}}" |
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