diff --git a/src/docs/asciidoc/Images/static_vs_dynamic_dynamic_1.png b/src/docs/asciidoc/Images/static_vs_dynamic_dynamic_1.png new file mode 100644 index 0000000..a007ff4 Binary files /dev/null and b/src/docs/asciidoc/Images/static_vs_dynamic_dynamic_1.png differ diff --git a/src/docs/asciidoc/Images/static_vs_dynamic_dynamic_obj.png b/src/docs/asciidoc/Images/static_vs_dynamic_dynamic_obj.png new file mode 100644 index 0000000..f26c030 Binary files /dev/null and b/src/docs/asciidoc/Images/static_vs_dynamic_dynamic_obj.png differ diff --git a/src/docs/asciidoc/Images/static_vs_dynamic_static_1.png b/src/docs/asciidoc/Images/static_vs_dynamic_static_1.png new file mode 100644 index 0000000..1b98b50 Binary files /dev/null and b/src/docs/asciidoc/Images/static_vs_dynamic_static_1.png differ diff --git a/src/docs/asciidoc/Images/static_vs_dynamic_static_obj.png b/src/docs/asciidoc/Images/static_vs_dynamic_static_obj.png new file mode 100644 index 0000000..0247c17 Binary files /dev/null and b/src/docs/asciidoc/Images/static_vs_dynamic_static_obj.png differ diff --git a/src/docs/asciidoc/README.adoc b/src/docs/asciidoc/README.adoc index e43d87f..2155f75 100644 --- a/src/docs/asciidoc/README.adoc +++ b/src/docs/asciidoc/README.adoc @@ -7,7 +7,7 @@ AVIO Consulting :doctype: book :icons: font :toc: left -:toclevels: 3 +:toclevels: 4 :imagesdir: ./Images :tabsize: 4 :keywords: Mule, MuleSoft, Observability, OpenTelemetry, OTel, Tracing, Instrumentation, Distributed diff --git a/src/docs/asciidoc/module-config.adoc b/src/docs/asciidoc/module-config.adoc index d306526..38bf1ca 100644 --- a/src/docs/asciidoc/module-config.adoc +++ b/src/docs/asciidoc/module-config.adoc @@ -463,13 +463,9 @@ image::manual-context-flow-injection.png[] [#_http_request_context_injection] ====== HTTP Request Context Injection -The Module does **NOT** support automatic context propagation. In order to *propagate the trace header* information to other web applications, the Mule HTTP Requester Configuration *must* -have default headers configured in the following way: +The Module does **NOT** support automatic context propagation. In order to *propagate the trace header* information to other web applications, the Mule HTTP Requester Operation _OR_ Configuration *must* be configured to propagate following http headers - -image::http-requester-config.png[600,600,title="Mule HTTP Requester Configuration",align="center"] - - -.HTTP Requester Configuration for Default Headers +.HTTP Headers for Trace Context [cols="30%, 70%"] |=== | *Key* | *Value* @@ -477,15 +473,46 @@ image::http-requester-config.png[600,600,title="Mule HTTP Requester Configuratio | `tracestate` | `#[vars.OTEL_TRACE_CONTEXT.tracestate default '' as String]` |=== +*Using Operation vs. Global Configuration:* + +HTTP Outbound headers can be added at HTTP Request Operation level OR as a default headers in HTTP Request Global Configuration. + +HTTP Global configuration may be easier from code modifications perspective i.e. just at one global level. That comes at the cost of performance because using expressions in configurations makes it a *https://docs.mulesoft.com/mule-sdk/latest/static-dynamic-configs[dynamic configuration^]*. + +On the other hand, using headers section in HTTP Request operation may need modification of every `http:request` operation, but then it keeps the global configuration as a *static configuration* for runtime to reuse the same instance. + +WARNING: Using Static configurations is a preferred approach from performance perspective. Dynamic is only recommended for lower request volume uses cases. For more information on performance impact, see link:#_static_vs_dynamic_global_configurations[performance report section]. + +*Propagation with Request Operation:* +To propagate context using request operation, add/append request headers section of every `http:request` operation to include following entries - + +[source,xml] +.Example GET Request with OTEL Trace context headers +---- + + + + +---- + +*Propagation with Requester Global Configuration:* + +In order to propagate the trace header information to other web applications, the Mule HTTP Requester Configuration must have default headers configured in the following way: .Mule configuration xml for setting default headers in the HTTP Requester Configuration [source%nowrap%linenums, xml] ---- - - + + - <1> - <2> + + ---- diff --git a/src/docs/asciidoc/performance.adoc b/src/docs/asciidoc/performance.adoc index 75a1ff4..293adaf 100644 --- a/src/docs/asciidoc/performance.adoc +++ b/src/docs/asciidoc/performance.adoc @@ -45,4 +45,59 @@ After multiple iterations of the test with above setup and comparing the perform * Up to 5% overhead on request processing under the load * Up to 10% CPU overhead +[#_static_vs_dynamic_global_configurations] +==== Static vs. Dynamic Configurations +Depending on how global configurations are written they can be https://docs.mulesoft.com/mule-sdk/latest/static-dynamic-configs[Static or Dynamic]. + +- *Static Configuration* - A configuration is static when none of its parameters are assigned an expression (even if those parameters do support expressions) + +[source,xml] +---- + + + +---- + + +- *Dynamic Configuration* - In dynamic configurations, at least one parameter has an expression + +[source,xml] +---- + + + + + +---- + +_For Static configurations_, a single instance is created and _re-used_ each time it is needed. + +_For Dynamic configurations_, Each time an operation that points to a dynamic configuration is executed, all the parameters in the configuration are evaluated. A configuration instance is created for each unique set of resolved parameters. In that way, each time the same values are resolved, the same instance is returned, but for each different set of values, a _different_ instance is created. + +This lifecycle difference can make a huge difference on the configuration objects created. Every request will have a different `traceparent` value. Thus, when using Dynamic configurations, a new instance will be created *for each request*. + +Following result demonstrates the configuration Object creations for a load of _20 concurrent users for a 1-minute_ time period - + +*Observations:* + +- The number of Objects creation and allocation is much higher for Dynamic configurations +- With configuration expiration window, this affects the memory consumption and GC times + +*Recommendations:* + +For higher load applications, static configurations i.e. propagation from operations instead of global configuration should be preferred. + + + +*Static Configuration Object Creations* + +image::Images/static_vs_dynamic_static_1.png[width=1024] +image::Images/static_vs_dynamic_static_obj.png[width=1024] + +*Dynamic Configuration Object Creations* + +image::Images/static_vs_dynamic_dynamic_1.png[width=1024] +image::Images/static_vs_dynamic_dynamic_obj.png[width=1024] \ No newline at end of file