From ca8e0f4d4f92ad0d51822041e8f1641b4fb84eb0 Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Mon, 29 Jul 2024 16:46:28 +0200 Subject: [PATCH] feat: decrease stack traces min duration (#35) * feat: decrease stack traces min duration * docs: add kafka agent modification --- .env.override | 1 + .github/README.md | 2 +- .../component_build-images-elastic.yml | 2 +- src/adservice/Dockerfile.elastic | 1 + src/frauddetectionservice/Dockerfile.elastic | 1 + src/kafka/Dockerfile.elastic | 30 +++++++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/kafka/Dockerfile.elastic diff --git a/.env.override b/.env.override index 53ffb483f9..6b73013ac2 100644 --- a/.env.override +++ b/.env.override @@ -10,6 +10,7 @@ IMAGE_NAME=ghcr.io/elastic/opentelemetry-demo # ********************* AD_SERVICE_DOCKERFILE=./src/adservice/Dockerfile.elastic FRAUD_SERVICE_DOCKERFILE=./src/frauddetectionservice/Dockerfile.elastic +KAFKA_SERVICE_DOCKERFILE=./src/kafka/Dockerfile.elastic # ********************* # Elastic Collector diff --git a/.github/README.md b/.github/README.md index 8136108a34..0ab925eefb 100644 --- a/.github/README.md +++ b/.github/README.md @@ -3,7 +3,7 @@ The following guide describes how to setup the OpenTelemetry demo with Elastic Observability using [Docker compose](#docker-compose) or [Kubernetes](#kubernetes). This fork introduces several changes to the agents used in the demo: -- The Java agent within the [Ad](../src/adservice/Dockerfile.elastic) and [Fraud Detection](../src/frauddetectionservice/Dockerfile.elastic) services have been replaced with the Elastic distribution of the OpenTelemetry Java Agent. You can find more information about the Elastic distribution in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-distribution-opentelemetry-java-agent). +- The Java agent within the [Ad](../src/adservice/Dockerfile.elastic), the [Fraud Detection](../src/frauddetectionservice/Dockerfile.elastic) and the [Kafka](../src/kafka/Dockerfile.elastic) services have been replaced with the Elastic distribution of the OpenTelemetry Java Agent. You can find more information about the Elastic distribution in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-distribution-opentelemetry-java-agent). - The .NET agent within the [Cart service](../src/cartservice/src/Directory.Build.props) has been replaced with the Elastic distribution of the OpenTelemetry .NET Agent. You can find more information about the Elastic distribution in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-opentelemetry-distribution-dotnet-applications). - The Elastic distribution of the OpenTelemetry Node.js Agent has replaced the OpenTelemetry Node.js agent in the [Payment service](../src/paymentservice/package.json). Additional details about the Elastic distribution are available in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-opentelemetry-distribution-node-js). diff --git a/.github/workflows/component_build-images-elastic.yml b/.github/workflows/component_build-images-elastic.yml index 200c51ed94..84b2761db9 100644 --- a/.github/workflows/component_build-images-elastic.yml +++ b/.github/workflows/component_build-images-elastic.yml @@ -72,7 +72,7 @@ jobs: tag_suffix: imageprovider context: ./ setup-qemu: true - - file: ./src/kafka/Dockerfile + - file: ./src/kafka/Dockerfile.elastic tag_suffix: kafka context: ./ setup-qemu: true diff --git a/src/adservice/Dockerfile.elastic b/src/adservice/Dockerfile.elastic index 593134839e..38abe4a9cf 100644 --- a/src/adservice/Dockerfile.elastic +++ b/src/adservice/Dockerfile.elastic @@ -23,6 +23,7 @@ COPY --from=builder /usr/src/app/ ./ ADD --chmod=644 https://repo1.maven.org/maven2/co/elastic/otel/elastic-otel-javaagent/$version/elastic-otel-javaagent-$version.jar /usr/src/app/opentelemetry-javaagent.jar ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar ENV ELASTIC_OTEL_INFERRED_SPANS_ENABLED=true +ENV ELASTIC_OTEL_SPAN_STACK_TRACE_MIN_DURATION=2 EXPOSE ${AD_SERVICE_PORT} ENTRYPOINT [ "./build/install/opentelemetry-demo-ad-service/bin/AdService" ] diff --git a/src/frauddetectionservice/Dockerfile.elastic b/src/frauddetectionservice/Dockerfile.elastic index cf600cd914..15e1e1bde8 100644 --- a/src/frauddetectionservice/Dockerfile.elastic +++ b/src/frauddetectionservice/Dockerfile.elastic @@ -17,5 +17,6 @@ COPY --from=builder /usr/src/app/build/libs/frauddetectionservice-1.0-all.jar ./ ADD --chmod=644 https://repo1.maven.org/maven2/co/elastic/otel/elastic-otel-javaagent/$version/elastic-otel-javaagent-$version.jar /app/opentelemetry-javaagent.jar ENV JAVA_TOOL_OPTIONS=-javaagent:/app/opentelemetry-javaagent.jar ENV ELASTIC_OTEL_INFERRED_SPANS_ENABLED=true +ENV ELASTIC_OTEL_SPAN_STACK_TRACE_MIN_DURATION=2 ENTRYPOINT [ "java", "-jar", "frauddetectionservice-1.0-all.jar" ] diff --git a/src/kafka/Dockerfile.elastic b/src/kafka/Dockerfile.elastic new file mode 100644 index 0000000000..350c8378fc --- /dev/null +++ b/src/kafka/Dockerfile.elastic @@ -0,0 +1,30 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + + +FROM apache/kafka:3.7.0 + +USER root +ARG version=0.4.0 + +USER appuser + +ADD --chown=appuser:appuser https://repo1.maven.org/maven2/co/elastic/otel/elastic-otel-javaagent/$version/elastic-otel-javaagent-$version.jar /tmp/opentelemetry-javaagent.jar + +ENV ELASTIC_OTEL_INFERRED_SPANS_ENABLED=true +ENV ELASTIC_OTEL_SPAN_STACK_TRACE_MIN_DURATION=2 +ENV KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093 +ENV KAFKA_CONTROLLER_QUORUM_VOTERS='1@0.0.0.0:9093' +ENV KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER +ENV KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT +ENV KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0 +ENV KAFKA_PROCESS_ROLES=controller,broker +ENV KAFKA_NODE_ID=1 +ENV KAFKA_METADATA_LOG_SEGMENT_MS=15000 +ENV KAFKA_METADATA_MAX_RETENTION_MS=60000 +ENV KAFKA_METADATA_LOG_MAX_RECORD_BYTES_BETWEEN_SNAPSHOTS=2800 +ENV KAFKA_AUTO_CREATE_TOPICS_ENABLE=true +ENV KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 +ENV KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 +ENV KAFKA_OPTS="-javaagent:/tmp/opentelemetry-javaagent.jar -Dotel.jmx.target.system=kafka-broker" +ENV CLUSTER_ID=ckjPoprWQzOf0-FuNkGfFQ