rajeshkumarchandolu opened a new pull request, #11852:
URL: https://github.com/apache/ozone/pull/11852

   HDDS-XXXX. Add TracingUtil span helpers and span-kind aware tracing proxies
   
   ## What changes were proposed in this pull request?
   
   ### Why
   This is the first, common-only step of adding OpenTelemetry tracing to OM 
(and later SCM and datanodes). Upcoming PRs will:
   * create OM components as tracing proxies through their interfaces, such as 
the request handler, client requests, the key, volume and bucket managers, and 
the authorizer;
   * add attributes, events and error status from inside request handling.
   
   For that we need a few things that `hdds-common` doesn't have yet:
   * proxies that work at startup;
   * proxies whose span kind matches what the delegate does: INTERNAL for 
in-process components, CLIENT for RPC clients;
   * exceptions recorded in a standard way;
   * small null-safe helpers for the current span;
   * a test helper to assert on collected spans.
   
   This PR adds only these building blocks. It doesn't add new spans to any 
service.
   
   ### What
   **Span helpers in `TracingUtil`:**
   * `createSpan(name)` and `createSpan(name, SpanKind)` create a span that is 
a child of the current span.
   * `recordException(span, t)` and `recordExceptionInCurrentSpan(t)` record 
the exception event and set the ERROR status, using the exception message as 
the description.
   * `addAttributesToCurrentSpan(key, String|long|boolean)` and 
`addEventToCurrentSpan(name, key, value)` do nothing when there is no recording 
span, and skip null values.
   * New `SpanAttributeKeys` holds the shared attribute keys, starting with 
`ozone.status`.
   
   **Tracing proxies:**
   * `TraceAllMethod` takes a `SpanKind`. `@InternalSpanKind` can now go on a 
whole delegate class as well as on a method.
   * Exceptions thrown by the delegate are recorded on the proxy span. Methods 
missing from the delegate, and `@SkipTracing` methods, are called directly 
instead of throwing `NoSuchMethodException`.
   * `createProxy(delegate, itf, conf)` now creates INTERNAL spans. The new 
`createClientProxy(delegate, itf, conf)` creates CLIENT spans. The existing RPC 
client proxies switch to `createClientProxy`, so their span kind stays CLIENT:
     * the SCM block, container location, security and secret key clients, in 
`HAUtils` and `HddsServerUtil`;
     * the OM client in `RpcClient`.
   * New `createProxy(delegate, itf, spanPrefix, spanKind)` names spans 
`<spanPrefix>.<method>`, for example `KeyManagerImpl.listStatus`. It doesn't 
need a current span, so it can wrap objects created at service startup when 
application-aware tracing is on.
   
   **Error recording on existing spans:**
   * `executeInSpan` and `OzoneProtocolMessageDispatcher#processRequest` now 
use `recordException`. Failed spans carry the exception event and the error 
message, not only the ERROR status.
   
   **Tests:**
   * New `TestSpanCollector` installs an in-memory span processor and has 
assertion helpers.
   * New tests in `TestTracingUtil`, `TestTraceAllMethod`, 
`TestTracingAnnotations`, `TestTracingInitModes` and 
`TestOzoneProtocolMessageDispatcher`.
   * The test tracer providers get a span processor. With OpenTelemetry 1.67, 
an `SdkTracerProvider` without a processor returns no-op spans.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-XXXX
   
   ## How was this patch tested?
   
   * All 79 tests in the `hdds-common` tracing package pass, including the new 
span-helper, proxy span-kind and exception-recording tests.
   * `TestOzoneProtocolMessageDispatcher` (3 tests).
   * A full build with test compilation (`install -DskipTests`), plus 
checkstyle and PMD on `hdds-common`, `hdds-server-framework`, `ozone-client` 
and `ozone-integration-test`.
   
   
   ##Build:
   
   https://github.com/rajeshkumarchandolu/ozone/actions/runs/40915946102


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to