Remove unused filter (endpoint is generated in listener now)

This commit is contained in:
Dave Syer
2015-08-13 09:04:45 +01:00
parent fdde285a69
commit 74ee062d6d
3 changed files with 1 additions and 131 deletions

View File

@@ -1,77 +0,0 @@
/*
* Copyright 2013-2015 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
*
* http://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.cloud.sleuth.zipkin.web;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import com.github.kristofa.brave.EndPointSubmitter;
/**
* @author Spencer Gibb
*/
@Order(Ordered.HIGHEST_PRECEDENCE + 2)
public class ZipkinFilter implements Filter {
@Value("${spring.application.name:application}")
private String serviceName;
private EndPointSubmitter endPointSubmitter;
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public ZipkinFilter(EndPointSubmitter endPointSubmitter) {
this.endPointSubmitter = endPointSubmitter;
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// NOOP
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (!this.endPointSubmitter.endPointSubmitted()) {
final String localAddr = request.getLocalAddr();
final int localPort = request.getLocalPort();
final String contextPath = this.serviceName
+ ((request instanceof HttpServletRequest) ? ((HttpServletRequest) request)
.getContextPath() : "");
this.endPointSubmitter.submit(localAddr, localPort, contextPath);
}
chain.doFilter(request, response);
}
@Override
public void destroy() {
// NOOP
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2013-2015 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
*
* http://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.cloud.sleuth.zipkin.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.cloud.sleuth.zipkin.ZipkinAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.github.kristofa.brave.EndPointSubmitter;
import com.github.kristofa.brave.ServerTracerConfig;
/**
* @author Spencer Gibb
*/
@Configuration
@ConditionalOnClass(ServerTracerConfig.class)
@ConditionalOnWebApplication
@ConditionalOnProperty(value = "spring.sleuth.zipkin.enabled", matchIfMissing = true)
@AutoConfigureAfter(ZipkinAutoConfiguration.class)
@AutoConfigureBefore(TraceAutoConfiguration.class)
public class ZipkinWebAutoConfiguration {
@Autowired
private EndPointSubmitter endPointSubmitter;
@Bean
public ZipkinFilter zipkinFilter() {
return new ZipkinFilter(this.endPointSubmitter);
}
}

View File

@@ -1,4 +1,3 @@
# Auto Configuration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.sleuth.zipkin.ZipkinAutoConfiguration,\
org.springframework.cloud.sleuth.zipkin.web.ZipkinWebAutoConfiguration
org.springframework.cloud.sleuth.zipkin.ZipkinAutoConfiguration