-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add code and scheme generation #20
Conversation
ab543a9
to
8951616
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
during meeting with @shaun-nx , we found two small bugs: (1) package telemetry
/*
This is a generated file. DO NOT EDIT.
*/
import (
"go.opentelemetry.io/otel/attribute"
"github.com/nginxinc/telemetry-exporter/pkg/telemetry" // self-import
) (2) package telemetry
/*
This is a generated file. DO NOT EDIT.
*/
import (
"go.opentelemetry.io/otel/attribute"
"github.com/nginxinc/telemetry-exporter/pkg/telemetry"
)
func (d *NGFResourceCounts2) Attributes() []attribute.KeyValue {
var attrs []attribute.KeyValue
attrs = append(attrs, attribute.Int64("Gateways", d.Gateways))
return attrs
}
// problem - we want to use github.com/nginxinc/telemetry-exporter/pkg/telemetry.Exportable here, but end up using Exportable from this package.
var _ telemetry.Exportable = (*NGFResourceCounts2)(nil) I will fix them shortly |
Problem: - Ensure the Attributes method of Exprotable interface are generated automatically for the telemetry data types. - Ensure the avro scheme (.avdl) is generated automatically for the telemetry data types. Solution: - Add generator tool in cmd/generator that generates code (Attributes method) and the scheme. - Generator can be used in //go:generate annotations in go source files. - Generator has "generator" build tag so that it is not included into the telemetry library by default. - Generator uses golang.org/x/tools/go/packages to parse source files. Testing: - Unit tests of parsing. - Unit tests of code and scheme generation - ensuring non-zero output. - Unit tests of generated code in cmd/generator/tests package - Manual validation of the generated scheme (cmd/generator/tests/data.avdl) using Apache Avro IDL Scheme Support IntelliJ plugin. CLOSES - #18 Co-authored-by: Saylor Berman <s.berman@f5.com> Co-authored-by: Ciara Stacke <c.stacke@f5.com>
…exporter/pkg/telemetry package
8951616
to
86bf656
Compare
(forced push to resolve go.mod conflicts with the main branch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Proposed changes
Problem:
Solution:
Testing:
CLOSES - #18
Note: if you'd like to experiment with code and scheme generation:
cmd/generator/tests/data.go
and/or Data2 incmd/generator/tests/subtests/data2.go
make generate
cmd/generator/tests/data_attributes_generated.go
,cmd/generator/tests/data.avdl
andcmd/generator/tests/subtests/data2_attributes_generated.go
Checklist
Before creating a PR, run through this checklist and mark each as complete.
guide