Skip to content

Commit

Permalink
fix: [RTD-2262] Wrong otel logging filter (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
petretiandrea authored Nov 28, 2023
1 parent a16f93c commit 214d5b5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM maven:3.9.0-amazoncorretto-17@sha256:0d683f66624265935e836c9d2c3851ce3cf250cb48c9929d979d8d80f62d8590 as buildtime
FROM maven:3.9.0-amazoncorretto-17@sha256:0d683f66624265935e836c9d2c3851ce3cf250cb48c9929d979d8d80f62d8590 AS buildtime

WORKDIR /build
COPY . .

RUN mvn clean package -DskipTests

FROM amazoncorretto:17.0.6-al2@sha256:86ad3a5620d6f7590f59fb6067b98687367e49e632a5ee719fb03bc9ffd1499f as runtime
FROM amazoncorretto:17.0.6-al2@sha256:86ad3a5620d6f7590f59fb6067b98687367e49e632a5ee719fb03bc9ffd1499f AS runtime

VOLUME /tmp
WORKDIR /app
Expand All @@ -14,7 +14,5 @@ RUN useradd --uid 10000 runner
USER 10000

COPY --from=buildtime /build/target/*.jar /app/app.jar
# The agent is enabled at runtime via JAVA_TOOL_OPTIONS.
ADD https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.4.7/applicationinsights-agent-3.4.7.jar /app/applicationinsights-agent.jar

ENTRYPOINT ["java","-jar","/app/app.jar"]
8 changes: 1 addition & 7 deletions helm/rtd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,10 @@ microservice-chart:
runAsUser: 10000
runAsGroup: 10000

envConfig:
APPLICATIONINSIGHTS_PREVIEW_PROFILER_ENABLED: "false"

envSecret:
MONGODB_CONNECTION_URI: mongo-db-connection-uri
APPLICATIONINSIGHTS_CONNECTION_STRING: appinsights-instrumentation-key

envConfigMapExternals:
rtdsenderauth:
JAVA_TOOL_OPTIONS: JAVA_TOOL_OPTIONS
APPLICATIONINSIGHTS_ROLE_NAME: APPLICATIONINSIGHTS_ROLE_NAME
APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL: APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL
APPLICATIONINSIGHTS_INSTRUMENTATION_MICROMETER_ENABLED: APPLICATIONINSIGHTS_INSTRUMENTATION_MICROMETER_ENABLED
OPENTELEMETRY_LOG_LEVEL: APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>it.gov.pagopa.rtd.ms</groupId>
<artifactId>rtd-ms-sender-auth</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<name>rtd-ms-sender-auth</name>
<description>micro-service responsible to store the association between sender code and api key</description>
<properties>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ management:
enabled: true

applicationinsights.enabled: '@applicationinsights.enabled@'
otel.log.level: ${OPENTELEMETRY_LOG_LEVEL:INFO}
otel.instrumentation.logback-appender.enabled: true # enable logback instrumentation
otel.traces.sampler.probability: 1.0 # sample probability for tracing (spans)
otel.metric.export.interval: 60000 # sampling rate for metrics (millis)
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
<charset>utf8</charset>
</encoder>
</appender>

<springProperty scope="context" name="otelLogLevel" source="otel.log.level" defaultValue="INFO"/>
<appender name="OpenTelemetry"
class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
<captureExperimentalAttributes>true</captureExperimentalAttributes>
<captureMdcAttributes>*</captureMdcAttributes>
<!-- Set the logging level for OpenTelemetry from the environment variable -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${otelLogLevel}</level>
</filter>
</appender>

<root level="INFO">
Expand Down

0 comments on commit 214d5b5

Please sign in to comment.