- Maven multi-module library delivering RPC tracing infrastructure for microservices.
- Java 11 baseline; core dependencies include SLF4J, Apache Commons Pool 2, OpenTelemetry (API/SDK/OTLP exporter), Jakarta Servlet 5, HttpClient5, Jetty (tests), EasyMock.
- Modules share version
woody(root POM);dependencyManagementkeepswoody- apiversion-aligned.
- Thread-local tracing via
TraceContext/TraceDatamanaging client/service spans, auto ID generation, duration tracking, SLF4J MDC sync, OTEL span lifecycle. MDCUtilsпубликует trace/span идентификаторы Woody и OpenTelemetry, дедлайны и RPC-метаданные (отключаемо через системное свойствоwoody.mdc.extended).- Concurrency helpers (
WFlow,WCallable,WRunnable,WExecutorService) clone/propagate trace context across threads, including service/client forks. - Proxy/interceptor pipeline:
ProxyFactorywraps interfaces with dynamic proxies andMethodCallTracer.AbstractClientBuilder/AbstractServiceBuilderassemble tracing, deadline enforcement (DeadlineTracer), error mapping, and event dispatch.- Event system (
ClientEvent,ServiceEvent, composite listeners) plus transport/provider interceptors for lifecycle hooks.
- Error framework (
WErrorType,WErrorDefinition,ErrorMapProcessor,ErrorMappingInterceptor) translating transport/business outcomes. - Metadata extensibility via
interceptor.ext,ExtensionBundle,MetadataExtensionKit.
- Thrift-over-HTTP implementation layered on woody-api.
- Client builders (
THClientBuilder,THSpawnClientBuilder,THPooledClientBuilder) constructTServiceClient, inject message/transport interceptors, traceparent propagation, metadata extensions, logging (THCEventLogListener); support custom or pooled HttpClient5. - Service builder (
THServiceBuilder) wrapsTProcessorintoTServlet, applies transport interceptors,THErrorMapProcessor, logging (THSEventLogListener), and ensuresTraceContext.forService. - Extension bundles produce
THCExtensionContext/THSExtensionContext;TraceParentUtilshandles W3C traceparent parsing/serialization. - Supplemental packages:
error(exception ↔ response mapping),event(HTTP logging),transport(servlet/client wiring). - Обновлённый
THProviderErrorMapperсинхронизирует статус, источники ошибок, метаданные и обеспечивает трассировку при транспортных исключениях.
- Local fork of Apache Thrift with HttpClient5 transport adjustments, servlet/TLS tweaks, and hooks compatible with woody interceptors.
- Packaged as module dependency for
woody-thrift(same version).
- Root
pom.xmlнаследуется отdev.vality:library-parent-pom:3.1.0и управляет версией через${revision}. woody-thriftoffersgen_thrift_classesprofile runningthrift-maven- plugin(thriftexecutable required).- Target Java version 11; uses Checkstyle suppressions and Renovate config.
woody-api/src/test: ID generators, tracing logic, proxy behavior.woody-thrift/src/test: Jetty quickstart servers + EasyMock cover HTTP integration, metadata propagation, error mapping, а также свежие интеграционные сценарииTraceLifecycleIntegrationTest, проверяющие сквозную OpenTelemetry-трассировку (новый/восстановленный контекст, обработку ошибок, отсутствие обязательных метаданных).- Дополнительно
THProviderErrorMapperTestиMetadataMdcPropagationTestконтролируют обработку ошибок и перенос MDC/OTel данных.
- Always maintain root/service/client span consistency;
TraceContextorchestrates init/destroy hooks and ensures MDC/Otel sync. - Cross-thread execution must wrap tasks with
WFlow.create/createServiceFork. - Interceptors are composable; metadata extensions rely on extension bundles (client/service contexts differ).
libthriftshould be treated as authoritative transport layer—do not upgrade Apache Thrift without reconciling local changes.
-
Create forked service task:
WFlow.createServiceFork(runnable)or callables with custom ID generators. -
Client build pattern:
ThriftServiceSrv.Iface client = new THClientBuilder() .withAddress(URI.create("https://example")) .withHttpClient(HttpClientBuilder.create().build()) .withEventListener(listener) .build(ThriftServiceSrv.Iface.class);
-
Service servlet:
Servlet servlet = new THServiceBuilder() .withEventListener(listener) .build(ThriftServiceSrv.Iface.class, handlerImpl);
- Logging depends on composite listeners; disable via
withLogEnabled(false). - Deadlines propagate through spans; ensure upstream services respect
DeadlineTracer. - Error mapping distinguishes transport errors vs business
(
WErrorType.BUSINESS_ERRORleaves transport metadata intact). - For new metadata, implement
MetadataExtensionKitand include via builderwithMetaExtensions. - Для фоновых задач используйте
WFlow.createServiceFork(...)— он создаёт новый service-span и корректно инициализирует OpenTelemetry контекст.