Is there a way to access the trace tag of the rule execution from the rule execution itself

I want to know if I can access the trace tag from within a rule definition via jinja interpolation.

Not really. Why do you want to do this?

I have a task in my workflow that is used to email admins if previous tasks within an orquesta workflow failed. In the email, it would really be handy to tell the admins what trace tag the current workflow is operating under.

This looks useful. Please open an issue at the st2 repo and request the feature.

1 Like

Posted a feature request: Make trace info available from within an orquesta workflow definition · Issue #4627 · StackStorm/st2 · GitHub

For future people: You can actually do this now, but using curl as a workaround e.g. within orquesta:

    action: core.local
      cmd: >
        -X GET
        -H 'Connection: keep-alive'
        -H 'Accept-Encoding: gzip, deflate'
        -H 'Accept: application/json'
        -H "X-Auth-Token: ${ST2_ACTION_AUTH_TOKEN}"
        | jq -r '.[0].trace_tag'
        | tr -d '\n\t '
      timeout: 60
      - publish:
          - get_tracetag_result: "{{ result() }}"
          - trace_tag: "{{ result().stdout }}"
        do: notify

(You’d have to install jq first for the above to work on a typical linux system.)

This is possible because of environment variables available to actions.

@djhaskin987 Thank you for this workaround.