This repository was archived by the owner on Apr 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Extended SetAttribute() method to include all integer types #6
Merged
IlyaKobelevskiy
merged 4 commits into
GoogleCloudPlatform:master
from
snehilchopra:extend_attributes
Aug 12, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #include "exporters/trace/gcp_exporter/recordable.h" | ||
| #include <assert.h> | ||
|
|
||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
|
|
@@ -34,31 +33,60 @@ void Recordable::SetIds(trace::TraceId trace_id, | |
|
|
||
|
|
||
| void Recordable::SetAttribute(nostd::string_view key, | ||
| const common::AttributeValue &&value) noexcept | ||
| const common::AttributeValue &value) noexcept | ||
| { | ||
| // Get the protobuf span's map | ||
| auto map = span_.mutable_attributes()->mutable_attribute_map(); | ||
| auto* map = span_.mutable_attributes()->mutable_attribute_map(); | ||
|
|
||
| if(nostd::holds_alternative<bool>(value)) | ||
| { | ||
| (*map)[std::string(key)].set_bool_value(nostd::get<bool>(value)); | ||
| (*map)[key.data()].set_bool_value(nostd::get<bool>(value)); | ||
| } | ||
| else if (nostd::holds_alternative<int>(value)) | ||
| { | ||
| (*map)[key.data()].set_int_value(nostd::get<int>(value)); | ||
| } | ||
| else if (nostd::holds_alternative<int64_t>(value)) | ||
| { | ||
| (*map)[std::string(key)].set_int_value(nostd::get<int64_t>(value)); | ||
| (*map)[key.data()].set_int_value(nostd::get<int64_t>(value)); | ||
| } | ||
| else if (nostd::holds_alternative<unsigned int>(value)) | ||
| { | ||
| (*map)[key.data()].set_int_value(nostd::get<unsigned int>(value)); | ||
| } | ||
| else if (nostd::holds_alternative<uint64_t>(value)) | ||
| { | ||
| (*map)[key.data()].set_int_value(nostd::get<uint64_t>(value)); | ||
| } | ||
| else if (nostd::holds_alternative<int64_t>(value)) | ||
| { | ||
| (*map)[key.data()].set_int_value(nostd::get<int64_t>(value)); | ||
| } | ||
| else if (nostd::holds_alternative<nostd::string_view>(value)) | ||
| { | ||
| // TODO: Truncate string to 128 bytes | ||
| std::string value_str = std::string(nostd::get<nostd::string_view>(value)); | ||
| (*map)[std::string(key)].mutable_string_value()->set_value(value_str); | ||
| (*map)[key.data()].mutable_string_value()->set_value(value_str); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| void Recordable::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept | ||
| void Recordable::AddEvent(nostd::string_view name, | ||
| core::SystemTimestamp timestamp, | ||
| const opentelemetry::trace::KeyValueIterable &attributes) noexcept | ||
| { | ||
| (void)name; | ||
| (void)timestamp; | ||
| (void)attributes; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I go with unnamed parameters here and below? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what is the spec, but I think those parameters are unused for a short term. |
||
| } | ||
|
|
||
|
|
||
| void Recordable::AddLink( | ||
| opentelemetry::trace::SpanContext span_context, | ||
| const opentelemetry::trace::KeyValueIterable &attributes) noexcept | ||
| { | ||
| (void)span_context; | ||
| (void)attributes; | ||
| } | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.