generated from TrueCloudLab/basic
[#9999] config: Add resource attributes
All checks were successful
DCO action / DCO (pull_request) Successful in 1m21s
Tests and linters / Tests (pull_request) Successful in 1m37s
Tests and linters / Staticcheck (pull_request) Successful in 1m41s
Tests and linters / Tests with -race (pull_request) Successful in 2m23s
Tests and linters / Lint (pull_request) Successful in 3m1s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m21s
Tests and linters / Tests (pull_request) Successful in 1m37s
Tests and linters / Staticcheck (pull_request) Successful in 1m41s
Tests and linters / Tests with -race (pull_request) Successful in 2m23s
Tests and linters / Lint (pull_request) Successful in 3m1s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
666d326cc5
commit
651f797671
2 changed files with 9 additions and 1 deletions
|
@ -3,6 +3,7 @@ package tracing
|
||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Exporter is type of tracing target.
|
// Exporter is type of tracing target.
|
||||||
|
@ -33,6 +34,9 @@ type Config struct {
|
||||||
// Version is version of service instance.
|
// Version is version of service instance.
|
||||||
// Optional.
|
// Optional.
|
||||||
Version string
|
Version string
|
||||||
|
// Attributes is KV list of attributes.
|
||||||
|
// Optional.
|
||||||
|
Attributes map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) validate() error {
|
func (c *Config) validate() error {
|
||||||
|
@ -81,5 +85,6 @@ func (c *Config) hasChange(other *Config) bool {
|
||||||
func (c *Config) serviceInfoEqual(other *Config) bool {
|
func (c *Config) serviceInfoEqual(other *Config) bool {
|
||||||
return c.Service == other.Service &&
|
return c.Service == other.Service &&
|
||||||
c.InstanceID == other.InstanceID &&
|
c.InstanceID == other.InstanceID &&
|
||||||
c.Version == other.Version
|
c.Version == other.Version &&
|
||||||
|
maps.Equal(c.Attributes, other.Attributes)
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,9 @@ func newResource(cfg *Config) *resource.Resource {
|
||||||
if len(cfg.InstanceID) > 0 {
|
if len(cfg.InstanceID) > 0 {
|
||||||
attrs = append(attrs, semconv.ServiceInstanceID(cfg.InstanceID))
|
attrs = append(attrs, semconv.ServiceInstanceID(cfg.InstanceID))
|
||||||
}
|
}
|
||||||
|
for k, v := range cfg.Attributes {
|
||||||
|
attrs = append(attrs, attribute.String(k, v))
|
||||||
|
}
|
||||||
return resource.NewWithAttributes(
|
return resource.NewWithAttributes(
|
||||||
semconv.SchemaURL,
|
semconv.SchemaURL,
|
||||||
attrs...,
|
attrs...,
|
||||||
|
|
Loading…
Reference in a new issue