mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-27 09:25:49 +00:00
Fix Apps java file
This commit is contained in:
parent
37c53d5fc5
commit
66e6edb849
2 changed files with 35 additions and 47 deletions
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.samples.petclinic;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* PetClinic Spring Boot Application.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication(proxyBeanMethods = false)
|
||||
public class PetClinicApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PetClinicApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import brave.Span;
|
||||
import brave.Span.Kind;
|
||||
import brave.Tracer;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class PetClinicAspect {
|
||||
|
||||
@Value("${petclinic.db.type:local}")
|
||||
String dbType;
|
||||
|
||||
@Value("${petclinic.db.instance:localDB}")
|
||||
String dbInstance;
|
||||
|
||||
@Autowired
|
||||
Tracer tracer;
|
||||
|
||||
// @Around("execution(* org.springframework.data.repository.Repository+.*(..)))")
|
||||
@Around("execution(* org.springframework.samples.petclinic.*.*Repository+.*(..)))")
|
||||
public Object AddSpan(ProceedingJoinPoint joinpoint) throws Throwable {
|
||||
Span newSpan = this.tracer.nextSpan().name(joinpoint.getSignature().toString()).start();
|
||||
|
||||
try {
|
||||
newSpan.tag("component", "java-jdbc");
|
||||
newSpan.kind(Kind.CLIENT);
|
||||
newSpan.tag("db.type", dbType);
|
||||
newSpan.tag("db.instance", dbInstance);
|
||||
Object result = joinpoint.proceed();
|
||||
|
||||
return result;
|
||||
}
|
||||
finally {
|
||||
newSpan.finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue