soudegesu / blog

soudegesu's blog post
https://www.soudegesu.com/
1 stars 0 forks source link

springboot 1.5 -> 2.0 へアップグレード #66

Closed soudegesu closed 6 years ago

soudegesu commented 6 years ago

対応したことメモをする。 今の所の予想

soudegesu commented 6 years ago

まずは、 springboot-actuator のメトリック設定を確認する

soudegesu commented 6 years ago

レスポンスフォーマットは以下

{
    "mem": 485331,
    "mem.free": 253058,
    "processors": 4,
    "instance.uptime": 312097,
    "uptime": 338799,
    "systemload.average": 3.69384765625,
    "heap.committed": 419840,
    "heap.init": 131072,
    "heap.used": 166781,
    "heap": 1864192,
    "nonheap.committed": 66648,
    "nonheap.init": 2496,
    "nonheap.used": 65492,
    "nonheap": 0,
    "threads.peak": 177,
    "threads.daemon": 155,
    "threads.totalStarted": 243,
    "threads": 158,
    "classes": 9613,
    "classes.loaded": 9613,
    "classes.unloaded": 0,
    "gc.ps_scavenge.count": 14,
    "gc.ps_scavenge.time": 373,
    "gc.ps_marksweep.count": 2,
    "gc.ps_marksweep.time": 388,
    "instrumented.responseCodes.serverError.oneMinuteRate": 0,
    "instrumented.responseCodes.badRequest.fiveMinuteRate": 0,
    "instrumented.responseCodes.created.oneMinuteRate": 0,
    "instrumented.responseCodes.serverError.fifteenMinuteRate": 0,
    "instrumented.responseCodes.notFound.count": 0,
    "instrumented.requests.snapshot.stdDev": 0,
    "instrumented.responseCodes.notFound.fiveMinuteRate": 0,
    "instrumented.responseCodes.badRequest.fifteenMinuteRate": 0,
    "instrumented.requests.snapshot.999thPercentile": 0,
    "instrumented.responseCodes.noContent.meanRate": 0,
    "instrumented.responseCodes.created.fifteenMinuteRate": 0,
    "instrumented.requests.count": 0,
    "instrumented.requests.snapshot.min": 0,
    "instrumented.requests.snapshot.98thPercentile": 0,
    "instrumented.requests.snapshot.median": 0,
    "instrumented.responseCodes.ok.fiveMinuteRate": 0,
    "instrumented.requests.fifteenMinuteRate": 0,
    "instrumented.responseCodes.badRequest.meanRate": 0,
    "instrumented.responseCodes.noContent.fiveMinuteRate": 0,
    "instrumented.responseCodes.other.oneMinuteRate": 0,
    "instrumented.responseCodes.created.count": 0,
    "instrumented.responseCodes.serverError.fiveMinuteRate": 0,
    "instrumented.responseCodes.noContent.count": 0,
    "instrumented.responseCodes.badRequest.count": 0,
    "instrumented.responseCodes.notFound.fifteenMinuteRate": 0,
    "instrumented.responseCodes.ok.meanRate": 0,
    "instrumented.responseCodes.ok.oneMinuteRate": 0,
    "instrumented.responseCodes.other.fifteenMinuteRate": 0,
    "instrumented.responseCodes.ok.count": 0,
    "instrumented.responseCodes.badRequest.oneMinuteRate": 0,
    "instrumented.requests.fiveMinuteRate": 0,
    "instrumented.requests.oneMinuteRate": 0,
    "instrumented.requests.snapshot.75thPercentile": 0,
    "instrumented.responseCodes.created.meanRate": 0,
    "instrumented.responseCodes.notFound.meanRate": 0,
    "instrumented.requests.snapshot.95thPercentile": 0,
    "instrumented.requests.meanRate": 0,
    "instrumented.requests.snapshot.max": 0,
    "instrumented.responseCodes.noContent.fifteenMinuteRate": 0,
    "instrumented.responseCodes.noContent.oneMinuteRate": 0,
    "instrumented.responseCodes.created.fiveMinuteRate": 0,
    "instrumented.responseCodes.ok.fifteenMinuteRate": 0,
    "instrumented.responseCodes.serverError.count": 0,
    "instrumented.responseCodes.serverError.meanRate": 0,
    "instrumented.activeRequests": 0,
    "instrumented.requests.snapshot.99thPercentile": 0,
    "instrumented.responseCodes.other.count": 0,
    "instrumented.responseCodes.other.meanRate": 0,
    "instrumented.requests.snapshot.mean": 0,
    "instrumented.responseCodes.notFound.oneMinuteRate": 0,
    "instrumented.responseCodes.other.fiveMinuteRate": 0,
    "httpsessions.max": -1,
    "httpsessions.active": 0,
    "datasource.primary.active": 0,
    "datasource.primary.usage": 0
}
soudegesu commented 6 years ago

この中で監視に使用しているメトリックはどれかというと。。

soudegesu commented 6 years ago

以下の6つぽい

soudegesu commented 6 years ago

datadog の gauge で打ち上げているロジックのエンドポイントを↑のパラメータにしてあげればよさそう。 packerで作成しているAMI内に含めているpythonスクリプトを修正してあげればよさそう

soudegesu commented 6 years ago

次にログフォーマットは

soudegesu commented 6 years ago

とりあえず springboot のバージョンを上げてみる

soudegesu commented 6 years ago

コンパイルエラーが出た

findById(java.lang.String)はorg.springframework.data.repository.CrudRepositoryのfindById(ID)と競合します
  戻り値の型XXXXXはjava.util.Optional<XXXXX>と互換性がありません
soudegesu commented 6 years ago

Optional<型> になったぽいのでそちらに修正する

soudegesu commented 6 years ago

次に

Error:(21, 34) java: シンボルを見つけられません
  シンボル:   メソッド findOne(long)
  場所: タイプXXXXXXの変数 identityRepository
soudegesu commented 6 years ago

findOne がなくなったので findById を使う

soudegesu commented 6 years ago

ErrorAttributes はパッケージが変更されているため修正 org.springframework.boot.autoconfigure.web.ErrorAttributes から org.springframework.boot.web.servlet.error.ErrorAttributes へ overrideしないといけないメソッドの引数も型が変わっている

soudegesu commented 6 years ago

dropwizardMetricで取得していた拡張メトリックは監視で使用していないため、削除する.

soudegesu commented 6 years ago

/actuator/metrics

{
    "names": [
        "http.server.requests",
        "jvm.buffer.memory.used",
        "jvm.memory.used",
        "jvm.gc.memory.allocated",
        "jvm.memory.committed",
        "jdbc.connections.min",
        "tomcat.sessions.created",
        "tomcat.sessions.expired",
        "hikaricp.connections.usage",
        "tomcat.global.request.max",
        "tomcat.global.error",
        "jvm.gc.max.data.size",
        "logback.events",
        "system.cpu.count",
        "jvm.memory.max",
        "jdbc.connections.active",
        "jvm.buffer.total.capacity",
        "jvm.buffer.count",
        "process.files.max",
        "jvm.threads.daemon",
        "hikaricp.connections",
        "process.start.time",
        "hikaricp.connections.active",
        "tomcat.global.sent",
        "hikaricp.connections.creation.percentile",
        "tomcat.sessions.active.max",
        "tomcat.threads.config.max",
        "jvm.gc.live.data.size",
        "process.files.open",
        "process.cpu.usage",
        "hikaricp.connections.acquire",
        "hikaricp.connections.timeout",
        "tomcat.servlet.request",
        "jvm.gc.pause",
        "hikaricp.connections.idle",
        "process.uptime",
        "tomcat.global.received",
        "system.load.average.1m",
        "tomcat.cache.hit",
        "hikaricp.connections.pending",
        "hikaricp.connections.acquire.percentile",
        "tomcat.servlet.error",
        "tomcat.servlet.request.max",
        "hikaricp.connections.usage.percentile",
        "jdbc.connections.max",
        "tomcat.cache.access",
        "tomcat.threads.busy",
        "tomcat.sessions.active.current",
        "system.cpu.usage",
        "jvm.threads.live",
        "jvm.classes.loaded",
        "jvm.classes.unloaded",
        "jvm.threads.peak",
        "tomcat.threads.current",
        "tomcat.global.request",
        "hikaricp.connections.creation",
        "jvm.gc.memory.promoted",
        "tomcat.sessions.rejected",
        "tomcat.sessions.alive.max"
    ]
}
soudegesu commented 6 years ago

例えば、以下で取得する /actuator/metrics/tomcat.sessions.created

{
    "name": "tomcat.sessions.created",
    "measurements": [
        {
            "statistic": "COUNT",
            "value": 0
        }
    ],
    "availableTags": []
}
soudegesu commented 6 years ago

105