Program Listing for File resource.h

Return to documentation for file (/tmp/B.puc0r6hi/BUILD/opentelemetry-cpp-1.27.0-build/opentelemetry-cpp-1.27.0/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() noexcept;

  Resource(const ResourceAttributes &attributes) noexcept;

  Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept;

  Resource(const Resource &)            = default;
  Resource(Resource &&)                 = default;
  Resource &operator=(const Resource &) = default;
  Resource &operator=(Resource &&)      = default;

  ~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();

private:
  ResourceAttributes attributes_;
  std::string schema_url_;
};

}  // namespace resource
}  // namespace sdk
OPENTELEMETRY_END_NAMESPACE