Class Resource

Class Documentation

class opentelemetry::sdk::resource::Resource

Public Functions

Resource(const Resource&) = default
const ResourceAttributes &GetAttributes() const noexcept
const std::string &GetSchemaURL() const noexcept
Resource Merge(const Resource &other) noexcept

Returns a new, merged Resource by merging the current Resource with the other Resource. In case of a collision, current Resource takes precedence.

Parameters

other – the Resource that will be merged with this.

Returns

the newly merged Resource.

Public Static Functions

static Resource Create(const ResourceAttributes &attributes, const std::string &schema_url = std::string{})

Returns a newly created Resource with the specified attributes. It adds (merge) SDK attributes and OTEL attributes before returning.

Parameters

attributes – for this resource

Returns

the newly created Resource.

static Resource &GetEmpty()

Returns an Empty resource.

static Resource &GetDefault()

Returns a Resource that indentifies the SDK in use.

Protected Functions

Resource(const ResourceAttributes &attributes = ResourceAttributes(), const std::string &schema_url = std::string{}) noexcept

The constructor is protected and only for use internally by the class and inside ResourceDetector class. Users should use the Create factory method to obtain a Resource instance.