grafana / pyroscope-java

pyroscope java integration
Apache License 2.0
72 stars 31 forks source link

Dynamic labels not working #93

Closed valodzka closed 1 year ago

valodzka commented 1 year ago

As of agent 0.11.3, this code adds label region=test but now unit=test:

    public static void main(String[] args) {
        Pyroscope.setStaticLabels(Map.of("region", "test"));

        for (int i = 0; i < 2; ++i) {
            Pyroscope.LabelsWrapper.run(new LabelsSet(Map.of("unit", "test")), () -> {
                try {
                    Thread.sleep(5_000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
        }
    }

image

korniltsev commented 1 year ago

Can you try replacing Thread.sleep with something burning cpu? What is your configuration?

valodzka commented 1 year ago

Can you try replacing Thread.sleep with something burning cpu?

I will try to test it.

What is your configuration? Mac OS M2, JDK 17.0.6, run with -javaagent:agent.jar PYROSCOPE_APPLICATION_NAME=test PYROSCOPE_SERVER_ADDRESS=http://127.0.0.1:3150

valodzka commented 1 year ago

I will try to test it.

Same result with this code:

        Pyroscope.setStaticLabels(Map.of("region", "test44"));
        Random rnd = new Random();

        for (int i = 0; i < 2; ++i) {
            Pyroscope.LabelsWrapper.run(new LabelsSet(Map.of("unit", "test")), () -> {
                for (int j = 0; j < 1000_000_000; ++j) {
                    if (rnd.nextInt() % 1_000_000_000 == 1)
                        System.out.println("y");
                }
            });
        }
korniltsev commented 1 year ago

by default it uses collapsed format, labels are supported only with JFR format

valodzka commented 1 year ago

yes, can confirm, with JFR it's working