generated_resource.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. // SetContainerID sets provided value as "container.id" attribute.
  20. func (rb *ResourceBuilder) SetContainerID(val string) {
  21. if rb.config.ContainerID.Enabled {
  22. rb.res.Attributes().PutStr("container.id", val)
  23. }
  24. }
  25. // SetContainerImageName sets provided value as "container.image.name" attribute.
  26. func (rb *ResourceBuilder) SetContainerImageName(val string) {
  27. if rb.config.ContainerImageName.Enabled {
  28. rb.res.Attributes().PutStr("container.image.name", val)
  29. }
  30. }
  31. // SetContainerImageTag sets provided value as "container.image.tag" attribute.
  32. func (rb *ResourceBuilder) SetContainerImageTag(val string) {
  33. if rb.config.ContainerImageTag.Enabled {
  34. rb.res.Attributes().PutStr("container.image.tag", val)
  35. }
  36. }
  37. // SetK8sContainerName sets provided value as "k8s.container.name" attribute.
  38. func (rb *ResourceBuilder) SetK8sContainerName(val string) {
  39. if rb.config.K8sContainerName.Enabled {
  40. rb.res.Attributes().PutStr("k8s.container.name", val)
  41. }
  42. }
  43. // SetK8sCronjobName sets provided value as "k8s.cronjob.name" attribute.
  44. func (rb *ResourceBuilder) SetK8sCronjobName(val string) {
  45. if rb.config.K8sCronjobName.Enabled {
  46. rb.res.Attributes().PutStr("k8s.cronjob.name", val)
  47. }
  48. }
  49. // SetK8sCronjobUID sets provided value as "k8s.cronjob.uid" attribute.
  50. func (rb *ResourceBuilder) SetK8sCronjobUID(val string) {
  51. if rb.config.K8sCronjobUID.Enabled {
  52. rb.res.Attributes().PutStr("k8s.cronjob.uid", val)
  53. }
  54. }
  55. // SetK8sDaemonsetName sets provided value as "k8s.daemonset.name" attribute.
  56. func (rb *ResourceBuilder) SetK8sDaemonsetName(val string) {
  57. if rb.config.K8sDaemonsetName.Enabled {
  58. rb.res.Attributes().PutStr("k8s.daemonset.name", val)
  59. }
  60. }
  61. // SetK8sDaemonsetUID sets provided value as "k8s.daemonset.uid" attribute.
  62. func (rb *ResourceBuilder) SetK8sDaemonsetUID(val string) {
  63. if rb.config.K8sDaemonsetUID.Enabled {
  64. rb.res.Attributes().PutStr("k8s.daemonset.uid", val)
  65. }
  66. }
  67. // SetK8sDeploymentName sets provided value as "k8s.deployment.name" attribute.
  68. func (rb *ResourceBuilder) SetK8sDeploymentName(val string) {
  69. if rb.config.K8sDeploymentName.Enabled {
  70. rb.res.Attributes().PutStr("k8s.deployment.name", val)
  71. }
  72. }
  73. // SetK8sDeploymentUID sets provided value as "k8s.deployment.uid" attribute.
  74. func (rb *ResourceBuilder) SetK8sDeploymentUID(val string) {
  75. if rb.config.K8sDeploymentUID.Enabled {
  76. rb.res.Attributes().PutStr("k8s.deployment.uid", val)
  77. }
  78. }
  79. // SetK8sHpaName sets provided value as "k8s.hpa.name" attribute.
  80. func (rb *ResourceBuilder) SetK8sHpaName(val string) {
  81. if rb.config.K8sHpaName.Enabled {
  82. rb.res.Attributes().PutStr("k8s.hpa.name", val)
  83. }
  84. }
  85. // SetK8sHpaUID sets provided value as "k8s.hpa.uid" attribute.
  86. func (rb *ResourceBuilder) SetK8sHpaUID(val string) {
  87. if rb.config.K8sHpaUID.Enabled {
  88. rb.res.Attributes().PutStr("k8s.hpa.uid", val)
  89. }
  90. }
  91. // SetK8sJobName sets provided value as "k8s.job.name" attribute.
  92. func (rb *ResourceBuilder) SetK8sJobName(val string) {
  93. if rb.config.K8sJobName.Enabled {
  94. rb.res.Attributes().PutStr("k8s.job.name", val)
  95. }
  96. }
  97. // SetK8sJobUID sets provided value as "k8s.job.uid" attribute.
  98. func (rb *ResourceBuilder) SetK8sJobUID(val string) {
  99. if rb.config.K8sJobUID.Enabled {
  100. rb.res.Attributes().PutStr("k8s.job.uid", val)
  101. }
  102. }
  103. // SetK8sKubeletVersion sets provided value as "k8s.kubelet.version" attribute.
  104. func (rb *ResourceBuilder) SetK8sKubeletVersion(val string) {
  105. if rb.config.K8sKubeletVersion.Enabled {
  106. rb.res.Attributes().PutStr("k8s.kubelet.version", val)
  107. }
  108. }
  109. // SetK8sKubeproxyVersion sets provided value as "k8s.kubeproxy.version" attribute.
  110. func (rb *ResourceBuilder) SetK8sKubeproxyVersion(val string) {
  111. if rb.config.K8sKubeproxyVersion.Enabled {
  112. rb.res.Attributes().PutStr("k8s.kubeproxy.version", val)
  113. }
  114. }
  115. // SetK8sNamespaceName sets provided value as "k8s.namespace.name" attribute.
  116. func (rb *ResourceBuilder) SetK8sNamespaceName(val string) {
  117. if rb.config.K8sNamespaceName.Enabled {
  118. rb.res.Attributes().PutStr("k8s.namespace.name", val)
  119. }
  120. }
  121. // SetK8sNamespaceUID sets provided value as "k8s.namespace.uid" attribute.
  122. func (rb *ResourceBuilder) SetK8sNamespaceUID(val string) {
  123. if rb.config.K8sNamespaceUID.Enabled {
  124. rb.res.Attributes().PutStr("k8s.namespace.uid", val)
  125. }
  126. }
  127. // SetK8sNodeName sets provided value as "k8s.node.name" attribute.
  128. func (rb *ResourceBuilder) SetK8sNodeName(val string) {
  129. if rb.config.K8sNodeName.Enabled {
  130. rb.res.Attributes().PutStr("k8s.node.name", val)
  131. }
  132. }
  133. // SetK8sNodeUID sets provided value as "k8s.node.uid" attribute.
  134. func (rb *ResourceBuilder) SetK8sNodeUID(val string) {
  135. if rb.config.K8sNodeUID.Enabled {
  136. rb.res.Attributes().PutStr("k8s.node.uid", val)
  137. }
  138. }
  139. // SetK8sPodName sets provided value as "k8s.pod.name" attribute.
  140. func (rb *ResourceBuilder) SetK8sPodName(val string) {
  141. if rb.config.K8sPodName.Enabled {
  142. rb.res.Attributes().PutStr("k8s.pod.name", val)
  143. }
  144. }
  145. // SetK8sPodQosClass sets provided value as "k8s.pod.qos_class" attribute.
  146. func (rb *ResourceBuilder) SetK8sPodQosClass(val string) {
  147. if rb.config.K8sPodQosClass.Enabled {
  148. rb.res.Attributes().PutStr("k8s.pod.qos_class", val)
  149. }
  150. }
  151. // SetK8sPodUID sets provided value as "k8s.pod.uid" attribute.
  152. func (rb *ResourceBuilder) SetK8sPodUID(val string) {
  153. if rb.config.K8sPodUID.Enabled {
  154. rb.res.Attributes().PutStr("k8s.pod.uid", val)
  155. }
  156. }
  157. // SetK8sReplicasetName sets provided value as "k8s.replicaset.name" attribute.
  158. func (rb *ResourceBuilder) SetK8sReplicasetName(val string) {
  159. if rb.config.K8sReplicasetName.Enabled {
  160. rb.res.Attributes().PutStr("k8s.replicaset.name", val)
  161. }
  162. }
  163. // SetK8sReplicasetUID sets provided value as "k8s.replicaset.uid" attribute.
  164. func (rb *ResourceBuilder) SetK8sReplicasetUID(val string) {
  165. if rb.config.K8sReplicasetUID.Enabled {
  166. rb.res.Attributes().PutStr("k8s.replicaset.uid", val)
  167. }
  168. }
  169. // SetK8sReplicationcontrollerName sets provided value as "k8s.replicationcontroller.name" attribute.
  170. func (rb *ResourceBuilder) SetK8sReplicationcontrollerName(val string) {
  171. if rb.config.K8sReplicationcontrollerName.Enabled {
  172. rb.res.Attributes().PutStr("k8s.replicationcontroller.name", val)
  173. }
  174. }
  175. // SetK8sReplicationcontrollerUID sets provided value as "k8s.replicationcontroller.uid" attribute.
  176. func (rb *ResourceBuilder) SetK8sReplicationcontrollerUID(val string) {
  177. if rb.config.K8sReplicationcontrollerUID.Enabled {
  178. rb.res.Attributes().PutStr("k8s.replicationcontroller.uid", val)
  179. }
  180. }
  181. // SetK8sResourcequotaName sets provided value as "k8s.resourcequota.name" attribute.
  182. func (rb *ResourceBuilder) SetK8sResourcequotaName(val string) {
  183. if rb.config.K8sResourcequotaName.Enabled {
  184. rb.res.Attributes().PutStr("k8s.resourcequota.name", val)
  185. }
  186. }
  187. // SetK8sResourcequotaUID sets provided value as "k8s.resourcequota.uid" attribute.
  188. func (rb *ResourceBuilder) SetK8sResourcequotaUID(val string) {
  189. if rb.config.K8sResourcequotaUID.Enabled {
  190. rb.res.Attributes().PutStr("k8s.resourcequota.uid", val)
  191. }
  192. }
  193. // SetK8sStatefulsetName sets provided value as "k8s.statefulset.name" attribute.
  194. func (rb *ResourceBuilder) SetK8sStatefulsetName(val string) {
  195. if rb.config.K8sStatefulsetName.Enabled {
  196. rb.res.Attributes().PutStr("k8s.statefulset.name", val)
  197. }
  198. }
  199. // SetK8sStatefulsetUID sets provided value as "k8s.statefulset.uid" attribute.
  200. func (rb *ResourceBuilder) SetK8sStatefulsetUID(val string) {
  201. if rb.config.K8sStatefulsetUID.Enabled {
  202. rb.res.Attributes().PutStr("k8s.statefulset.uid", val)
  203. }
  204. }
  205. // SetOpenshiftClusterquotaName sets provided value as "openshift.clusterquota.name" attribute.
  206. func (rb *ResourceBuilder) SetOpenshiftClusterquotaName(val string) {
  207. if rb.config.OpenshiftClusterquotaName.Enabled {
  208. rb.res.Attributes().PutStr("openshift.clusterquota.name", val)
  209. }
  210. }
  211. // SetOpenshiftClusterquotaUID sets provided value as "openshift.clusterquota.uid" attribute.
  212. func (rb *ResourceBuilder) SetOpenshiftClusterquotaUID(val string) {
  213. if rb.config.OpenshiftClusterquotaUID.Enabled {
  214. rb.res.Attributes().PutStr("openshift.clusterquota.uid", val)
  215. }
  216. }
  217. // Emit returns the built resource and resets the internal builder state.
  218. func (rb *ResourceBuilder) Emit() pcommon.Resource {
  219. r := rb.res
  220. rb.res = pcommon.NewResource()
  221. return r
  222. }