Skip to content

Commit

Permalink
incorporating reviewer feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
willie committed Mar 5, 2024
1 parent bf3363c commit 0e63f5e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sdk/src/resource/resource_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "opentelemetry/sdk/resource/resource_detector.h"
#include "opentelemetry/sdk/common/env_variables.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/sdk/resource/semantic_conventions.h"

#include <sstream>
#include <string>
Expand Down Expand Up @@ -39,16 +40,19 @@ Resource OTELResourceDetector::Detect() noexcept
std::string token;
while (std::getline(iss, token, ','))
{
size_t pos = token.find('=');
std::string key = token.substr(0, pos);
std::string value = token.substr(pos + 1);
attributes[key] = value;
size_t pos = token.find('=');
if (pos != std::string::npos)
{
std::string key = token.substr(0, pos);
std::string value = token.substr(pos + 1);
attributes[key] = value;
}
}
}

if (service_name_exists)
{
attributes["service.name"] = service_name;
attributes[SemanticConventions::kServiceName] = service_name;
}

return Resource(attributes);
Expand Down

0 comments on commit 0e63f5e

Please sign in to comment.