Skip to content

Commit f5a22e7

Browse files
committed
Signed-off-by: owent <[email protected]> Fix `-Werror=suggest-override` and style Signed-off-by: owent <[email protected]> Fix ostream_log_test Signed-off-by: owent <[email protected]> Fix ostream print_value for `AttributeValue` Signed-off-by: owent <[email protected]> New Recordable of logs Signed-off-by: owent <[email protected]> Restore .vscode/launch.json Signed-off-by: owent <[email protected]> Fix warning. Signed-off-by: owent <[email protected]> Fix warnings in maintainer mode and ETW exporter Signed-off-by: owent <[email protected]> Add CHANGELOG Signed-off-by: owent <[email protected]> Allow to move 'nostd::unique_ptr<T>' into `nostd::shared_ptr<T>` Signed-off-by: owent <[email protected]> Do not use `std/type_traits.h` any more. Maybe we should remove this file later. Signed-off-by: owent <[email protected]> Allow to add rvalue into `CircularBuffer` Signed-off-by: owent <[email protected]> Finish new `LogRecord` for exporters. Signed-off-by: owent <[email protected]> Finish unit tests in API and SDK. Exporters are still work in progress. Signed-off-by: owent <[email protected]> New `LogRecord` and `Recordable` implementations. Signed-off-by: WenTao Ou <[email protected]>
1 parent 308ec88 commit f5a22e7

File tree

77 files changed

+2206
-1374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2206
-1374
lines changed

.vscode/launch.json

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Debug on Windows",
6-
"type": "cppvsdbg",
7-
"request": "launch",
8-
"program": "${workspaceFolder}/build/<path-to-bin-file>",
9-
"args": [],
10-
"stopAtEntry": false,
11-
"cwd": "${workspaceFolder}",
12-
"environment": [],
13-
"externalConsole": false
14-
},
15-
{
16-
"name": "Debug on Linux",
17-
"type": "gdb",
18-
"request": "launch",
19-
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
20-
"cwd": "${workspaceRoot}",
21-
"valuesFormatting": "parseText"
22-
}
23-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug on Windows",
6+
"type": "cppvsdbg",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/build/<path-to-bin-file>",
9+
"args": [],
10+
"stopAtEntry": false,
11+
"cwd": "${workspaceFolder}",
12+
"environment": [],
13+
"externalConsole": false
14+
},
15+
{
16+
"name": "Debug on Linux",
17+
"type": "gdb",
18+
"request": "launch",
19+
"target": "${workspaceFolder}/bazel-bin/<path to the bin file>",
20+
"cwd": "${workspaceRoot}",
21+
"valuesFormatting": "parseText"
22+
}
23+
]
2424
}

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Increment the:
4949
* [BUILD] Add CMake OTELCPP_PROTO_PATH [#1730](https://github.com/open-telemetry/opentelemetry-cpp/pull/1730)
5050
* [SEMANTIC CONVENTIONS] Upgrade to version 1.15.0
5151
[#1761](https://github.com/open-telemetry/opentelemetry-cpp/pull/1761)
52+
* [LOGS SDK] New LogRecord and logs::Recordable implementations.
53+
[#1766](https://github.com/open-telemetry/opentelemetry-cpp/pull/1766)
5254

5355
Deprecation notes:
5456

api/include/opentelemetry/common/key_value_iterable_view.h

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <utility>
99

1010
#include "opentelemetry/common/key_value_iterable.h"
11+
#include "opentelemetry/nostd/type_traits.h"
1112
#include "opentelemetry/nostd/utility.h"
1213
#include "opentelemetry/version.h"
1314

@@ -73,5 +74,12 @@ class KeyValueIterableView final : public KeyValueIterable
7374
private:
7475
const T *container_;
7576
};
77+
78+
template <class T, nostd::enable_if_t<detail::is_key_value_iterable<T>::value> * = nullptr>
79+
KeyValueIterableView<T> MakeKeyValueIterableView(const T &container) noexcept
80+
{
81+
return KeyValueIterableView<T>(container);
82+
}
83+
7684
} // namespace common
7785
OPENTELEMETRY_END_NAMESPACE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
#ifdef ENABLE_LOGS_PREVIEW
6+
7+
# include "opentelemetry/common/attribute_value.h"
8+
# include "opentelemetry/common/key_value_iterable.h"
9+
# include "opentelemetry/common/timestamp.h"
10+
# include "opentelemetry/logs/severity.h"
11+
# include "opentelemetry/trace/span_id.h"
12+
# include "opentelemetry/trace/trace_flags.h"
13+
# include "opentelemetry/trace/trace_id.h"
14+
# include "opentelemetry/version.h"
15+
16+
OPENTELEMETRY_BEGIN_NAMESPACE
17+
namespace logs
18+
{
19+
/**
20+
* Maintains a representation of a log in a format that can be processed by a recorder.
21+
*
22+
* This class is thread-compatible.
23+
*/
24+
class LogRecord
25+
{
26+
public:
27+
virtual ~LogRecord() = default;
28+
29+
/**
30+
* Set the timestamp for this log.
31+
* @param timestamp the timestamp to set
32+
*/
33+
virtual void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept = 0;
34+
35+
/**
36+
* Set the observed timestamp for this log.
37+
* @param timestamp the timestamp to set
38+
*/
39+
virtual void SetObservedTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept = 0;
40+
41+
/**
42+
* Set the severity for this log.
43+
* @param severity the severity of the event
44+
*/
45+
virtual void SetSeverity(opentelemetry::logs::Severity severity) noexcept = 0;
46+
47+
/**
48+
* Set body field for this log.
49+
* @param message the body to set
50+
*/
51+
virtual void SetBody(const opentelemetry::common::AttributeValue &message) noexcept = 0;
52+
53+
/**
54+
* Set an attribute of a log.
55+
* @param key the name of the attribute
56+
* @param value the attribute value
57+
*/
58+
virtual void SetAttribute(nostd::string_view key,
59+
const opentelemetry::common::AttributeValue &value) noexcept = 0;
60+
61+
/**
62+
* Set the trace id for this log.
63+
* @param trace_id the trace id to set
64+
*/
65+
virtual void SetTraceId(const opentelemetry::trace::TraceId &trace_id) noexcept = 0;
66+
67+
/**
68+
* Set the span id for this log.
69+
* @param span_id the span id to set
70+
*/
71+
virtual void SetSpanId(const opentelemetry::trace::SpanId &span_id) noexcept = 0;
72+
73+
/**
74+
* Inject trace_flags for this log.
75+
* @param trace_flags the trace flags to set
76+
*/
77+
virtual void SetTraceFlags(const opentelemetry::trace::TraceFlags &trace_flags) noexcept = 0;
78+
};
79+
} // namespace logs
80+
OPENTELEMETRY_END_NAMESPACE
81+
#endif

0 commit comments

Comments
 (0)