Replies: 1 comment 1 reply
-
@r03942139 - Thanks for moving this over discussions. Regarding the error, resources should be set through opentelemetry-cpp/examples/batch/main.cc Lines 34 to 44 in 1f31341 Don't set resource through |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My platform info:
Platform - alpine:3.12.7
opentelemetry-cpp - 1.0.0-rc2
Build - cmake 3.17.2
/usr/bin/c++: (Alpine 9.3.0) 9.3.0
/usr/bin/cc: (Alpine 9.3.0) 9.3.0
Steps to reproduce
bash-5.0$ c++ -I/opt/ats/include -I/usr/local/include -I/opentelemetry-cpp-1.0.0-rc3/exporters/jaeger/include -I/opentelemetry-cpp-1.0.0-rc3/exporters/jaeger/src -I/opentelemetry-cpp-1.0.0-rc3/exporters/jaeger/src -I/opentelemetry-cpp-1.0.0-rc3/exporters/jaeger/thrift-gen -std=c++17 -ggdb3 -pipe -Wall -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-format-truncation -Wno-cast-function-type -Wno-stringop-overflow -Wno-invalid-offsetof -Wno-noexcept-type -mcx16 -fpic -c main.cc -o main.lo -lopentelemetry_trace -ljaeger_trace_exporter -lopentelemetry_version -lopentelemetry_resources -lopentelemetry_exporter_ostream_span -lopentelemetry_zpages -lopentelemetry_common -lhttp_client_curl -lthrift -lthriftnb -lthriftz
main.cc:34:1: error: 'rec' does not name a type
34 | rec.SetResource(resource);
| ^~~
---- Discussions/Supports required ----
The rec is previously assigned to class opentelemetry::exporter::jaeger::Recordable rec;
But the assign later is not working.
rec.SetResource(resource);
---- My main.cc related code ----
#include "opentelemetry/exporters/jaeger/recordable.h"
#include "opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h"
#include "opentelemetry/exporters/jaeger/jaeger_exporter.h"
#include "opentelemetry/sdk/trace/simple_processor.h"
#include "opentelemetry/sdk/trace/span_data.h"
#include "opentelemetry/sdk/trace/tracer_provider.h"
#include "opentelemetry/trace/provider.h"
#include
#include
#define PLUGIN_NAME "hello_world"
namespace trace = opentelemetry::trace;
namespace nostd = opentelemetry::nostd;
namespace sdktrace = opentelemetry::sdk::trace;
namespace jaeger = opentelemetry::exporter::jaeger;
using namespace jaegertracing;
using namespace opentelemetry::exporter::jaeger;
using namespace opentelemetry::sdk::instrumentationlibrary;
namespace
{
opentelemetry::exporter::jaeger::JaegerExporterOptions opts;
opentelemetry::exporter::jaeger::Recordable rec;
const std::string service_name_key = "service.name";
std::string service_name_value = "test-jaeger-service-name";
auto resource = opentelemetry::sdk::resource::Resource::Create(
{{service_name_key, service_name_value}, {"key1", "value1"}, {"key2", "value2"}});
rec.SetResource(resource);
nostd::shared_ptrtrace::Tracer get_tracer()
{
auto provider = trace::Provider::GetTracerProvider();
return provider->GetTracer("foo_library", OPENTELEMETRY_SDK_VERSION);
}
void InitTracer()
{
// Create Jaeger exporter instance
auto exporter = std::unique_ptrsdktrace::SpanExporter(new jaeger::JaegerExporter(opts));
auto processor = std::unique_ptrsdktrace::SpanProcessor(
new sdktrace::SimpleSpanProcessor(std::move(exporter)));
auto provider =
nostd::shared_ptrtrace::TracerProvider(new sdktrace::TracerProvider(std::move(processor)));
// Set the global trace provider
trace::Provider::SetTracerProvider(provider);
}
void foo_library()
{
auto scoped_span = trace::Scope(get_tracer()->StartSpan("library"));
}
} // namespace
int main() {
.......
}
The lib I installed
bash-5.0$ ls /usr/local/lib64
cmake libgtest_main.a libopentelemetry_trace.a
libbenchmark.a libhttp_client_curl.a libopentelemetry_version.a
libbenchmark_main.a libjaeger_trace_exporter.a libopentelemetry_zpages.a
libgmock.a libopentelemetry_common.a pkgconfig
libgmock_main.a libopentelemetry_exporter_ostream_span.a
libgtest.a libopentelemetry_resources.a
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions