File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 4
4
#include " opentelemetry/sdk/resource/resource_detector.h"
5
5
#include " opentelemetry/sdk/common/env_variables.h"
6
6
#include " opentelemetry/sdk/resource/resource.h"
7
+ #include " opentelemetry/sdk/resource/semantic_conventions.h"
7
8
8
9
#include < sstream>
9
10
#include < string>
@@ -39,16 +40,19 @@ Resource OTELResourceDetector::Detect() noexcept
39
40
std::string token;
40
41
while (std::getline (iss, token, ' ,' ))
41
42
{
42
- size_t pos = token.find (' =' );
43
- std::string key = token.substr (0 , pos);
44
- std::string value = token.substr (pos + 1 );
45
- attributes[key] = value;
43
+ size_t pos = token.find (' =' );
44
+ if (pos != std::string::npos)
45
+ {
46
+ std::string key = token.substr (0 , pos);
47
+ std::string value = token.substr (pos + 1 );
48
+ attributes[key] = value;
49
+ }
46
50
}
47
51
}
48
52
49
53
if (service_name_exists)
50
54
{
51
- attributes[" service.name " ] = service_name;
55
+ attributes[SemanticConventions:: kServiceName ] = service_name;
52
56
}
53
57
54
58
return Resource (attributes);
You can’t perform that action at this time.
0 commit comments