Program Listing for File resource.h

Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/opentelemetry-cpp/checkouts/latest/sdk/include/opentelemetry/sdk/resource/resource.h)

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <string>

#include "opentelemetry/sdk/common/attribute_utils.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace resource
{

using ResourceAttributes = opentelemetry::sdk::common::AttributeMap;

class Resource
{
public:
  Resource(const Resource &) = default;

  const ResourceAttributes &GetAttributes() const noexcept;
  const std::string &GetSchemaURL() const noexcept;

  Resource Merge(const Resource &other) const noexcept;

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

  static Resource &GetEmpty();

  static Resource &GetDefault();

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

private:
  ResourceAttributes attributes_;
  std::string schema_url_;

  friend class OTELResourceDetector;
};

}  // namespace resource
}  // namespace sdk
OPENTELEMETRY_END_NAMESPACE