Explorar el Código

refactor: otel e2e trace config schema `cluster_identifier`

JimMoen hace 1 año
padre
commit
0e7c1889f4

+ 1 - 1
apps/emqx_opentelemetry/include/emqx_otel_trace.hrl

@@ -39,7 +39,7 @@
 -define(EMQX_OTEL_SAMPLE_CLIENTID, 1).
 -define(EMQX_OTEL_SAMPLE_TOPIC, 2).
 
--define(EMQX_OTEL_DEFAULT_META_VALUE, <<"emqxcl">>).
+-define(EMQX_OTEL_DEFAULT_CLUSTER_ID, <<"emqxcl">>).
 
 -record(?EMQX_OTEL_SAMPLER, {
     type ::

+ 3 - 3
apps/emqx_opentelemetry/src/emqx_otel_schema.erl

@@ -242,13 +242,13 @@ fields("trace_filter") ->
     ];
 fields("e2e_tracing_options") ->
     [
-        {attribute_meta_value,
+        {cluster_identifier,
             ?HOCON(
                 string(),
                 #{
                     required => true,
-                    default => ?EMQX_OTEL_DEFAULT_META_VALUE,
-                    desc => ?DESC(e2e_attribute_meta_value),
+                    default => ?EMQX_OTEL_DEFAULT_CLUSTER_ID,
+                    desc => ?DESC(cluster_identifier),
                     importance => ?IMPORTANCE_MEDIUM
                 }
             )},

+ 7 - 7
apps/emqx_opentelemetry/src/sampler/emqx_otel_sampler.erl

@@ -11,7 +11,7 @@
 -include_lib("opentelemetry/include/otel_sampler.hrl").
 -include_lib("opentelemetry_api/include/opentelemetry.hrl").
 
--define(META_KEY, 'emqx.meta').
+-define(CLUSTER_ID_KEY, 'cluster.id').
 
 -export([
     init_tables/0,
@@ -148,7 +148,7 @@ setup(#{sample_ratio := Ratio} = InitOpts) ->
             client_subscribe_unsubscribe,
             client_publish,
             msg_trace_level,
-            attribute_meta_value
+            cluster_identifier
         ],
         InitOpts
     ))#{
@@ -187,7 +187,7 @@ should_sample(
             decide_by_traceid_ratio(TraceId, SpanName, Opts),
     {
         decide(Desicion),
-        with_meta_value(Opts),
+        with_cluster_id(Opts),
         otel_span:tracestate(otel_tracer:current_span_ctx(Ctx))
     };
 %% None Root Span, decide by Parent or Publish Response Tracing Level
@@ -205,7 +205,7 @@ should_sample(
             match_by_span_name(SpanName, QoS),
     {
         decide(Desicion),
-        with_meta_value(Opts),
+        with_cluster_id(Opts),
         otel_span:tracestate(otel_tracer:current_span_ctx(Ctx))
     }.
 
@@ -304,7 +304,7 @@ decide(true) ->
 decide(false) ->
     ?DROP.
 
-with_meta_value(#{attribute_meta_value := MetaValue}) ->
-    #{?META_KEY => MetaValue};
-with_meta_value(_) ->
+with_cluster_id(#{cluster_identifier := IdValue}) ->
+    #{?CLUSTER_ID_KEY => IdValue};
+with_cluster_id(_) ->
     #{}.

+ 3 - 3
rel/i18n/emqx_otel_schema.hocon

@@ -71,10 +71,10 @@ trace_mode.label: "Trace Mode"
 e2e_tracing_options.desc: "End-to-end tracing options"
 e2e_tracing_options.label: "End-to-End Tracing Options"
 
-e2e_attribute_meta_value.desc:
-"""A meta value added into Span's Attribute. The attribute key will be <code>emqx.meta</code></br/>
+cluster_identifier.desc:
+"""An attribute value added into Span's Attributes. The attribute key will be `cluster.id`
 Typically, set a simple and easily recognizable name or use the cluster name to identify different EMQX clusters."""
-e2e_attribute_meta_value.label: "Attribute Meta Value"
+cluster_identifier.label: "Cluster Identifier"
 
 msg_trace_level.desc:
 """Trace level for all message exchanges during the message publishing process.