Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Increment the:
* [CODE HEALTH] Fix clang-tidy macro to enum warnings
[#3922](https://github.com/open-telemetry/opentelemetry-cpp/pull/3922)

* [CODE HEALTH] Fix clang-tidy performance enum size warnings
[#3923](https://github.com/open-telemetry/opentelemetry-cpp/pull/3923)

Important changes:

* [BUILD] Revisit EventLogger deprecation
Expand Down
6 changes: 5 additions & 1 deletion api/include/opentelemetry/common/attribute_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ using AttributeValue =
nostd::span<const uint64_t>,
nostd::span<const uint8_t>>;

enum AttributeType
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
enum AttributeType : std::uint8_t
#else
enum AttributeType // NOLINT(performance-enum-size)
#endif
{
kTypeBool,
kTypeInt,
Expand Down
16 changes: 14 additions & 2 deletions api/include/opentelemetry/trace/span_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
#include "opentelemetry/common/timestamp.h"
#include "opentelemetry/version.h"

#if OPENTELEMETRY_ABI_VERSION_NO >= 2
# include <cstdint>
#endif

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{

enum class SpanKind
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
enum class SpanKind : std::uint8_t
#else
enum class SpanKind // NOLINT(performance-enum-size)
#endif
{
kInternal,
kServer,
Expand All @@ -24,7 +32,11 @@ constexpr char kSpanKey[] = "active_span";
constexpr char kIsRootSpanKey[] = "is_root_span";

// StatusCode - Represents the canonical set of status codes of a finished Span.
enum class StatusCode
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
enum class StatusCode : std::uint8_t
#else
enum class StatusCode // NOLINT(performance-enum-size)
#endif
{
kUnset, // default status
kOk, // Operation has completed successfully.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <cstdint>

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

Expand All @@ -12,14 +14,14 @@ namespace exporter
namespace otlp
{

enum class JsonBytesMappingKind
enum class JsonBytesMappingKind : std::uint8_t
{
kHexId,
kHex,
kBase64,
};

enum class HttpRequestContentType
enum class HttpRequestContentType : std::uint8_t
{
kJson,
kBinary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <cstdint>

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -10,7 +13,7 @@ namespace exporter
namespace otlp
{

enum class PreferredAggregationTemporality
enum class PreferredAggregationTemporality : std::uint8_t
{
kUnspecified,
kDelta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <cstdint>

#include "opentelemetry/ext/http/client/http_client_factory.h"
#include "opentelemetry/ext/http/common/url_parser.h"
#include "opentelemetry/sdk/common/env_variables.h"
Expand All @@ -26,7 +28,7 @@ inline const std::string GetDefaultZipkinEndpoint()
return exists ? endpoint : kZipkinEndpointDefault;
}

enum class TransportFormat
enum class TransportFormat : std::uint8_t
{
kJson,
kProtobuf
Expand Down
7 changes: 4 additions & 3 deletions ext/include/opentelemetry/ext/http/client/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <cstdint>
#include <cstring>
#include <map>
#include <memory>
Expand Down Expand Up @@ -67,7 +68,7 @@ namespace http
namespace client
{

enum class Method
enum class Method : std::uint8_t
{
Get,
Post,
Expand All @@ -78,7 +79,7 @@ enum class Method
Delete
};

enum class SessionState
enum class SessionState : std::uint8_t
{
CreateFailed, // session create failed
Created, // session created
Expand All @@ -97,7 +98,7 @@ enum class SessionState
Cancelled // (manually) cancelled
};

enum class Compression
enum class Compression : std::uint8_t
{
kNone,
kGzip
Expand Down
3 changes: 2 additions & 1 deletion ext/include/opentelemetry/ext/http/server/http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <cstdint>
#include <functional>
#include <list>
#include <map>
Expand Down Expand Up @@ -95,7 +96,7 @@ class HttpServer : private SocketTools::Reactor::SocketCallback
SocketTools::Socket socket;
std::string receiveBuffer;
std::string sendBuffer;
enum
enum : std::uint8_t
{
Idle,
ReceivingHeaders,
Expand Down
7 changes: 4 additions & 3 deletions ext/include/opentelemetry/ext/http/server/socket_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <atomic>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <map>
Expand Down Expand Up @@ -405,7 +406,7 @@ struct Socket
#endif
}

enum
enum // NOLINT(performance-enum-size)
{
#ifdef _WIN32
ErrorWouldBlock = WSAEWOULDBLOCK
Expand All @@ -414,7 +415,7 @@ struct Socket
#endif
};

enum
enum // NOLINT(performance-enum-size)
{
#ifdef _WIN32
ShutdownReceive = SD_RECEIVE,
Expand Down Expand Up @@ -469,7 +470,7 @@ struct Reactor : protected common::Thread
/// <summary>
/// Socket State
/// </summary>
enum State
enum State : std::uint8_t
{
Readable = 1,
Writable = 2,
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/common/attribute_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using OwnedAttributeValue = nostd::variant<bool,
std::vector<uint64_t>,
std::vector<uint8_t>>;

enum OwnedAttributeType
enum OwnedAttributeType : std::uint8_t
{
kTypeBool,
kTypeInt,
Expand Down
4 changes: 3 additions & 1 deletion sdk/include/opentelemetry/sdk/common/exporter_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <cstdint>

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -13,7 +15,7 @@ namespace common
/**
* ExportResult is returned as result of exporting a batch of Records.
*/
enum class ExportResult
enum class ExportResult : std::uint8_t
{
// Batch was exported successfully.
kSuccess = 0,
Expand Down
3 changes: 2 additions & 1 deletion sdk/include/opentelemetry/sdk/common/global_log_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <cstdint>
#include <sstream> // IWYU pragma: keep
#include <string>

Expand All @@ -28,7 +29,7 @@ namespace common
namespace internal_log
{

enum class LogLevel
enum class LogLevel : std::uint8_t
{
None = OTEL_INTERNAL_LOG_LEVEL_NONE,
Error = OTEL_INTERNAL_LOG_LEVEL_ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <cstdint>
#include <functional>
#include <memory>

Expand Down Expand Up @@ -35,14 +36,14 @@ namespace metrics
class MetricFilter
{
public:
enum class MetricFilterResult
enum class MetricFilterResult : std::uint8_t
{
kAccept,
kDrop,
kAcceptPartial,
};

enum class AttributesFilterResult
enum class AttributesFilterResult : std::uint8_t
{
kAccept,
kDrop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <cstdint>
#include <memory>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -94,7 +95,7 @@ class MetricProducer
MetricProducer &operator=(const MetricProducer &) = delete;
MetricProducer &operator=(MetricProducer &&) = delete;

enum class Status
enum class Status : std::uint8_t
{
kSuccess,
kFailure,
Expand Down
11 changes: 6 additions & 5 deletions sdk/include/opentelemetry/sdk/metrics/instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <algorithm>
#include <cctype>
#include <cstdint>
#include <functional>
#include <string>

Expand All @@ -16,7 +17,7 @@ namespace sdk
{
namespace metrics
{
enum class InstrumentType
enum class InstrumentType : std::uint8_t
{
kCounter,
kHistogram,
Expand All @@ -27,21 +28,21 @@ enum class InstrumentType
kGauge
};

enum class InstrumentClass
enum class InstrumentClass : std::uint8_t
{
kSync,
kAsync
};

enum class InstrumentValueType
enum class InstrumentValueType : std::uint8_t
{
kInt,
kLong,
kFloat,
kDouble
};

enum class AggregationType
enum class AggregationType : std::uint8_t
{
kDrop,
kHistogram,
Expand All @@ -51,7 +52,7 @@ enum class AggregationType
kBase2ExponentialHistogram
};

enum class AggregationTemporality
enum class AggregationTemporality : std::uint8_t
{
kUnspecified,
kDelta,
Expand Down
3 changes: 2 additions & 1 deletion sdk/include/opentelemetry/sdk/trace/sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include <cstdint>
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -34,7 +35,7 @@ namespace trace
/**
* A sampling Decision for a Span to be created.
*/
enum class Decision
enum class Decision : std::uint8_t
{
// IsRecording() == false, span will not be recorded and all events and attributes will be
// dropped.
Expand Down
Loading