11package io .pyroscope .javaagent .config ;
22
33import io .pyroscope .http .Format ;
4+ import io .pyroscope .javaagent .EventType ;
45import io .pyroscope .javaagent .api .ConfigurationProvider ;
56import org .junit .jupiter .api .Test ;
67
@@ -26,21 +27,52 @@ void rejectsOtlpWithJfrProfiler() {
2627 }
2728
2829 @ Test
29- void rejectsOtlpWithAllocationProfiling () {
30+ void acceptsOtlpWithAllocationProfiling () {
31+ Config config = Config .build (provider (
32+ "PYROSCOPE_FORMAT" , "otlp" ,
33+ "PYROSCOPE_PROFILER_EVENT" , "alloc" ,
34+ "PYROSCOPE_PROFILER_ALLOC" , "512k" ));
35+ assertEquals (EventType .ALLOC , config .profilingEvent );
36+ assertEquals ("512k" , config .profilingAlloc );
37+ }
38+
39+ @ Test
40+ void acceptsOtlpWithLockProfiling () {
41+ Config config = Config .build (provider (
42+ "PYROSCOPE_FORMAT" , "otlp" ,
43+ "PYROSCOPE_PROFILER_EVENT" , "lock" ,
44+ "PYROSCOPE_PROFILER_LOCK" , "10ms" ));
45+ assertEquals (EventType .LOCK , config .profilingEvent );
46+ assertEquals ("10ms" , config .profilingLock );
47+ }
48+
49+ @ Test
50+ void rejectsOtlpWithSimultaneousAllocationProfiling () {
3051 ConfigurationProvider provider = provider (
3152 "PYROSCOPE_FORMAT" , "otlp" ,
3253 "PYROSCOPE_PROFILER_ALLOC" , "512k" );
3354 IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> Config .build (provider ));
34- assertEquals ("OTLP format does not support allocation or lock profiling " , exception .getMessage ());
55+ assertEquals ("OTLP format does not support multiple profiling events simultaneously " , exception .getMessage ());
3556 }
3657
3758 @ Test
38- void rejectsOtlpWithLockProfiling () {
59+ void rejectsOtlpWithSimultaneousLockProfiling () {
3960 ConfigurationProvider provider = provider (
4061 "PYROSCOPE_FORMAT" , "otlp" ,
4162 "PYROSCOPE_PROFILER_LOCK" , "10ms" );
4263 IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> Config .build (provider ));
43- assertEquals ("OTLP format does not support allocation or lock profiling" , exception .getMessage ());
64+ assertEquals ("OTLP format does not support multiple profiling events simultaneously" , exception .getMessage ());
65+ }
66+
67+ @ Test
68+ void acceptsOtlpWithSequentialSamplingEvents () {
69+ Config config = Config .build (provider (
70+ "PYROSCOPE_FORMAT" , "otlp" ,
71+ "PYROSCOPE_PROFILER_ALLOC" , "512k" ,
72+ "PYROSCOPE_PROFILER_LOCK" , "10ms" ,
73+ "PYROSCOPE_SAMPLING_DURATION" , "1s" ,
74+ "PYROSCOPE_SAMPLING_EVENT_ORDER" , "cpu,alloc,lock" ));
75+ assertEquals (3 , config .samplingEventOrder .size ());
4476 }
4577
4678 private static ConfigurationProvider provider (String ... pairs ) {
0 commit comments