# AUTOGENERATED BY ./scripts/codegen.py. DO NOT EDIT.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

{% macro glean_type(type) -%}
  {%- if type == "integer" -%}
  {#- This should be called integer by glean. Number refers to a double by the
      jsonschema spec -#}
    number
  {%- else -%}
    {{ type }}
  {%- endif -%}
{%- endmacro -%}

---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0

$tags:
  - "Toolkit :: Gecko Trace"

gecko_trace:
  traces_data:
    type: object
    description: >
      Represents the telemetry traces data collected during browser operation. This data
      provides insights into errors that occur in Firefox during runtime.

      Based on the [TracesData OTLP](1) protobuf definition which provides a standardized
      format for collecting and transmitting trace information.

      [1]: https://github.com/open-telemetry/opentelemetry-proto/blob/c0a98a1847d3124ac5f9ecd02d0e2d2732bbb590/opentelemetry/proto/trace/v1/trace.proto#L38
    send_in_pings:
      - gecko-trace
    notification_emails:
      - mvanstraten@mozilla.com
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1930954
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1930954
    expires: never
    # This is currently not transmitted over telemetry and thus useless for us
    # version: 0.1
    structure:
      type: object
      properties:
        version:
          type: string
        resource_spans:
          type: array
          items:
            type: object
            properties:
              # A resource represents the entity producing telemetry data, identified by a set
              # of resource attributes.
              #
              # For example, a gecko process producing traces in Firefox has a process ID and
              # a process type (e.g., ContentChild). The opentelemetry-cpp library additionally
              # enforces four extra resource attributes which are listed below. These attributes
              # help identify the source and context of the telemetry data.
              #
              # For more information, see:
              # https://opentelemetry.io/docs/concepts/resources/
              resource:
                type: object
                properties:
                  attributes:
                    type: object
                    properties:
                      gecko.process.internal_id:
                        type: number
                      gecko.process.type:
                        type: string
                      service.name:
                        type: string
                      telemetry.sdk.language:
                        type: string
                      telemetry.sdk.name:
                        type: string
                      telemetry.sdk.version:
                        type: string
              scope_spans:
                type: array
                items:
                  type: object
                  properties:
                    # Instrumentation scope represents a logical unit within the application code with
                    # which the emitted telemetry can be associated. This helps in organizing and
                    # categorizing telemetry data based on its origin within the codebase.
                    #
                    # For more information, see:
                    # https://opentelemetry.io/docs/concepts/instrumentation-scope/
                    scope:
                      type: object
                      properties:
                        name:
                          type: string
                    # A list of Spans that originate from an instrumentation scope. Spans represent
                    # individual operations or units of work within a trace and contain timing,
                    # metadata, and event information about these operations.
                    #
                    # For more information, see:
                    # https://opentelemetry.io/docs/concepts/signals/traces/#spans
                    spans:
                      type: array
                      items:
                        type: object
                        properties:
                          # A unique identifier for a trace. All spans from the same trace share
                          # the same `trace_id`, allowing related spans to be grouped together
                          # and analyzed as a single transaction or operation flow.
                          trace_id:
                            type: string
                          # A unique identifier for a span within a trace. This ID distinguishes
                          # each span from others within the same trace.
                          span_id:
                            type: string
                          # The `span_id` of this span's parent span. This establishes the
                          # hierarchical relationship between spans, creating a tree structure
                          # that represents the execution path.
                          parent_span_id:
                            type: string
                          # A human-readable description of the operation represented by this span.
                          name:
                            type: string
                          start_time_unix_nano:
                            type: number
                          end_time_unix_nano:
                            type: number
                          # Events are time-stamped annotations within a span that mark significant
                          # moments or state changes during the span's lifetime.
                          events:
                            type: array
                            items:
                              type: object
                              properties:
                                name:
                                  type: string
                                # The time the event occurred.
                                time_unix_nano:
                                  type: number
                                # A collection of attribute key/value pairs associated with the event.
                                # These attributes provide detailed information about the event's
                                # context, parameters, and results.
                                #
                                # New attribute key/value pairs can be defined in gecko-trace.yaml
                                # files.
                                attributes:
                                  type: object
                                  properties:
                                  {% for event_name, event in events.items() %}
                                    # Generated from: {{ event.__definition_site__ }}
                                    {% for attr_key, attr in event.attributes.items() %}
                                    {{ attr_key }}:
                                      {% if attr.type == "array" %}
                                      type: array
                                      items:
                                        type: {{ glean_type(attr["items"]["type"]) }}
                                      {% else %}
                                      type: {{ glean_type(attr.type) }}
                                      {% endif %}
                                    {% endfor %}
                                  {% endfor %}
