Skip to content

Commit

Permalink
[currencyService] Update OTel dependency (open-telemetry#991)
Browse files Browse the repository at this point in the history
* Update currency service OTel dependency

* changelog

---------

Co-authored-by: Austin Parker <[email protected]>
  • Loading branch information
2 people authored and AlexanderWert committed Jul 24, 2023
1 parent 46c5133 commit a8909a1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ release.
([#972](https://github.com/open-telemetry/opentelemetry-demo/pull/972))
* Update frontendproxy's env for minimal
([#983](https://github.com/open-telemetry/opentelemetry-demo/pull/983))
* [currencyService] Update OTel dependency
([#991](https://github.com/open-telemetry/opentelemetry-demo/pull/991))
* [LoadGenerator & RecommendatationService] update dependencies
([#988](https://github.com/open-telemetry/opentelemetry-demo/pull/988))
* [FraudDetectionService] Updated Kotlin version and OTel dependencies
Expand Down
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 a8909a1

Please sign in to comment.