OpenTelemetryã®Routing Connectorã使ã£ã¦æ¡ä»¶åå²ã¨ãµã³ããªã³ã°ãã·ã³ãã«ã«ãã¦ã¿ã
OpenTelemetryã®ãã¬ã¼ã¹ã·ã°ãã«åå¾ãããä¸ã§ãã¦ã¼ã¶ã¼ã®å±æ§ã«å¿ãã¦ãµã³ããªã³ã°ã調æ´ããããã¨ãããããã¨ãã°ä»¥ä¸ã®ãããªå ·åã ã
- userType=freeã®å ´åã¯1%ãµã³ããªã³ã°ï¼1%æ¾ãã99%ã¯å»æ£ï¼
- standardãªã©ã»ãã®userTypeã®å ´åã¯å ¨ãµã³ããªã³ã°ï¼å ¨é¨æ¾ãï¼
ãã¼ã«ãµã³ããªã³ã°ããªï¼ã¨æãã¨ããã ããããã¯å°ã åé¡ãããã
tail_sampling: decision_wait: 10s policies: - name: free_sampling type: and and: and_sub_policy: - name: match_free type: ottl_condition ottl_condition: span: - attributes["userType"] == "free" - name: probabilistic_policy type: probabilistic probabilistic: sampling_percentage: 1 - name: all_sampling type: always_sample
ããã¯ãã¾ããããªããããªã·ã¼ã§è¨å®ããfree_sampling
ã¨all_sampling
ã¯ä¸¦åã§è©ä¾¡ãå®è¡ãããæ®ã£ããã®ãæ¾ãããæåã«ãªã£ã¦ããããã®ãããfree_sampling
ã§è½ã¨ãã¦ããall_sampling
ã§æ¾ããã¦ãã¾ãã
åé¿çã®ã²ã¨ã¤ã¯ãall_sampling
ã§æç¤ºçã«userType
ãfree
ã®ãã®ãé¤å¤ãããã¨ã§ããã
- name: free_sampling type: and and: and_sub_policy: - name: match_free type: ottl_condition ottl_condition: span: - attributes["userType"] == "free" - name: probabilistic_policy type: probabilistic probabilistic: sampling_percentage: 1 - name: all_sampling type: and and: and_sub_policy: - name: not_match_free type: ottl_condition ottl_condition: span: - attributes["userType"] != "free" - name: always_sample_policy type: always_sample
ãã ããã®ãããªæ¸ãæ¹ã®å ´åãå°æ¥çã«userType
ãå¢ãã¦ããã¨ããã®ãã³ã«ãæ¾ãæ¡ä»¶ãã¨ããã®å¦å®æ¡ä»¶ãã®2ã¤ãã¡ã³ããã³ã¹ãããã¨ã«ãªã£ã¦ãã¾ãã
ä½ãæç«ã¦ããªããOpenTelemetry Collector Contribãçºãã¦ããã¨ãããRouting Connectorã使ãã¨ããã®åé¡ã解決ã§ããã®ã§ã¯ãªããã¨èããã
Routing Connectorã¯ããã¼ãã«ã«è¨å®ããæ¡ä»¶ï¼å±æ§ãªã©ï¼ã«å¿ãã¦ãã¤ãã©ã¤ã³ãåãæ¿ããã³ãã¯ã¿ã§ããã¬ã¼ã¹-ãã¬ã¼ã¹ãã¡ããªãã¯-ã¡ããªãã¯ããã°-ãã°ãã¨åãã·ã°ãã«å½¢å¼ã®éãã¤ãªãããããã©ã«ããã®ãã¤ãã©ã¤ã³ãæå®ã§ããã
ä»åã®ä¾ã§è¨ãã°ã次ã®ãããªè¨è¿°ã¨ãªãã
connectors: routing: default_pipelines: [traces/all_sampling] table: - condition: attributes["userType"] == "free" pipelines: [traces/free_sampling] pipelines: traces: receivers: [otlp] ... exporters: [routing] traces/all_sampling: receivers: [routing] ... traces/free_sampling: receivers: [routing] ...
traces
ãã¤ãã©ã¤ã³ã¯receivers
ã®otlp
ã§ãã¬ã¼ã¹ã·ã°ãã«ãåããrouting
ã³ãã¯ã¿ã«ã¨ã¯ã¹ãã¼ãããrouting
ã³ãã¯ã¿ã§ã¯ããã©ã«ãã§æ¸¡ããã¤ãã©ã¤ã³ã¨ãã¦traces/all_sampling
ãè¨å®ãã屿§userType
ãfree
ã§ããã°traces/free_sampling
ã®ãã¤ãã©ã¤ã³ã«æ¸¡ãtraces/all_sampling
ãã¤ãã©ã¤ã³ã¯routing
ã³ãã¯ã¿ããã®ãã¬ã¼ã¹ã·ã°ãã«ãåããtraces/free_sampling
ãã¤ãã©ã¤ã³ãrouting
ã³ãã¯ã¿ããã®ãã¬ã¼ã¹ã·ã°ãã«ãåããï¼å±æ§userType
ãfree
ã®ã¨ãã«ããã«æ¥ãï¼
ãããªãã°ãåºå¥ããã屿§ãå¢ãã¦ãæ¾ãæ¡ä»¶ã¨ãã¤ãã©ã¤ã³ã追å ããã ããªã®ã§ãè¦éãããããªãã
ãã ãããã¾ã§èªãã§ãããããã£ã¦ã¿ãããã¨é£ã³ã¤ãåã«ãRouting Connectorã使ãä¸ã§ã®æ³¨æããããããã¯ããå¤å®ã«ä½¿ããã屿§ã¯ãªã½ã¼ã¹å±æ§ãã¨ãããã¨ã ããªã½ã¼ã¹å±æ§ã¯ã¢ããªã±ã¼ã·ã§ã³ã»ãµã¼ãã¹ããã¬ã¼ã¹å ¨ä½ã«ããã屿§ã§ããã¨ãã°ãµã¼ãã¹ãã¼ã¸ã§ã³ããããã¤ç°å¢åãªã©ãã¢ããªã±ã¼ã·ã§ã³èµ·åæã«é常決å®ããããã®ãããã«å½ããã䏿¹ã®ã¹ãã³å±æ§ã¯ãã¹ãã³ã«é¢ããæ å ±ã§ããªã¯ã¨ã¹ããå¦çåä½ãã¨ã«å¤ããã
æ§æã«ãããã¨æããuserType
ã¯ä¸è¬ã«ã¹ãã³å±æ§ã ãããããããããªãã¨ãããå¿
è¦ããããã¢ããªã±ã¼ã·ã§ã³å´ã§ããããã¯OpenTelemetry Collectorå´ã§å±æ§ãå¦çã§ããã¨æ¥½ã ããã
屿§ã夿´ããããã»ããµã¨ãã¦ã¯ãtransformããã»ããµã使ãï¼attributesããã»ããµã¯ãªã½ã¼ã¹å±æ§ã®æä½ã¯ã§ããªãï¼ãtransformããã»ããµã®ä¸ã§ãã¹ãã³å±æ§userType
ã®å
容ããªã½ã¼ã¹å±æ§userType
ã«ã³ãã¼ããã
transform: error_mode: ignore trace_statements: - set(resource.attributes["userType"], span.attributes["userType"]) ... pipelines: traces: receivers: [otlp] processors: [..., transform] exporters: [routing]
ã¨ããã§ã屿§ã§ãã¤ãã©ã¤ã³ãåãããã¨ã§ãuserType
ãfree
ã®1%ãµã³ããªã³ã°ã¯ããã¼ã«ãµã³ããªã³ã°ã§ã¯ãªããã·ã³ãã«ãªããããã¼ã¹ã®ç¢ºçãµã³ããªã³ã°ã§æ¸ããã¨ã«ãæ°ä»ãã ãããã
probabilistic_sampler: sampling_percentage: 1 ... traces/free_sampling: receivers: [routing] processors: [probabilistic_sampler, batch]
å ¨ä½ã¨ãã¦ã¯æ¬¡ã®ããã«ãªã£ãã
receivers: otlp: protocols: http: endpoint: "0.0.0.0:4318" processors: batch: timeout: 5s send_batch_size: 5000 send_batch_max_size: 5000 resource/namespace: attributes: - key: service.namespace value: samplingtest action: upsert transform: error_mode: ignore trace_statements: - set(resource.attributes["userType"], span.attributes["userType"]) probabilistic_sampler: sampling_percentage: 1 connectors: routing: default_pipelines: [traces/all_sampling] table: - condition: attributes["userType"] == "free" pipelines: [traces/free_sampling] exporters: otlphttp/mackerel: endpoint: https://otlp-vaxila.mackerelio.com compression: gzip headers: Mackerel-Api-Key: ${env:MACKEREL_APIKEY} otlphttp/oteltui: endpoint: http://localhost:4319 debug: service: telemetry: metrics: level: none pipelines: traces: receivers: [otlp] processors: [resource/namespace, transform] exporters: [routing] traces/all_sampling: receivers: [routing] processors: [batch] exporters: [otlphttp/oteltui, otlphttp/mackerel] traces/free_sampling: receivers: [routing] processors: [probabilistic_sampler, batch] exporters: [debug, otlphttp/oteltui, otlphttp/mackerel]
freeãªãã®ã200åãstandardãªãã®ã10åæç¨¿ããMackerelãã4319ãã¼ãã§ä¸ãã¦ããotel-tuiï¼otel-tui --http 4319
ï¼ã§æ§åãè¦ããfreeã®ãã®ã«ã¤ãã¦ã¯debug
ã«ãã¨ã¯ã¹ãã¼ããããã¨ã§ãRouting Connectorã§ç¢ºãã«åå²ãã¦å°ãã ãããå±ããªããã¨ã確èªããã
å ¨ä½ã®ã¬ã¤ãã³ã·ã¼ã«åºã¥ãåå²ãªã©ã¯ãã¼ã«ãµã³ããªã³ã°ã§ããã§ããªããã屿§å¤ã§åå²ãããããªã·ã³ãã«ãªãã®ã§ããã°ãRouting Connectorã广çãªè§£æ±ºæ¹æ³ã«ãªãããã ã