generated_resource.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // SetHaproxyAddr sets provided value as "haproxy.addr" attribute.
  20. func (rb *ResourceBuilder) SetHaproxyAddr(val string) {
  21. if rb.config.HaproxyAddr.Enabled {
  22. rb.res.Attributes().PutStr("haproxy.addr", val)
  23. }
  24. }
  25. // SetHaproxyProxyName sets provided value as "haproxy.proxy_name" attribute.
  26. func (rb *ResourceBuilder) SetHaproxyProxyName(val string) {
  27. if rb.config.HaproxyProxyName.Enabled {
  28. rb.res.Attributes().PutStr("haproxy.proxy_name", val)
  29. }
  30. }
  31. // SetHaproxyServiceName sets provided value as "haproxy.service_name" attribute.
  32. func (rb *ResourceBuilder) SetHaproxyServiceName(val string) {
  33. if rb.config.HaproxyServiceName.Enabled {
  34. rb.res.Attributes().PutStr("haproxy.service_name", val)
  35. }
  36. }
  37. // Emit returns the built resource and resets the internal builder state.
  38. func (rb *ResourceBuilder) Emit() pcommon.Resource {
  39. r := rb.res
  40. rb.res = pcommon.NewResource()
  41. return r
  42. }