Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Migrations

cameleeck edited this page May 23, 2016 · 5 revisions

0.x.x -> 2.0.1

Bootstrap configuration

If you want to have the possibility to use either Spring Cloud Zookeeper approach or the old (microservice.json) based approach you have to set up two yml files.

bootstrap.yml

This configuration file will by default disable Spring Cloud Zookeeper and Ribbon.

spring.cloud.zookeeper.enabled: false
spring.cloud.zookeeper.discovery.enabled: false
ribbon.zookeeper.enabled: false
spring.autoconfigure.exclude: org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration

bootstrap-springCloud.yml

This configuration will enable the Spring Cloud Zookeeper with Ribbon

spring.cloud.zookeeper.enabled: true
spring.cloud.zookeeper.discovery.enabled: true
ribbon.zookeeper.enabled: true
spring.autoconfigure.exclude: ''

# Once the bug in Spring Cloud Zookeeper is fixed you'll have to remove the starting prefix if you provide a prefix in spring.cloud.zookeeper.prefix
spring:
  application:
    name: com/ofg/twitter-places-analyzer

spring.cloud.zookeeper.discovery.root: /pl
spring.cloud.zookeeper:
  prefix: com/ofg/
  dependencies:
    collerator:
      path: twitter-places-collerator

The second yaml file corresponds to the following microservice.json file

{
    "pl": {
        "this": "com/ofg/twitter-places-analyzer",
        "dependencies": {
            "collerator": {
                "path": "com/ofg/twitter-places-collerator"
            }
        }
    }
}

x.x.x -> 2.0.2 (Spring Cloud Sleuth integration)

Backwards incompatible changes

CorrelationIdFilter

There is no more CorrelationIdFilter. In tests instead of sth like

@ContextConfiguration(classes = [Application], loader = SpringApplicationContextLoader)
class MicroserviceMvcWiremockSpec extends MvcWiremockIntegrationSpec {

    @Override
    protected void configureMockMvcBuilder(ConfigurableMockMvcBuilder mockMvcBuilder) {
        super.configureMockMvcBuilder(mockMvcBuilder)
        mockMvcBuilder.addFilter(new CorrelationIdFilter())
    }
}

you have to have

import com.ofg.infrastructure.base.MvcWiremockIntegrationSpec
import org.springframework.cloud.sleuth.instrument.web.TraceFilter
import com.ofg.infrastructure.web.correlationid.HeadersSettingFilter
import com.ofg.twitter.Application
import org.springframework.beans.factory.annotation.Autowire
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.actuate.trace.Trace
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.web.servlet.setup.ConfigurableMockMvcBuilder

@ContextConfiguration(classes = [Application], loader = SpringApplicationContextLoader)
class MicroserviceMvcWiremockSpec extends MvcWiremockIntegrationSpec {

    @Autowired Trace trace
    
    @Override
    protected void configureMockMvcBuilder(ConfigurableMockMvcBuilder mockMvcBuilder) {
        super.configureMockMvcBuilder(mockMvcBuilder)
        mockMvcBuilder.addFilter(new HeadersSettingFilter(), new TraceFilter(trace))
    }
}

  • CorrelationIdFilter has been changed by TraceFilter
  • HeadersSettingFilter might be incorporated in TraceFilter in the subsequent Sleuth versions

Logging pattern

There is a change in the logging approach since the pattern changed:

'%d{yyyy-MM-dd HH:mm:ss.SSSZ, Europe/Warsaw} | %-5level | %X{X-Trace-Id} | %thread | %logger{1} | %m%n'

What changed is that there was the correlationId MDC entry and now it's X-Trace-Id. Please ensure that your Logback configuration can parse both MDC entries.

Workarounds (should disappear if fixed in Spring Cloud Sleuth)

Headers are not set for "first" request

Had to add com.ofg.infrastructure.web.correlationid.HeadersSettingFilter that creates headers for spanId and traceId if there are not set. Without those TraceFilter is not setting traceId and spanId` to response

TraceCallable and TraceRunnable should clean after itself

Kudos to @nurkiewicz for help on the analysis. Both classes are working on a separate thread pool which is shared by a number of threads. After either of them finishes it's job it should remove the Span from current ThreadLocal. The same with TraceCommand.

Exception should not be thrown when there is a tracing issue

For now we're wrapping it in ExceptionCatchingTraceScope that wraps TraceScope in com.ofg.infrastructure.tracing.TracingConfiguration.ExceptionCatchingTraceScope

Prefix not appended

With Spring Boot 1.3.0.RELEASE Spring Cloud Zookeeper fails to combine the spring.cloud.zookeeper.prefix with spring.application.name

Issues

Swagger is not compatible with Spring Boot 1.3.0.RELEASE and Spring 4.2.3.RELEASE - https://github.com/springfox/springfox/issues/1055

Workaround

I've repackaged Swagger and changed this class as follows:

package repackaged.com.mangofactory.swagger.readers.operation;

import com.mangofactory.swagger.scanners.RequestMappingContext;

/**
 * Terrible hack until they fix https://github.com/springfox/springfox/issues/1055
 */
public class OperationDeprecatedReader implements RequestMappingReader {
  @Override
  public void execute(RequestMappingContext context) {
    context.put("deprecated", String.valueOf(false));
  }
}

0.x.x -> 2.0.8

  • Java 1.8 is required (support for java 1.8 is dropped).
  • Accurest 1.1.0-M6 is required (due to wiremock 2.0.10-beta update).
  • rest.client.metrics.enabled is disabled by default due to performance reasons.
  • ServiceRestClient is deprecated now! 💯
  • See also if finding more problems. Workarounds