スパンプロセッサー

スパンプロセッサーを使って、その属性に基づいてスパン名を修正したり、スパン名からスパン属性を抽出したりします。

スパンプロセッサーは、以下のことを可能にします:

  • 属性に基づいてスパン名を修正します。

  • スパン名からスパン属性を抽出します。

  • スパンのステータスを変更します。

  • 必要に応じて、スパンを含めたり除外したりできます。詳しくは GitHub のフィルタリングリポジトリ「Include/Exclude Filtering」を参照してください。

サポートされるパイプラインタイプは traces です。詳細については「パイプラインでデータを処理する」を参照してください。

はじめに

以下の手順に従って、コンポーネントの設定とアクティベーションを行ってください:

  1. Splunk Distribution of OpenTelemetry Collector をホストまたはコンテナプラットフォームにデプロイします:

  2. 次のセクションで説明するように、スパンプロセッサーを設定します。

  3. Collector を再起動します。

サンプル構成

スパンプロセッサーを有効にするには、以下の例に示すように、設定ファイルの processors セクションにspan を追加します:

YAML
resource:
  span:
    name:
    status:

プロセッサーは以下の動作をサポートします:

  • name:スパン内の属性名を変更します。

  • status:スパンのステータスを変更します。

次に、設定ファイルのサービスパイプラインセクションにプロセッサーを追加します。例:

YAML
service:
  pipelines:
    traces:
      processors: [span]

span プロセッサーを使用します。

スパンに名前を付ける

スパンに名前を付けるには、以下の設定を使用します:

  • from_attributesします。必須。設定で指定された順序で新しい名前を作成するために使用されるキーの属性値。

  • separator:値を分割するための文字列。

注: 名前の変更が「属性プロセッサ」によって変更される属性に依存する場合、パイプラインの属性プロセッサの後にスパンプロセッサが指定されていることを確認します。
YAML
span:
  name:
    # from_attributes represents the attribute keys to pull the values from to generate the new span name.
    from_attributes: [<key1>, <key2>, ...]
    # Separator is the string used to concatenate various parts of the span name.
    separator: <value>

次の例を参照してください:

YAML
span:
  name:
    from_attributes: ["db.svc", "operation"]
    separator: "::"

スパン名から属性を抽出する

span プロセッサは、スパン名とマッチする正規表現のリストを受け取り、その中から部分式に基づいて属性を抽出します。これは to_attributes セクションで指定する必要があります。

スパン名から属性を抽出するには、以下の設定を使用します:

  • rulesします。必須。スパン名から属性値を抽出するルールのリスト。スパン名の値は、抽出された属性名に置き換えられます。リスト内の各ルールは、正規表現パターン文字列です。

    • スパン名は正規表現と照合され、正規表現がマッチした場合、正規表現のすべての名前付き部分式が属性として抽出され、スパンに追加されます。

    • それぞれの副次式名が属性名となり、副次式にマッチした部分が属性値となります。スパン名の一致した部分は、抽出された属性名に置き換えられます。

    • もしその属性が既にスパンに存在していれば、それらは上書きされます。

    • この処理は、指定された順序で、すべてのルールに対して繰り返されます。後続の各ルールは、前のルールの処理後の出力であるスパン名に対して機能します。

  • break_after_matchします。必須。デフォルトでは false です。最初の一致の後にルールの処理を停止するかどうかを指定します。false の場合、ルール処理は変更されたスパン名に対して引き続き実行されます。

YAML
span/to_attributes:
  name:
    to_attributes:
      rules:
        - regexp-rule1
        - regexp-rule2
        - regexp-rule3
        ...
      break_after_match: <true|false>

次の例を参照してください:

YAML
# Let's assume input span name is /api/v1/document/12345678/update
# Applying the following results in output span name /api/v1/document/{documentId}/update
# and will add a new attribute "documentId"="12345678" to the span.
span/to_attributes:
  name:
    to_attributes:
      rules:
        - ^\/api\/v1\/document\/(?P<documentId>.*)\/update$

スパンのステータスを設定する

スパンのステータスを設定するには、以下の設定を参照してください:

  • codeします。必須。スパンのステータスを表します。許容値は UnsetErrorOk です。

  • descriptionします。コード Error にのみ使用されます。

次の例を参照してください:

YAML
# Set status allows to set specific status for a given span. Possible values are
# Ok, Error and Unset as per
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
# The description field allows to set a human-readable message for errors.
span/set_status:
  status:
    code: Error
    description: "some error description"

設定

以下の表は、スパンプロセッサーの設定オプションを示しています:

同梱

https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/processor/span.yaml

トラブルシューティング

If you are a Splunk Observability Cloud customer and are not able to see your data in Splunk Observability Cloud, you can get help in the following ways.

Available to Splunk Observability Cloud customers

Available to prospective customers and free trial users

  • Ask a question and get answers through community support at Splunk Answers.

  • Join the Splunk community #observability Slack channel to communicate with customers, partners, and Splunk employees worldwide.