1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // Code generated by mdatagen. DO NOT EDIT.
- package metadata
- import (
- "go.opentelemetry.io/collector/pdata/pcommon"
- )
- // ResourceBuilder is a helper struct to build resources predefined in metadata.yaml.
- // The ResourceBuilder is not thread-safe and must not to be used in multiple goroutines.
- type ResourceBuilder struct {
- config ResourceAttributesConfig
- res pcommon.Resource
- }
- // NewResourceBuilder creates a new ResourceBuilder. This method should be called on the start of the application.
- func NewResourceBuilder(rac ResourceAttributesConfig) *ResourceBuilder {
- return &ResourceBuilder{
- config: rac,
- res: pcommon.NewResource(),
- }
- }
- // SetHaproxyAddr sets provided value as "haproxy.addr" attribute.
- func (rb *ResourceBuilder) SetHaproxyAddr(val string) {
- if rb.config.HaproxyAddr.Enabled {
- rb.res.Attributes().PutStr("haproxy.addr", val)
- }
- }
- // SetHaproxyProxyName sets provided value as "haproxy.proxy_name" attribute.
- func (rb *ResourceBuilder) SetHaproxyProxyName(val string) {
- if rb.config.HaproxyProxyName.Enabled {
- rb.res.Attributes().PutStr("haproxy.proxy_name", val)
- }
- }
- // SetHaproxyServiceName sets provided value as "haproxy.service_name" attribute.
- func (rb *ResourceBuilder) SetHaproxyServiceName(val string) {
- if rb.config.HaproxyServiceName.Enabled {
- rb.res.Attributes().PutStr("haproxy.service_name", val)
- }
- }
- // Emit returns the built resource and resets the internal builder state.
- func (rb *ResourceBuilder) Emit() pcommon.Resource {
- r := rb.res
- rb.res = pcommon.NewResource()
- return r
- }
|