Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New LogRecord and Recordable implementations. #1766

Merged
merged 2 commits into from
Dec 13, 2022
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
44 changes: 22 additions & 22 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug on Windows",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/<path-to-bin-file>",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
},
{
"name": "Debug on Linux",
"type": "gdb",
"request": "launch",
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Debug on Windows",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/<path-to-bin-file>",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
},
{
"name": "Debug on Linux",
"type": "gdb",
"request": "launch",
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText"
}
]
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ exporters [#1828](https://github.com/open-telemetry/opentelemetry-cpp/pull/1828)
* [BUILD] Add CMake OTELCPP_PROTO_PATH [#1730](https://github.com/open-telemetry/opentelemetry-cpp/pull/1730)
* [SEMANTIC CONVENTIONS] Upgrade to version 1.15.0
[#1761](https://github.com/open-telemetry/opentelemetry-cpp/pull/1761)
* [LOGS SDK] New LogRecord and logs::Recordable implementations.
[#1766](https://github.com/open-telemetry/opentelemetry-cpp/pull/1766)

Deprecation notes:

Expand Down
8 changes: 8 additions & 0 deletions api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <utility>

#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/nostd/type_traits.h"
#include "opentelemetry/nostd/utility.h"
#include "opentelemetry/version.h"

Expand Down Expand Up @@ -73,5 +74,12 @@ class KeyValueIterableView final : public KeyValueIterable
private:
const T *container_;
};

template <class T, nostd::enable_if_t<detail::is_key_value_iterable<T>::value> * = nullptr>
KeyValueIterableView<T> MakeKeyValueIterableView(const T &container) noexcept
{
return KeyValueIterableView<T>(container);
}

} // namespace common
OPENTELEMETRY_END_NAMESPACE
81 changes: 81 additions & 0 deletions api/include/opentelemetry/logs/log_record.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once
#ifdef ENABLE_LOGS_PREVIEW

# include "opentelemetry/common/attribute_value.h"
# include "opentelemetry/common/key_value_iterable.h"
# include "opentelemetry/common/timestamp.h"
# include "opentelemetry/logs/severity.h"
# include "opentelemetry/trace/span_id.h"
# include "opentelemetry/trace/trace_flags.h"
# include "opentelemetry/trace/trace_id.h"
# include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace logs
{
/**
* Maintains a representation of a log in a format that can be processed by a recorder.
*
* This class is thread-compatible.
*/
class LogRecord
{
public:
virtual ~LogRecord() = default;

/**
* Set the timestamp for this log.
* @param timestamp the timestamp to set
*/
virtual void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept = 0;

/**
* Set the observed timestamp for this log.
* @param timestamp the timestamp to set
*/
virtual void SetObservedTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept = 0;

/**
* Set the severity for this log.
* @param severity the severity of the event
*/
virtual void SetSeverity(opentelemetry::logs::Severity severity) noexcept = 0;

/**
* Set body field for this log.
* @param message the body to set
*/
virtual void SetBody(const opentelemetry::common::AttributeValue &message) noexcept = 0;

/**
* Set an attribute of a log.
* @param key the name of the attribute
* @param value the attribute value
*/
virtual void SetAttribute(nostd::string_view key,
const opentelemetry::common::AttributeValue &value) noexcept = 0;

/**
* Set the trace id for this log.
* @param trace_id the trace id to set
*/
virtual void SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept = 0;

/**
* Set the span id for this log.
* @param span_id the span id to set
*/
virtual void SetSpanId(const opentelemetry::trace::SpanId &span_id) noexcept = 0;

/**
* Inject trace_flags for this log.
* @param trace_flags the trace flags to set
*/
virtual void SetTraceFlags(const opentelemetry::trace::TraceFlags &trace_flags) noexcept = 0;
};
} // namespace logs
OPENTELEMETRY_END_NAMESPACE
#endif
Loading