2

I am trying to add tracing on a Wildfly server (specifically Keycloak Docker image)

Following this document https://docs.wildfly.org/19/Admin_Guide.html#MicroProfile_OpenTracing_SmallRye

I got as far as

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

But I can't get the next parts working to set it to point to zipkin:9411

The next command in the instructions failed

[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
}

However, doing it using /opt/jboss/startup-scripts/ also fails

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

Using @ehsavoie answer I got a bit further

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

but still does not log to zipkin which uses B3.

I also tried

/subsystem=microprofile-opentracing-smallrye/jaeger-tracer=my-tracer:write-attribute(name=sender-endpoint,value=http://tracing:9411/api/v1/spans)
Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265

3 Answers3

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

This jboss-cli script should enable opentracing before starting the server properly. I'm not sure how/when you can execute that with keycloack image

ehsavoie
  • 3,126
  • 1
  • 16
  • 14
0

You need to reload after adding the subsystem:

[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"}
ehsavoie
  • 3,126
  • 1
  • 16
  • 14
0

I would recommend https://github.com/open-telemetry/opentelemetry-java-instrumentation for tracing. It needs to be started as javaagent, so JAVA_OPTS_APPEND can be used with official Keycloak Docker image, e.g.:

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

And then agent can be configured via env variables, e.g.:

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

It works also with future Keycloak X version and without complicated startup scripts.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59