【问题标题】:Adding Zipkin tracing to WildFly via CLI using startup scripts使用启动脚本通过 CLI 将 Zipkin 跟踪添加到 WildFly
【发布时间】:2020-05-03 05:48:16
【问题描述】:

我正在尝试在 Wildfly 服务器上添加跟踪(特别是 Keycloak Docker 映像)

关注本文档https://docs.wildfly.org/19/Admin_Guide.html#MicroProfile_OpenTracing_SmallRye

我做到了

/extension=org.wildfly.extension.microprofile.opentracing-smallrye:add
/subsystem=microprofile-opentracing-smallrye:add

但我无法让下一部分工作以将其设置为指向 zipkin:9411

指令中的下一条命令失败

[standalone@localhost:9990 /]  /subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:add()
{
    "outcome" => "failed",
    "failure-description" => "WFLYCTL0030: No resource definition is registered for address [
    (\"subsystem\" => \"microprofile-opentracing-smallrye\"),
    (\"jaeger-tracer\" => \"my-tracer\")
]",
    "rolled-back" => true
}

但是,使用 /opt/jboss/startup-scripts/ 执行此操作也会失败

Executing cli script: /opt/jboss/startup-scripts/enable-tracing.cli
No connection to the controller.

使用@ehsavoie 回答我得到了一点进一步

embed-server --admin-only=true
/extension=org.wildfly.extension.microprofile.opentracing-smallrye:add()
/subsystem=microprofile-opentracing-smallrye:add()
/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:add()
/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:write-attribute(name=sender-endpoint,value=http://tracing:9411)
/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:write-attribute(name=propagation,value=[B3])
/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:write-attribute(name=reporter-log-spans,value=true)
/subsystem=microprofile-opentracing-smallrye:write-attribute(name=default-tracer,value=my-tracer)
stop-embedded-server

但仍然没有登录到使用 B3 的 zipkin。

我也试过

/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:write-attribute(name=sender-endpoint,value=http://tracing:9411/api/v1/spans)

【问题讨论】:

  • 在删除 opentracing 扩展和子系统后,我刚刚在 WildFly 19 上尝试了您的命令,它通过了。你能把你正在使用的图片的链接放上去吗?
  • 我用过jboss/keycloak

标签: wildfly zipkin


【解决方案1】:
embed-server --admin-only=true
/extension=org.wildfly.extension.microprofile.opentracing-smallrye:add()
/subsystem=microprofile-opentracing-smallrye:add()
/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:add()
stop-embedded-server

这个 jboss-cli 脚本应该在正确启动服务器之前启用 opentracing。我不确定如何/何时可以使用 keyclock 图像执行该操作

【讨论】:

  • 一旦你添加了它,你如何配置它?假设我希望跟踪在 192.168.1.1:9411 上使用 zipkin
  • 好吧wildfly.org/news/2020/03/19/… 看起来很有用;)
  • 我看了你的项目,有点奇怪,我找不到你在哪里设置 jaeger 服务器或启用跟踪。
  • /subsystem=microprofile-opentracing-smallrye/jaeger-tracer=jaeger-demo:write-attribute(name="sender-endpoint", value="localhost:14268/api/traces")
  • 我说的是你的github项目github.com/ehsavoie/opentracing-demo
【解决方案2】:

添加子系统后需要重新加载:

[standalone@localhost:9990 /] /extension=org.wildfly.extension.microprofile.opentracing-smallrye:add
{"outcome" => "success"}

[standalone@localhost:9990 /] /subsystem=microprofile-opentracing-smallrye:add
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}

[standalone@localhost:9990 /] reload
[standalone@localhost:9990 /] /subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:add()
{"outcome" => "success"}

【讨论】:

  • 可以通过 CLI 启动脚本来完成吗?正如我在 OP 中指出的那样,我希望在启动脚本中使用它
【解决方案3】:

我会推荐https://github.com/open-telemetry/opentelemetry-java-instrumentation 进行跟踪。需要作为javaagent启动,所以JAVA_OPTS_APPEND可以和官方Keycloak Docker镜像一起使用,例如:

JAVA_OPTS_APPEND: "-javaagent:/opentelemetry-javaagent-all.jar"

然后agent can be configured via env variables,例如:

OTEL_SERVICE_NAME: keycloak
OTEL_TRACES_EXPORTER: jaeger
OTEL_EXPORTER_JAEGER_ENDPOINT: <jaeger endpoint>

它也适用于未来的 Keycloak X 版本,无需复杂的启动脚本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-26
    • 2018-01-04
    • 1970-01-01
    • 2019-12-02
    • 2023-03-27
    相关资源
    最近更新 更多