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

IgnoredTypesConfigurer SPI does not work due to package shading #4049

Closed
edwardxia opened this issue Sep 2, 2021 · 5 comments · Fixed by #4064
Closed

IgnoredTypesConfigurer SPI does not work due to package shading #4049

edwardxia opened this issue Sep 2, 2021 · 5 comments · Fixed by #4064
Labels
bug Something isn't working

Comments

@edwardxia
Copy link

edwardxia commented Sep 2, 2021

Caused by: java.lang.AbstractMethodError: Receiver class MyIgnoredTypesConfigurer does not define or inherit an implementation of the resolved method 'abstract void configure(io.opentelemetry.javaagent.shaded.instrumentation.api.config.Config, io.opentelemetry.javaagent.extension.ignore.IgnoredTypesBuilder)' of interface io.opentelemetry.javaagent.extension.ignore.IgnoredTypesConfigurer.

My class implement the SPI interface and takes io.opentelemetry.instrumentation.api.config.Config as argument, but when this is loaded from agent it is expecting the shaded class io.opentelemetry.javaagent.shaded.instrumentation.api.config.Config, causing it to break.

@edwardxia edwardxia added the bug Something isn't working label Sep 2, 2021
@edwardxia
Copy link
Author

Adding a package relocation rule in my project fixed this. However, other things like custom exporter provider spi etc. do not need package relocation to work.

@mateuszrzeszutek
Copy link
Member

Hey @edwardxia ,
What's your use case - are you developing a custom distro or an extension? You shouldn't need to relocate anything in the case of implementing a custom extension.

@edwardxia
Copy link
Author

Extension loaded by -Dotel.javaagent.extensions. My understanding is that I shouldn't need to relocate, thus I think it is a bug.

@edwardxia
Copy link
Author

import com.google.auto.service.AutoService;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.extension.ignore.IgnoredTypesBuilder;
import io.opentelemetry.javaagent.extension.ignore.IgnoredTypesConfigurer;

@AutoService(IgnoredTypesConfigurer.class)
public class FabanIgnoredTypesConfigurer implements IgnoredTypesConfigurer {
    @Override
    public void configure(Config config, IgnoredTypesBuilder builder) {
        builder.allowClass("com.sun.faban.");
    }

    @Override
    public int order() {
        return 1;
    }
}

@trask
Copy link
Member

trask commented Sep 8, 2021

oh no! the runtime shading for the extensions

rule(
"#io.opentelemetry.instrumentation",
"#io.opentelemetry.javaagent.shaded.io.opentelemetry.instrumentation"),

doesn't quite match the compile-time shading:

relocate("io.opentelemetry.instrumentation", "io.opentelemetry.javaagent.shaded.instrumentation")

I will send a PR to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants