-
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.
Fix a bug when parsing a struct in the github.com/nginxinc/telemetry-…
…exporter/pkg/telemetry package
- Loading branch information
Showing
7 changed files
with
98 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build generator | ||
|
||
package telemetry | ||
|
||
// MoreData is used to ensure that the generator produces the correct code for a struct in a package with the name | ||
// 'telemetry'. | ||
// Correctness is confirmed by the fact the generated code compiles. | ||
// | ||
//go:generate go run -tags generator github.com/nginxinc/telemetry-exporter/cmd/generator -type=MoreData -build-tags=generator | ||
type MoreData struct { | ||
// StringField is a string field. | ||
StringField string | ||
} |
24 changes: 24 additions & 0 deletions
24
cmd/generator/tests/telemetry/moredata_attributes_generated.go
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,24 @@ | ||
//go:build generator | ||
package telemetry | ||
/* | ||
This is a generated file. DO NOT EDIT. | ||
*/ | ||
|
||
import ( | ||
"go.opentelemetry.io/otel/attribute" | ||
|
||
|
||
ngxTelemetry "github.com/nginxinc/telemetry-exporter/pkg/telemetry" | ||
|
||
) | ||
|
||
func (d *MoreData) Attributes() []attribute.KeyValue { | ||
var attrs []attribute.KeyValue | ||
|
||
attrs = append(attrs, attribute.String("StringField", d.StringField)) | ||
|
||
|
||
return attrs | ||
} | ||
|
||
var _ ngxTelemetry.Exportable = (*MoreData)(nil) |
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,22 @@ | ||
|
||
package telemetry | ||
/* | ||
This is a generated file. DO NOT EDIT. | ||
*/ | ||
|
||
import ( | ||
"go.opentelemetry.io/otel/attribute" | ||
|
||
|
||
) | ||
|
||
func (d *Data) Attributes() []attribute.KeyValue { | ||
var attrs []attribute.KeyValue | ||
|
||
attrs = append(attrs, attribute.Int64("Nodes", d.Nodes)) | ||
|
||
|
||
return attrs | ||
} | ||
|
||
var _ Exportable = (*Data)(nil) |
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