Skip to content

Commit

Permalink
Fix profile recheck error (apache#4690)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu authored Apr 22, 2020
1 parent e28e2f4 commit 4e82141
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 356 deletions.
2 changes: 1 addition & 1 deletion apm-checkstyle/checkStyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/>
</module>
<module name="PackageName">
<property name="format" value="^org\.apache\.skywalking(\.[a-zA-Z][a-zA-Z0-9]*)+$"/>
<property name="format" value="^(org|test)\.apache\.skywalking(\.[a-zA-Z][a-zA-Z0-9]*)+$"/>
</module>
<module name="ParameterName"/>
<module name="StaticVariableName">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private Tags() {
public static final class HTTP {
public static final StringTag METHOD = new StringTag(10, "http.method");

public static final StringTag PARAMS = new StringTag(11, "http.params");
public static final StringTag PARAMS = new StringTag(11, "http.params", true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public ThreadProfiler(TracingContext tracingContext, String traceSegmentId, Thre
this.traceSegmentId = traceSegmentId;
this.profilingThread = profilingThread;
this.executionContext = executionContext;
this.profilingStatus = ProfileStatusReference.createWithPending();
if (tracingContext.profileStatus() == null) {
this.profilingStatus = ProfileStatusReference.createWithPending();
} else {
this.profilingStatus = tracingContext.profileStatus();
this.profilingStatus.updateStatus(ProfileStatus.PENDING);
}
this.profilingMaxTimeMills = TimeUnit.MINUTES.toMillis(Config.Profile.MAX_DURATION);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.skywalking.e2e.verification.AbstractMatcher;
import org.assertj.core.api.Assertions;

@Data
@ToString(callSuper = true)
Expand All @@ -34,12 +33,22 @@ public class ProfileStackTreeMatcher extends AbstractMatcher<ProfileAnalyzation.

@Override
public void verify(ProfileAnalyzation.ProfileStackTree profileStackTree) {
Assertions.assertThat(profileStackTree.getElements()).hasSameSizeAs(this.elements);

int size = this.elements.size();

for (int i = 0; i < size; i++) {
elements.get(i).verify(profileStackTree.getElements().get(i));
boolean hasVerified = false;
for (int dataElement = 0; dataElement < profileStackTree.getElements().size(); dataElement++) {
try {
elements.get(i).verify(profileStackTree.getElements().get(dataElement));
hasVerified = true;
break;
} catch (Throwable e) {
}
}

if (!hasVerified) {
throw new IllegalStateException("Cannot found " + elements.get(i).getCodeSignature());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@EnableJpaRepositories
@SpringBootApplication
@ComponentScan({"org.apache.skywalking", "test.apache.skywalking"})
public class Service0Application {
public static void main(String[] args) {
SpringApplication.run(Service0Application.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package org.apache.skywalking.e2e.profile;
package test.apache.skywalking.e2e.profile;

import lombok.Data;
import org.apache.skywalking.e2e.User;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package org.apache.skywalking.e2e.profile;
package test.apache.skywalking.e2e.profile;

import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
Expand All @@ -31,7 +31,7 @@
public class ProfileController {
private final UserRepo userRepo;

@PostMapping("/profile/users")
@PostMapping("/profile/{name}")
public User createAuthor(@RequestBody final CreateUser createUser) throws InterruptedException {
final User user = userRepo.save(createUser.toUser());
if (createUser.isEnableProfiling()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void services() throws Exception {
void createProfileTask() throws Exception {
final ProfileTaskCreationRequest creationRequest = ProfileTaskCreationRequest.builder()
.serviceId("ZTJlLXByb2ZpbGUtc2VydmljZQ==.1")
.endpointName("/profile/users")
.endpointName("/profile/{name}")
.duration(1)
.startTime(-1)
.minDurationThreshold(1500)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# limitations under the License.

endpoints:
- key: ZTJlLXByb2ZpbGUtc2VydmljZQ==.1_L3Byb2ZpbGUvdXNlcnM=
label: /profile/users
- key: ZTJlLXByb2ZpbGUtc2VydmljZQ==.1_L3Byb2ZpbGUve25hbWV9
label: /profile/{name}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
tasks:
- id: not null
serviceId: ZTJlLXByb2ZpbGUtc2VydmljZQ==.1
endpointName: /profile/users
endpointName: /profile/{name}
startTime: gt 0
duration: gt 0
minDurationThreshold: gt 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
tasks:
- id: not null
serviceId: ZTJlLXByb2ZpbGUtc2VydmljZQ==.1
endpointName: /profile/users
endpointName: /profile/{name}
startTime: gt 0
duration: gt 0
minDurationThreshold: gt 0
Expand Down
Loading

0 comments on commit 4e82141

Please sign in to comment.