Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

The Java Pyroscope agent does not use `pyroscope.application.name ` when profiling Gradle assemblies

未关闭
#202 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

从 gradle.properties 配置以及 Gradle 将 org.gradle.jvmargs 传递给其 daemon 时 Java Pyroscope agent 的行为开始。使用 gradle clean build --no-daemon 复现,并在 Pyroscope UI 中检查生成的应用程序。完成的标准是构建报告 my-application,并带有 env=prod 和 version=1.0 标签,而不是自动生成的名称。

由索引模型根据 Issue 内容生成。

描述

Problem description

When trying to profile a Gradle project build using the Java Pyroscope agent, the application name that is set in the gradle.properties file via the system property -Dpyroscope.application.name , is not recognized and is not applied. Instead of the custom name specified in the configuration, the automatically generated default name is displayed in the Pyroscope user interface.

Expected behavior:

It is expected that after the Gradle build is completed with the java agent configured, an application with the name my-application and the corresponding tags {env=prod,version=1.0}, as it was specified in `gradle.properties'.

Current (actual) behavior:

In the Pyroscope user interface, instead of the expected name my-application, an automatically generated name is displayed, in this case javaspy.WeChRaEsRvWcEjq93mpGGg. This indicates that the agent is running and sending data, but it cannot correctly determine or apply the application name from the JVM arguments passed to the Gradle daemon.

As you can see in the attached screenshot, there is no my-application in the list of applications.

Steps to reproduce

To reproduce the problem, follow these steps::

  1. Installing and configuring the Gradle environment:
  • Downloading the Gradle distribution:
wget https://services.gradle.org/distributions/gradle-8.14.2-bin.zip
  • Creating a directory and unpacking an archive:
mkdir /opt/gradle
unzip -d /opt/gradle gradle-8.14.2-bin.zip
  • Setting up the environment variable PATH:
export PATH=$PATH:/opt/gradle/gradle-8.14.2/bin
  1. Creating a Gradle test project:
mkdir gradle-profiling-example
cd gradle-profiling-example
gradle init --type java-application --dsl kotlin --test-framework junit-jupiter --project-name simple-app --package com.example
  1. Loading the Java Pyroscope agent:
  • The agent is loaded into the Gradle daemon cache directory to be accessible to the daemon JVM.
wget -O /home/user/.gradle/daemon/8.14.2/pyroscope.jar https://github.com/grafana/pyroscope-java/releases/download/v2.1.2/pyroscope.jar
  • Note: The path is /home/user/.gradle/daemon/8.14.2/ may vary depending on the user and the version of Gradle.
  1. Launching the Pyroscope server:
  • A docker-compose' file is created.yml in the root of the project with the following contents:
version: '3.8'
services:
  pyroscope:
    image: grafana/pyroscope:main-8c89229
    ports:
      - "4040:4040"
    command:
      - "server"
  • The container starts:
docker-compose up -d
  1. Gradle configuration for profiling:
  • The gradle.properties file is created or edited in the root of the project with the following content, where the JVM arguments for the Gradle daemon are specified:
# JVM arguments for Gradle Daemon
org.gradle.jvmargs=-javaagent:pyroscope.jar -Dpyroscope.application.name=my-application{env=prod,version=1.0} -Dpyroscope.server.address=http://localhost:4040 -Dpyroscope.profile=cpu,alloc,lock,network,wall
  • Important: pyroscope.jar must be in a path accessible by the Gradle daemon. In this case, it was placed in his cache.
  1. Launching the profiled build:
  • The project is being built. The '--no-daemonflag is used to ensure that a new Gradle daemon is started that picks up arguments fromgradle.properties'.
gradle clean build --no-daemon

After completing these steps, when going to the Pyroscope web interface (http://localhost:4040 ) the problem described above is observed.

Image

主要语言
Java
星标
125
派生
48
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

grafana/pyroscope-java 的其他 Issue

查看 grafana/pyroscope-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。