Skip to content

Commit

Permalink
Update currency service OTel dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliano Costa committed Jul 21, 2023
1 parent 9ae9528 commit 64bfc0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
17 changes: 4 additions & 13 deletions src/currencyservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine as builder
FROM alpine

RUN apk update
RUN apk add git cmake make g++ grpc-dev re2-dev protobuf-dev c-ares-dev

ARG OPENTELEMETRY_CPP_VERSION=1.9.0
ARG OPENTELEMETRY_CPP_VERSION=1.10.0

RUN git clone https://github.com/open-telemetry/opentelemetry-cpp \
&& cd opentelemetry-cpp/ \
Expand All @@ -28,7 +28,7 @@ RUN git clone https://github.com/open-telemetry/opentelemetry-cpp \
&& cd build \
&& cmake .. -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \
-DWITH_EXAMPLES=OFF -DWITH_OTLP=ON -DWITH_OTLP_GRPC=ON \
-DWITH_EXAMPLES=OFF -DWITH_OTLP_GRPC=ON \
&& make -j$(nproc || sysctl -n hw.ncpu || echo 1) install && cd ../.. && rm -rf opentelemetry-cpp

COPY . /currencyservice
Expand All @@ -38,14 +38,5 @@ RUN cd /currencyservice \
&& cmake .. \
&& make -j$(nproc || sysctl -n hw.ncpu || echo 1) install

FROM alpine

WORKDIR /usr/src/app/

RUN apk update
RUN apk add grpc-dev re2-dev protobuf-dev c-ares-dev

COPY --from=builder /usr/local/bin/currencyservice ./

EXPOSE ${CURRENCY_SERVICE_PORT}
ENTRYPOINT ./currencyservice ${CURRENCY_SERVICE_PORT}
ENTRYPOINT ./usr/local/bin/currencyservice ${CURRENCY_SERVICE_PORT}
11 changes: 7 additions & 4 deletions src/currencyservice/src/tracer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "opentelemetry/exporters/ostream/span_exporter_factory.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/sdk/trace/simple_processor_factory.h"
#include "opentelemetry/sdk/trace/tracer_context.h"
#include "opentelemetry/sdk/trace/tracer_context_factory.h"
#include "opentelemetry/sdk/trace/tracer_provider_factory.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"
Expand Down Expand Up @@ -76,14 +77,16 @@ void initTracer()
opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(exporter));
std::vector<std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor>> processors;
processors.push_back(std::move(processor));
std::shared_ptr<opentelemetry::sdk::trace::TracerContext> context =

auto context =
opentelemetry::sdk::trace::TracerContextFactory::Create(std::move(processors));
std::shared_ptr<opentelemetry::trace::TracerProvider> provider =
opentelemetry::sdk::trace::TracerProviderFactory::Create(context);
// Set the global trace provider
opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(context));

// Set the global trace provider
opentelemetry::trace::Provider::SetTracerProvider(provider);

// set global propagator
// set global propagator
opentelemetry::context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(
opentelemetry::nostd::shared_ptr<opentelemetry::context::propagation::TextMapPropagator>(
new opentelemetry::trace::propagation::HttpTraceContext()));
Expand Down

0 comments on commit 64bfc0b

Please sign in to comment.