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
11 changes: 10 additions & 1 deletion exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ class Recordable final : public sdk::trace::Recordable
void SetAttribute(nostd::string_view key,
const opentelemetry::common::AttributeValue &value) noexcept override;

void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override;
void AddEvent(
nostd::string_view name,
core::SystemTimestamp timestamp = core::SystemTimestamp(std::chrono::system_clock::now()),
const trace::KeyValueIterable &attributes =
trace::KeyValueIterableView<std::map<std::string, int>>({})) noexcept override;

void AddLink(
opentelemetry::trace::SpanContext span_context,
const trace::KeyValueIterable &attributes =
trace::KeyValueIterableView<std::map<std::string, int>>({})) noexcept override;
Comment thread
nadiaciobanu marked this conversation as resolved.

void SetStatus(trace::CanonicalCode code, nostd::string_view description) noexcept override;

Expand Down
12 changes: 11 additions & 1 deletion exporters/otlp/src/recordable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,21 @@ void Recordable::SetAttribute(nostd::string_view key,
}
}

void Recordable::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept
void Recordable::AddEvent(nostd::string_view name,
core::SystemTimestamp timestamp,
const trace::KeyValueIterable &attributes) noexcept
{
auto *event = span_.add_events();
event->set_name(name.data(), name.size());
event->set_time_unix_nano(timestamp.time_since_epoch().count());
// TODO: handle attributes
}

void Recordable::AddLink(opentelemetry::trace::SpanContext span_context,
const trace::KeyValueIterable &attributes) noexcept
{
(void)span_context;
(void)attributes;
}

void Recordable::SetStatus(trace::CanonicalCode code, nostd::string_view description) noexcept
Expand Down
22 changes: 21 additions & 1 deletion sdk/include/opentelemetry/sdk/trace/recordable.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
#include "opentelemetry/core/timestamp.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/trace/canonical_code.h"
#include "opentelemetry/trace/key_value_iterable.h"
#include "opentelemetry/trace/key_value_iterable_view.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/trace_id.h"
#include "opentelemetry/version.h"

#include <map>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
Expand Down Expand Up @@ -46,8 +51,23 @@ class Recordable
* Add an event to a span.
* @param name the name of the event
* @param timestamp the timestamp of the event
* @param attributes the attributes associated with the event
*/
virtual void AddEvent(
nostd::string_view name,
core::SystemTimestamp timestamp = core::SystemTimestamp(std::chrono::system_clock::now()),
const trace_api::KeyValueIterable &attributes =
trace_api::KeyValueIterableView<std::map<std::string, int>>({})) noexcept = 0;

/**
* Add a link to a span.
* @param span_context the span context of the linked span
* @param attributes the attributes associated with the link
*/
virtual void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept = 0;
virtual void AddLink(
opentelemetry::trace::SpanContext span_context,
const trace_api::KeyValueIterable &attributes =
trace_api::KeyValueIterableView<std::map<std::string, int>>({})) noexcept = 0;

/**
* Set the status of the span.
Expand Down
16 changes: 15 additions & 1 deletion sdk/include/opentelemetry/sdk/trace/span_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,23 @@ class SpanData final : public Recordable
attributes_[std::string(key)] = nostd::visit(converter_, value);
}

void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override
void AddEvent(
nostd::string_view name,
core::SystemTimestamp timestamp = core::SystemTimestamp(std::chrono::system_clock::now()),
const trace_api::KeyValueIterable &attributes =
trace_api::KeyValueIterableView<std::map<std::string, int>>({})) noexcept override
{
events_.push_back(SpanDataEvent(std::string(name), timestamp));
// TODO: handle attributes
}

void AddLink(
opentelemetry::trace::SpanContext span_context,
const trace_api::KeyValueIterable &attributes =
trace_api::KeyValueIterableView<std::map<std::string, int>>({})) noexcept override
{
(void)span_context;
(void)attributes;
}

void SetStatus(trace_api::CanonicalCode code, nostd::string_view description) noexcept override
Expand Down