Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Security 6.0.1 ObservationFilterChainDecorator produce wrong instrument names #12490

Closed
rschlick opened this issue Jan 6, 2023 · 4 comments
Assignees
Labels
in: web An issue in web modules (web, webmvc) type: bug A general bug
Milestone

Comments

@rschlick
Copy link

rschlick commented Jan 6, 2023

Describe the bug

Open Telemetry Java Agent version 1.21 don't like the Instrument names produces by Spring Security 6.0 (from Class ObservationFilterChainDecorator)

Here is the WARNING Log :

WARN io.opentelemetry.ApiUsageLogging - Instrument name "spring.security.filterchains.DisableEncodeUrlFilter before" is invalid, returning noop instrument. Instrument names must consist of 63 or fewer characters including alphanumeric, _, ., -, and start with a letter.

The instrument name is produced by Spring Security there :

parent.before().event(Observation.Event.of(this.name + " before"));

parent.before().event(Observation.Event.of(this.name + " before"));

I think this instrument name with a space in the name is not correct in term of good naming conventions or standard.

A bug ticket was opened in the Github of Open Telemetry Java Agent project : open-telemetry/opentelemetry-java-instrumentation#7448

They answered that the fix should be done in Spring Security project.

They believe :

that this sort of naming pattern (whitespaces) might not be accepted by at least some of the monitoring systems supported by Micrometer; it's not just OpenTelemetry that'll trip on this.

To Reproduce
Using a simple Spring Boot 3.0.1 project with Kotlin 1.7, JDK 17, Spring Boot 3.0.1 and Spring Security 6.0 and Maven.
Using Open Telemetry java Agent v 1.21.
Application is running in a docker container, but you can reproduce the problem with a java -jar springboot.jar -javaagent:opentelemetry-javaagent-all.jar

Docker File :

ARG OPENJDK_IMAGE=openjdk:17-slim-bullseye
ARG USER=app
ARG WORKDIR=/app
ARG OPENTELEMETRY_VERSION=1.21.0
ARG OPENTELEMETRY_REPO="https://github.com/open-telemetry/opentelemetry-java-instrumentation"
ARG OPENTELEMETRY_JAR_PATH="/releases/download/v${OPENTELEMETRY_VERSION}/opentelemetry-javaagent.jar"
ARG OPENTELEMETRY_JAR=opentelemetry-javaagent-all.jar

# Build
FROM busybox:stable AS builder

ARG USER
ARG WORKDIR
ARG OPENTELEMETRY_REPO
ARG OPENTELEMETRY_JAR_PATH
ARG OPENTELEMETRY_JAR

RUN addgroup ${USER} \
    && adduser -D -H -G ${USER} ${USER}

WORKDIR ${WORKDIR}

RUN wget -O ${OPENTELEMETRY_JAR} ${OPENTELEMETRY_REPO}${OPENTELEMETRY_JAR_PATH}

# Main
FROM ${OPENJDK_IMAGE}

ARG USER
ARG WORKDIR
ARG OPENTELEMETRY_JAR

COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/passwd /etc/passwd

USER ${USER}:${USER}
WORKDIR ${WORKDIR}

ENV JAVA_TOOL_OPTIONS=-javaagent:${OPENTELEMETRY_JAR}
COPY --from=builder ${WORKDIR} .

Expected behavior

The expected behaviour is that Open Telemetry Java Agent doesn't create WARNING logs about Spring Security instrument names.

@rschlick rschlick added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Jan 6, 2023
@rschlick rschlick changed the title Spring Security 6.0 ObservationFilterChainDecorator produce wrong instrument names Spring Security 6.0.1 ObservationFilterChainDecorator produce wrong instrument names Jan 6, 2023
@jzheaux jzheaux closed this as completed in c308e46 Jan 6, 2023
@jzheaux jzheaux added this to the 6.0.2 milestone Jan 6, 2023
@jzheaux jzheaux added in: web An issue in web modules (web, webmvc) and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 6, 2023
@pierre-filliolaud
Copy link

pierre-filliolaud commented Jan 31, 2023

Hi @jzheaux , the instrument names is still invalid because the length is more than 63 characters.

Here is the stack trace:

WARN io.opentelemetry.ApiUsageLogging - Instrument name "spring.security.filterchains.SecurityContextHolderAwareRequestFilter.before" is invalid, returning noop instrument. Instrument names must consist of 63 or fewer characters including alphanumeric, _, ., -, and start with a letter. Returning noop instrument.

Test done with:
org.springframework.security:spring-security-web:6.0.2-SNAPSHOT
Regards

@olivierboudet
Copy link

Hello @rschlick I encounter this issue also, is it possible to reopen this to avoid length of more 63 characters ?

Thanks

@andrebask
Copy link

andrebask commented Feb 24, 2023

Hi @jzheaux, could we reopen this issue?
I'm also getting the same error after upgrading to spring-boot 3.0.3 (spring-security 6.0.2)
WARN io.opentelemetry.ApiUsageLogging - Instrument name "spring.security.filterchains.AnonymousAuthenticationFilter.after" is invalid, returning noop instrument. Instrument names must consist of 63 or fewer characters including alphanumeric, _, ., -, and start with a letter. Returning noop instrument.
Also, this appears to be a warning but is logged with log lever error.

@hriddhighosh4
Copy link

Hi @jzheaux, I also got the error in spring 3.0.3. Please reopen the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

6 participants