---
schema_version: "1"
id: 156da1247a849a7db99e5d7de393ee0d1f17218fda1abcb44bb1eb3b1468db74
title: 接続モードでの Flex Gateway 分散トレースの設定
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/gateway/1.10/flex-conn-tracing-config.md
canonical_url: https://docs.mulesoft.com/jp/gateway/1.10/flex-conn-tracing-config
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0786dd038ba7161843d99264af2841a363e662b87d3a6d078527b905c778901b
description: MuleSoft Documentation Site
release: "1.10"
latest: false
---
# 接続モードでの Flex Gateway 分散トレースの設定

OpenTelemetry により、分散システムでテレメトリーデータを計測、生成、収集、エクスポートするための統合された基準が提供されます。Flex Gateway では OpenTelemetry をサポートしているため、ゲートウェイで管理するすべての API トラフィックの分散トレースデータの生成を設定できます。このインテグレーションにより、API 要求フローをより詳しく視覚化できるため、システムの動作をより簡単に分析し、問題をトラブルシューティングして、Flex Gateway API と外部サービス間のインタラクションを理解できます。

Anypoint Monitoring Telemetry Exporter を使用することで、Flex Gateway トレースデータを Azure Monitor や Splunk HEC のほか、OpenTelemetry 互換ツールなどのサードパーティオブザーバビリティおよび分析プラットフォームに送信できます。この機能によって、エンドツーエンドオブザーバビリティを活用し、API トレースを他のシステムのデータと相関させ、環境の包括的なビューを構築できます。

## [](#始める前に)始める前に

Flex Gateway で OpenTelemetry を使用するには、以下に精通している必要があります。

- 分散トレースの概念 (トレースやスパンなど)。
    
    分散トレースや OpenTelemetry を初めて使用する場合、 [「OpenTelemetry とは」](https://opentelemetry.io/docs/concepts/what-is-opentelemetry/)​および [「分散トレースを理解する」](https://opentelemetry.io/docs/concepts/observability-primer/#understanding-distributed-tracing)​から始めることをお勧めします。
- [テレメトリーデータをサードパーティ監視システムにエクスポートする方法](https://docs.mulesoft.com/jp/monitoring/telemetry-exporter)​。

## [](#flex-gateway-api-の分散トレースの設定)Flex Gateway API の分散トレースの設定

トレースにより、Flex Gateway API のインタラクションを追跡できます。複数のシステムおよびサービスが関連する場合、分散トレースで分散環境に流れる API 要求を追跡し、API の実行の包括的なビューを提供します。

## [](#yaml-設定リソースを使用した分散トレースの有効化と設定)YAML 設定リソースを使用した分散トレースの有効化と設定

この設定リソースを編集してから適用し、分散トレースを有効にします。この設定リソースは、すべての API インスタンスに適用されます。 次の例では、すべてのトレースのサンプリングを 0% に設定し、サンプリングはポリシーを使用して API ごとに設定されます。

```yaml
apiVersion: gateway.mulesoft.com/v1beta1
kind: Configuration
metadata:
  name: tracing
  namespace: test-ns
spec:
  tracing:
    provider:
      type: anypoint
      properties:
        timeout: 10s #
    sampling: # Set all sampling to 0% - this example shows enabling samping for the gateway, but only generating trace data for sampling on a per-API basis using the Tracing policy.
      client: 0
      random: 0
      overall: 0
      #
      # Add labels such as these example labels, if you want to configure labels globally. You can also configure labels on a per-API basis by using the Tracing policy.
      labels:
      - name: c-env-tag
        type: environment
        keyName: FLEX_NAME
        defaultValue: DEFAULT_VAL
      - name: c-header-tag
        type: requestHeader
        keyName: :method
        defaultValue: DEFAULT_METHOD
      - name: c-literal-tag
        type: literal
        defaultValue: the-tag
```

## [](#特定の-api-の分散トレースの設定)特定の API の分散トレースの設定

特定の API にトレースポリシーを適用することで、グローバルに設定された分散トレース設定を上書きできます。まずゲートウェイの分散トレースを有効にして設定する必要があります。その後、次のポリシーを計測する API に適用できます。

- [トレースポリシー](https://docs.mulesoft.com/jp/gateway/1.10/policies-included-tracing)