Having some trouble setting up agent for this particular project.
:java-source-paths ["java_src"]
:jvm-opts ["-javaagent:grafana-opentelemetry-java.jar"
"-Dotel.resource.attributes=service.name=dev-webserver"
"-Dotel.metrics.exporter=prometheus"
"-Dotel.metric.export.interval=5000"
"-Dotel.logs.exporter=none"
"-Dotel.traces.exporter=none"
]
these options together causes lein repl to be stuck
Leiningen 2.11.2 on Java 11.0.23 OpenJDK 64-Bit Server VM
Without java_src - projects starts fine
without jvm-opts - project starts fine
This is reproducible with basic lein new app, add agent, add java class and java-source-paths -> lein repl -> gets stuck after
Compiling 1 source files to /target/classes
What am i doing wrong here?I don't use lein but I suspect the issue lies with the project setup. If you publish your full project then hopefully someone can help out with your lein setup.
Remember also that applications run with the agent can take longer to start.
It's not that for sure. Without java-source-paths repl starts within 20sec. With it it's just stuck on the step i wrote above. I will see if i can recreate it with deps.edn
Just so I'm clear, you have not added any clj-otel dependencies to the project?
Exactly. I haven't added any clj-otel.
[[org.clojure/clojure "1.11.1"]
[software.amazon.glue/schema-registry-serde "1.1.17"]]
these are deps at the moment.
I will share the link to minimum example soon
By the way i am not going to setup deps.edn project i am not verse in it enough to do this fast enough. It doesn't have java-source-paths equivalent.Also i asked in #leiningen but they forwarded me back here 😄
I don't see where Prometheus is started in your project. In the clj-otel microservices examples, I use Docker Compose to start the application and Prometheus instances.
As is stands, when starting your project the agent would complain it can't reach Prometheus, as there is no instance for it to talk to.
Just tried it. Doesn't work. Same behavior
Used the same setup from the project that is using agent but doesn't have java-source-paths
lein repl
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[otel.javaagent 2024-06-14 21:30:41:642 +0000] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 2.4.0
[otel.javaagent 2024-06-14 21:30:41:673 +0000] [main] INFO com.grafana.extensions.instrumentations.TestedInstrumentationsContext - Grafana OpenTelemetry Javaagent: version=2.4.0-beta.1, includeAllInstrumentations=true, useTestedInstrumentations=false, includedUntestedInstrumentations=[], excludedInstrumentations=[]
[otel.javaagent 2024-06-14 21:30:41:675 +0000] [main] INFO com.grafana.extensions.cloud.GrafanaCloudConfigCustomizer - will not attempt to send data to Grafana Cloud: zone is not set
[otel.javaagent 2024-06-14 21:30:41:744 +0000] [main] INFO io.opentelemetry.sdk.resources.Resource - Attempting to merge Resources with different schemaUrls. The resulting Resource will have no schemaUrl assigned. Schema 1: Schema 2:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
Warning: protocol #'java-time.core/Amount is overwriting function abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: java-time.core, being replaced by: #'java-time.core/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: java-time, being replaced by: #'java-time/abs
Reflection warning, jackdaw/data/consumer.clj:20:3 - call to org.apache.kafka.clients.consumer.ConsumerRecord ctor can't be resolved.
Compiling 1 source files to /<path>target/classes Are you using Grafana Cloud, or attempting to use a backend deployed locally on your machine?
I am not using grafana cloud. I am attempting to just start the app locally yes
Then you need to use the regular OpenTelemetry instrumentation agent, not grafana-opentelemetry-java.jar. Download the agent opentelemetry-javaagent.jar from https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases
I switched. Behavior is the same and output is
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[otel.javaagent 2024-06-14 23:40:18:487 +0200] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 2.4.0
Compiling 1 source files to /home/marko/clojure/helper/mini-projects/test-agent/target/classesHave you also got a Prometheus instance running? How are you starting that?
Simple docker compose
prometheus:
network_mode: "host"
image: prom/prometheus
volumes:
- ./dev-resources/otel/prometheus2.yml:/etc/prometheus/prometheus.yml
Yes prometheus container is running.
Even agent is running because
gives me results
But repl isn't startingCould you update your test project so I can reproduce your setup? I don't use lein at all so it will take me some time to analyse.
You mean to convert it to deps.edn project?
I mean include details like your Docker Compose files, prometheus.yaml and any other files so that I can reproduce the issue. There is likely some issue with the project setup.
I pushed.
Here are the steps
docker-compose up
and then
lein repl
it's hanging.
Commenting out java-source-pahts everything works
Not sure if this affects it, but I noticed your test project uses a different method than divisor-app for the Prometheus instance to access the local machine. https://github.com/steffan-westcott/clj-otel/tree/master/examples/divisor-app
I tried, same behavior. I think it's related to lein somehow. i created an issue: https://github.com/technomancy/leiningen/issues/2818
I spotted something : You should use the command docker compose up, not docker-compose up These are different commands, despite looking very similar!
Thank you very much for spending time and looking into this i appreciate it 🙇
I have recreated your issue, but I'm at a loss as to what is happening. Perhaps someone who knows how lein works can help you.
it must be some interaction between agent, jvm and lein that is causing this. I will see what comes out of the issue i created. Thank you again 🙇
I do note this in the Leiningen docs:
> To pass extra arguments to the JVM, set the :jvm-opts vector. This will override any default JVM opts set by Leiningen.
So I'm guessing that there are some opts needed by lein to make the REPL work. It's not clear to me if the JVM opts you supply are added with the default ones, or replace them entirely.
I can see the thread in #leiningen has a useful suggestion about separating the build and run steps. lein definitely tries to be too automatic (magical) and ends up being quite brittle, from what I know of it.
Yeah, maybe we will switch to deps.edn because of this 😄 or at least have an option for local dev
I would strongly recommend using deps.edn for any project, you have good control on what is happening. tools.build documentation says that builds are programs, which I find is a powerful truth!
I've written more than my fair share of Makefiles, Ant, Maven and Gradle build files to know this 😄
Compiling Java source files is done with clojure.tools.build.api/javac . Your build.clj would be quite simple, like this https://clojure.org/guides/tools_build#_mixed_java_clojure_build