From 8684a33feaa4419af12a99ad0d95cd838236bdf4 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Mon, 12 Feb 2024 13:37:12 -0800 Subject: [PATCH] Remove namespace using in ETW exporter which affects global namespace (#2531) --- .../exporters/etw/etw_provider.h | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h index 0ffccebc0b..7dc2bad0ff 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h @@ -50,7 +50,7 @@ #define MICROSOFT_EVENTTAG_NORMAL_PERSISTENCE 0x01000000 -using namespace OPENTELEMETRY_NAMESPACE::exporter::etw; +namespace exporter_etw = OPENTELEMETRY_NAMESPACE::exporter::etw; OPENTELEMETRY_BEGIN_NAMESPACE @@ -237,7 +237,7 @@ class ETWProvider } unsigned long writeMsgPack(Handle &providerData, - Properties &eventData, + exporter_etw::Properties &eventData, LPCGUID ActivityId = nullptr, LPCGUID RelatedActivityId = nullptr, uint8_t Opcode = 0) @@ -268,10 +268,10 @@ class ETWProvider switch (nameField.index()) { - case PropertyType::kTypeString: + case exporter_etw::PropertyType::kTypeString: eventName = (char *)(nostd::get(nameField).data()); // must be 0-terminated! break; - case PropertyType::kTypeCString: + case exporter_etw::PropertyType::kTypeCString: eventName = (char *)(nostd::get(nameField)); break; default: @@ -298,41 +298,41 @@ class ETWProvider auto &value = kv.second; switch (value.index()) { - case PropertyType::kTypeBool: { + case exporter_etw::PropertyType::kTypeBool: { UINT8 temp = static_cast(nostd::get(value)); jObj[name] = temp; break; } - case PropertyType::kTypeInt: { + case exporter_etw::PropertyType::kTypeInt: { auto temp = nostd::get(value); jObj[name] = temp; break; } - case PropertyType::kTypeInt64: { + case exporter_etw::PropertyType::kTypeInt64: { auto temp = nostd::get(value); jObj[name] = temp; break; } - case PropertyType::kTypeUInt: { + case exporter_etw::PropertyType::kTypeUInt: { auto temp = nostd::get(value); jObj[name] = temp; break; } - case PropertyType::kTypeUInt64: { + case exporter_etw::PropertyType::kTypeUInt64: { auto temp = nostd::get(value); jObj[name] = temp; break; } - case PropertyType::kTypeDouble: { + case exporter_etw::PropertyType::kTypeDouble: { auto temp = nostd::get(value); jObj[name] = temp; break; } - case PropertyType::kTypeString: { + case exporter_etw::PropertyType::kTypeString: { jObj[name] = nostd::get(value); break; } - case PropertyType::kTypeCString: { + case exporter_etw::PropertyType::kTypeCString: { auto temp = nostd::get(value); jObj[name] = temp; break; @@ -348,14 +348,14 @@ class ETWProvider # endif // TODO: arrays are not supported yet - case PropertyType::kTypeSpanByte: - case PropertyType::kTypeSpanBool: - case PropertyType::kTypeSpanInt: - case PropertyType::kTypeSpanInt64: - case PropertyType::kTypeSpanUInt: - case PropertyType::kTypeSpanUInt64: - case PropertyType::kTypeSpanDouble: - case PropertyType::kTypeSpanString: + case exporter_etw::PropertyType::kTypeSpanByte: + case exporter_etw::PropertyType::kTypeSpanBool: + case exporter_etw::PropertyType::kTypeSpanInt: + case exporter_etw::PropertyType::kTypeSpanInt64: + case exporter_etw::PropertyType::kTypeSpanUInt: + case exporter_etw::PropertyType::kTypeSpanUInt64: + case exporter_etw::PropertyType::kTypeSpanDouble: + case exporter_etw::PropertyType::kTypeSpanString: default: // TODO: unsupported type break; @@ -435,7 +435,7 @@ class ETWProvider /// /// unsigned long writeTld(Handle &providerData, - Properties &eventData, + exporter_etw::Properties &eventData, LPCGUID ActivityId = nullptr, LPCGUID RelatedActivityId = nullptr, uint8_t Opcode = 0 /* Information */) @@ -459,10 +459,10 @@ class ETWProvider auto nameField = eventData[EVENT_NAME]; switch (nameField.index()) { - case PropertyType::kTypeString: + case exporter_etw::PropertyType::kTypeString: eventName = (char *)(nostd::get(nameField).data()); break; - case PropertyType::kTypeCString: + case exporter_etw::PropertyType::kTypeCString: eventName = (char *)(nostd::get(nameField)); break; default: @@ -479,48 +479,48 @@ class ETWProvider auto &value = kv.second; switch (value.index()) { - case PropertyType::kTypeBool: { + case exporter_etw::PropertyType::kTypeBool: { builder.AddField(name, tld::TypeBool8); UINT8 temp = static_cast(nostd::get(value)); dbuilder.AddByte(temp); break; } - case PropertyType::kTypeInt: { + case exporter_etw::PropertyType::kTypeInt: { builder.AddField(name, tld::TypeInt32); auto temp = nostd::get(value); dbuilder.AddValue(temp); break; } - case PropertyType::kTypeInt64: { + case exporter_etw::PropertyType::kTypeInt64: { builder.AddField(name, tld::TypeInt64); auto temp = nostd::get(value); dbuilder.AddValue(temp); break; } - case PropertyType::kTypeUInt: { + case exporter_etw::PropertyType::kTypeUInt: { builder.AddField(name, tld::TypeUInt32); auto temp = nostd::get(value); dbuilder.AddValue(temp); break; } - case PropertyType::kTypeUInt64: { + case exporter_etw::PropertyType::kTypeUInt64: { builder.AddField(name, tld::TypeUInt64); auto temp = nostd::get(value); dbuilder.AddValue(temp); break; } - case PropertyType::kTypeDouble: { + case exporter_etw::PropertyType::kTypeDouble: { builder.AddField(name, tld::TypeDouble); auto temp = nostd::get(value); dbuilder.AddValue(temp); break; } - case PropertyType::kTypeString: { + case exporter_etw::PropertyType::kTypeString: { builder.AddField(name, tld::TypeUtf8String); dbuilder.AddString(nostd::get(value).data()); break; } - case PropertyType::kTypeCString: { + case exporter_etw::PropertyType::kTypeCString: { builder.AddField(name, tld::TypeUtf8String); auto temp = nostd::get(value); dbuilder.AddString(temp); @@ -528,7 +528,7 @@ class ETWProvider } #if HAVE_TYPE_GUID // TODO: consider adding UUID/GUID to spec - case PropertyType::kGUID: { + case exporter_etw::PropertyType::kGUID: { builder.AddField(name.c_str(), TypeGuid); auto temp = nostd::get(value); dbuilder.AddBytes(&temp, sizeof(GUID)); @@ -537,14 +537,14 @@ class ETWProvider #endif // TODO: arrays are not supported - case PropertyType::kTypeSpanByte: - case PropertyType::kTypeSpanBool: - case PropertyType::kTypeSpanInt: - case PropertyType::kTypeSpanInt64: - case PropertyType::kTypeSpanUInt: - case PropertyType::kTypeSpanUInt64: - case PropertyType::kTypeSpanDouble: - case PropertyType::kTypeSpanString: + case exporter_etw::PropertyType::kTypeSpanByte: + case exporter_etw::PropertyType::kTypeSpanBool: + case exporter_etw::PropertyType::kTypeSpanInt: + case exporter_etw::PropertyType::kTypeSpanInt64: + case exporter_etw::PropertyType::kTypeSpanUInt: + case exporter_etw::PropertyType::kTypeSpanUInt64: + case exporter_etw::PropertyType::kTypeSpanDouble: + case exporter_etw::PropertyType::kTypeSpanString: default: // TODO: unsupported type break; @@ -588,7 +588,7 @@ class ETWProvider } unsigned long write(Handle &providerData, - Properties &eventData, + exporter_etw::Properties &eventData, LPCGUID ActivityId, LPCGUID RelatedActivityId, uint8_t Opcode,