Allow modules to alter request span attributes

Created on 13 June 2024, 5 months ago
Updated 28 June 2024, 5 months ago

Problem/Motivation

I'd like to add further information about the application to traces, as currently provided by the opentelemetry module.

Proposed resolution

  • Add an alter hook to allow other modules to extend trace attributes
  • Add API Docs how to utilize the alter hook
  • Add API Docs how to add resource information to traces

API changes

Introduce "hook_opentelemetry_request_attributes_alter()".

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇩🇪Germany Daniel Kulbe Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Daniel Kulbe
  • Pipeline finished with Success
    5 months ago
    Total: 176s
    #197802
  • Status changed to Needs review 5 months ago
  • Assigned to murz
  • Status changed to Needs work 5 months ago
  • 🇦🇲Armenia murz Yerevan, Armenia

    Thank you for the suggestion, but I think it's better to provide an Event than a Hook, cuz hooks are already considered as legacy approach.
    I will prepare a separate MR with this.

  • Status changed to Needs review 5 months ago
  • 🇦🇲Armenia murz Yerevan, Armenia

    I reworked the MR https://git.drupalcode.org/issue/opentelemetry-3454318/-/tree/3454318-al... to events, so now you can subscribe to the OpenTelemetrySpanBuilderEvent to alter the whole request span, not even only attributes.
    Please check if it works for you.

    Also, maybe also add an event for plugins like RequestTrace, ExceptionTrace, etc?

  • 🇦🇲Armenia murz Yerevan, Armenia

    I also added the event dispatching to all plugins, please test.

  • 🇩🇪Germany Daniel Kulbe Berlin

    I want to point out, you dropped the whole API documentation from my initial commit, without any replacement. I'd love to have some information about the Event approach in the README instead, so I will know it is possible at all.

    In this approach I see e big flaw ... all properties of the SpanBulder are private ... so I got no clue if I have to rely on an attribute to be present. May be I am missing something, as I am not that deep into the SDK, yet.

Production build 0.71.5 2024