generated_resource.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Code generated by mdatagen. DO NOT EDIT.
  2. package metadata
  3. import (
  4. "go.opentelemetry.io/collector/pdata/pcommon"
  5. )
  6. // ResourceBuilder is a helper struct to build resources predefined in metadata.yaml.
  7. // The ResourceBuilder is not thread-safe and must not to be used in multiple goroutines.
  8. type ResourceBuilder struct {
  9. config ResourceAttributesConfig
  10. res pcommon.Resource
  11. }
  12. // NewResourceBuilder creates a new ResourceBuilder. This method should be called on the start of the application.
  13. func NewResourceBuilder(rac ResourceAttributesConfig) *ResourceBuilder {
  14. return &ResourceBuilder{
  15. config: rac,
  16. res: pcommon.NewResource(),
  17. }
  18. }
  19. // SetOracledbInstanceName sets provided value as "oracledb.instance.name" attribute.
  20. func (rb *ResourceBuilder) SetOracledbInstanceName(val string) {
  21. if rb.config.OracledbInstanceName.Enabled {
  22. rb.res.Attributes().PutStr("oracledb.instance.name", val)
  23. }
  24. }
  25. // Emit returns the built resource and resets the internal builder state.
  26. func (rb *ResourceBuilder) Emit() pcommon.Resource {
  27. r := rb.res
  28. rb.res = pcommon.NewResource()
  29. return r
  30. }