Skip to content

Commit

Permalink
[APM][OTel] Make agent names generic with otel-native mode (#195594)
Browse files Browse the repository at this point in the history
Closes #195583

### Summary

In the effort of making [APM UI work with otel-native
mode](elastic/opentelemetry-dev#385) we
introduced possibility for having any kind of agent names matching the
following format: `opentelemetry/*` or `otlp/*`.

This change forced us to modify the way we collect data in 'services'
and 'agents' tasks in apm telemetry.

Before the change, we could group data by agent names that were known
ahead of time.

Right now, for opentelemetry agents, we have to group them by unique
values. To achieve the following, we decided to run two ES queries:

1. Collects data by the known list of non-opentelemetry agents names
(the same approach as before but without opentelemetry agent names)
2. (_New_) Collects data starting from `opentelemetry/*` or `otlp/*` and
group them by unique value

To achieve backward compatibility, we initialize previously known
`opentelemetry/*` or `otlp/*` agent names with empty values before
collecting data. This way the new collectors match the old format,
adding only unique opentelemetry agent names.

### How to test
1. Change schedule interval to `1m` (default `720m`) in
`x-pack/plugins/observability_solution/apm/server/lib/apm_telemetry/index.ts`
2. Run kibana server in debug mode (`yarn debug-break`) and place
breakpoints in 'services' and 'agents' in
`x-pack/plugins/observability_solution/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts`
3. Verify tasks outputs:
<details>
<summary>`Services` task old output:</summary>

```json
{
  "dotnet": 6,
  "go": 22,
  "iOS/swift": 1,
  "java": 11,
  "js-base": 0,
  "nodejs": 12,
  "php": 1,
  "python": 2,
  "ruby": 2,
  "rum-js": 3,
  "android/java": 1,
  "ios/swift": 0,
  "otlp": 0,
  "opentelemetry": 0,
  "opentelemetry/cpp": 0,
  "opentelemetry/dotnet": 1,
  "opentelemetry/erlang": 1,
  "opentelemetry/go": 2,
  "opentelemetry/java": 4,
  "opentelemetry/nodejs": 2,
  "opentelemetry/php": 0,
  "opentelemetry/python": 1,
  "opentelemetry/ruby": 0,
  "opentelemetry/rust": 0,
  "opentelemetry/swift": 0,
  "opentelemetry/android": 0,
  "opentelemetry/webjs": 0,
  "otlp/cpp": 0,
  "otlp/dotnet": 0,
  "otlp/erlang": 0,
  "otlp/go": 0,
  "otlp/java": 0,
  "otlp/nodejs": 0,
  "otlp/php": 0,
  "otlp/python": 0,
  "otlp/ruby": 0,
  "otlp/rust": 0,
  "otlp/swift": 0,
  "otlp/android": 0,
  "otlp/webjs": 0
}
```
</details>
<details>
<summary>`Services` task new output:</summary>

```json
{
  "dotnet": 6,
  "go": 22,
  "iOS/swift": 1,
  "java": 11,
  "js-base": 0,
  "nodejs": 12,
  "php": 1,
  "python": 2,
  "ruby": 2,
  "rum-js": 3,
  "android/java": 1,
  "otlp": 0,
  "opentelemetry": 0,
  "opentelemetry/cpp": 0,
  "opentelemetry/dotnet": 1,
  "opentelemetry/erlang": 1,
  "opentelemetry/go": 2,
  "opentelemetry/java": 4,
  "opentelemetry/nodejs": 2,
  "opentelemetry/php": 0,
  "opentelemetry/python": 1,
  "opentelemetry/ruby": 0,
  "opentelemetry/rust": 0,
  "opentelemetry/swift": 0,
  "opentelemetry/android": 0,
  "opentelemetry/webjs": 0,
  "otlp/cpp": 0,
  "otlp/dotnet": 0,
  "otlp/erlang": 0,
  "otlp/go": 0,
  "otlp/java": 0,
  "otlp/nodejs": 0,
  "otlp/php": 0,
  "otlp/python": 0,
  "otlp/ruby": 0,
  "otlp/rust": 0,
  "otlp/swift": 0,
  "otlp/android": 0,
  "otlp/webjs": 0,
  "ios/swift": 0
}
```
</details>
<details>
<summary>`Agents` task old output:</summary>

```json
{
  "dotnet": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.19.0+f72bf10e024b0bad4601ccda7fdea7db46c71640"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "ASP.NET Core"
        ],
        "version": [
          "3.1.7.0"
        ],
        "composite": [
          "ASP.NET Core/3.1.7.0"
        ]
      },
      "language": {
        "name": [
          "C#"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "AWS_lambda",
          ".NET Core"
        ],
        "version": [
          "3.1.7"
        ],
        "composite": [
          ".NET Core/3.1.7"
        ]
      }
    }
  },
  "go": {
    "agent": {
      "activation_method": [],
      "version": [
        "2.6.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "gin"
        ],
        "version": [
          "v1.10.0"
        ],
        "composite": [
          "gin/v1.10.0"
        ]
      },
      "language": {
        "name": [
          "go"
        ],
        "version": [
          "go1.22.7",
          "go1.18.3"
        ],
        "composite": [
          "go/go1.22.7",
          "go/go1.18.3"
        ]
      },
      "runtime": {
        "name": [
          "gc"
        ],
        "version": [
          "go1.22.7",
          "go1.18.3"
        ],
        "composite": [
          "gc/go1.22.7",
          "gc/go1.18.3"
        ]
      }
    }
  },
  "iOS/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [
          "iOS"
        ],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "java"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "iOS"
        ],
        "version": [
          "13",
          "9",
          "11"
        ],
        "composite": [
          "iOS/13",
          "iOS/9",
          "iOS/11"
        ]
      }
    }
  },
  "java": {
    "agent": {
      "activation_method": [
        "k8s-attach"
      ],
      "version": [
        "1.38.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "Spring Web MVC",
          "Servlet API"
        ],
        "version": [
          "6.1.11"
        ],
        "composite": [
          "Spring Web MVC/6.1.11"
        ]
      },
      "language": {
        "name": [
          "Java"
        ],
        "version": [
          "17.0.12"
        ],
        "composite": [
          "Java/17.0.12"
        ]
      },
      "runtime": {
        "name": [
          "Java"
        ],
        "version": [
          "17.0.12"
        ],
        "composite": [
          "Java/17.0.12"
        ]
      }
    }
  },
  "js-base": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "nodejs": {
    "agent": {
      "activation_method": [
        "env-attach",
        "require"
      ],
      "version": [
        "3.46.0",
        "4.7.2"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "express"
        ],
        "version": [
          "4.19.2",
          "4.18.2"
        ],
        "composite": [
          "express/4.19.2",
          "express/4.18.2"
        ]
      },
      "language": {
        "name": [
          "javascript"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "AWS_lambda",
          "node"
        ],
        "version": [
          "18.13.0",
          "22.5.1"
        ],
        "composite": [
          "node/18.13.0",
          "node/22.5.1"
        ]
      }
    }
  },
  "php": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.8.4"
      ]
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "PHP"
        ],
        "version": [
          "8.0.30"
        ],
        "composite": [
          "PHP/8.0.30"
        ]
      },
      "runtime": {
        "name": [
          "PHP"
        ],
        "version": [
          "8.0.30"
        ],
        "composite": [
          "PHP/8.0.30"
        ]
      }
    }
  },
  "python": {
    "agent": {
      "activation_method": [
        "unknown"
      ],
      "version": [
        "6.22.3"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "django"
        ],
        "version": [
          "5.0.7"
        ],
        "composite": [
          "django/5.0.7"
        ]
      },
      "language": {
        "name": [
          "python"
        ],
        "version": [
          "3.12.4"
        ],
        "composite": [
          "python/3.12.4"
        ]
      },
      "runtime": {
        "name": [
          "AWS_lambda",
          "CPython"
        ],
        "version": [
          "3.12.4"
        ],
        "composite": [
          "CPython/3.12.4"
        ]
      }
    }
  },
  "ruby": {
    "agent": {
      "activation_method": [],
      "version": [
        "4.7.3"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "Ruby on Rails"
        ],
        "version": [
          "6.1.4.1"
        ],
        "composite": [
          "Ruby on Rails/6.1.4.1"
        ]
      },
      "language": {
        "name": [
          "ruby"
        ],
        "version": [
          "2.7.3"
        ],
        "composite": [
          "ruby/2.7.3"
        ]
      },
      "runtime": {
        "name": [
          "ruby"
        ],
        "version": [
          "2.7.3"
        ],
        "composite": [
          "ruby/2.7.3"
        ]
      }
    }
  },
  "rum-js": {
    "agent": {
      "activation_method": [],
      "version": [
        "5.16.0"
      ]
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "javascript"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "android/java": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [
          "Android Activity"
        ],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "java"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "Android Runtime"
        ],
        "version": [
          "2.1.0",
          "1.9.0",
          "2.0.0"
        ],
        "composite": [
          "Android Runtime/2.1.0",
          "Android Runtime/1.9.0",
          "Android Runtime/2.0.0"
        ]
      }
    }
  },
  "otlp": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/cpp": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/dotnet": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.4.0.802"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "OpenTelemetry.Instrumentation.Runtime"
        ],
        "version": [
          "1.1.0.2"
        ],
        "composite": [
          "OpenTelemetry.Instrumentation.Runtime/1.1.0.2"
        ]
      },
      "language": {
        "name": [
          "dotnet"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/erlang": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.2.1"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "opentelemetry_ecto",
          "opentelemetry_phoenix"
        ],
        "version": [
          "1.0.0"
        ],
        "composite": [
          "opentelemetry_ecto/1.0.0",
          "opentelemetry_phoenix/1.0.0"
        ]
      },
      "language": {
        "name": [
          "erlang"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "BEAM"
        ],
        "version": [
          "11.2.2.8"
        ],
        "composite": [
          "BEAM/11.2.2.8"
        ]
      }
    }
  },
  "opentelemetry/go": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.10.0",
        "1.11.2"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "go.opentelemetry.io/contrib/instrumentation/runtime"
        ],
        "version": [
          "semver:0.36.1",
          "semver:0.36.4"
        ],
        "composite": [
          "go.opentelemetry.io/contrib/instrumentation/runtime/semver:0.36.4",
          "go.opentelemetry.io/contrib/instrumentation/runtime/semver:0.36.1"
        ]
      },
      "language": {
        "name": [
          "go"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "go"
        ],
        "version": [
          "go1.19.2",
          "go1.19.4"
        ],
        "composite": [
          "go/go1.19.4",
          "go/go1.19.2"
        ]
      }
    }
  },
  "opentelemetry/java": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.10.1",
        "1.23.1",
        "1.24.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "io.opentelemetry.tomcat-10.0",
          "io.opentelemetry.jdbc",
          "io.opentelemetry.spring-data-1.8"
        ],
        "version": [
          "1.10.1",
          "1.23.0-alpha",
          "1.24.0-alpha"
        ],
        "composite": [
          "io.opentelemetry.tomcat-10.0/1.10.1",
          "io.opentelemetry.jdbc/1.10.1",
          "io.opentelemetry.spring-data-1.8/1.10.1"
        ]
      },
      "language": {
        "name": [
          "java"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "OpenJDK Runtime Environment"
        ],
        "version": [
          "17.0.12+7",
          "11.0.18+10-LTS",
          "17.0.6+10-Debian-1deb11u1"
        ],
        "composite": [
          "OpenJDK Runtime Environment/17.0.12+7",
          "OpenJDK Runtime Environment/11.0.18+10-LTS",
          "OpenJDK Runtime Environment/17.0.6+10-Debian-1deb11u1"
        ]
      }
    }
  },
  "opentelemetry/nodejs": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.10.1",
        "1.9.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "@opentelemetry/instrumentation-fs",
          "@opentelemetry/instrumentation-http",
          "@opentelemetry/instrumentation-net"
        ],
        "version": [
          "0.7.1",
          "0.6.0",
          "0.35.1"
        ],
        "composite": [
          "@opentelemetry/instrumentation-fs/0.7.1",
          "@opentelemetry/instrumentation-fs/0.6.0",
          "@opentelemetry/instrumentation-http/0.35.1"
        ]
      },
      "language": {
        "name": [
          "nodejs"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "nodejs"
        ],
        "version": [
          "18.16.0",
          "16.20.0"
        ],
        "composite": [
          "nodejs/18.16.0",
          "nodejs/16.20.0"
        ]
      }
    }
  },
  "opentelemetry/php": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/python": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.15.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "opentelemetry.instrumentation.system_metrics"
        ],
        "version": [
          "0.36b0"
        ],
        "composite": [
          "opentelemetry.instrumentation.system_metrics/0.36b0"
        ]
      },
      "language": {
        "name": [
          "python"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/ruby": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/rust": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/android": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/webjs": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/cpp": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/dotnet": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/erlang": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/go": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/java": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/nodejs": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/php": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/python": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/ruby": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/rust": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/android": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/webjs": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "ios/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  }
}
```
</details>
<details>
<summary>`Agents` task new output:</summary>

```json
{
  "dotnet": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.19.0+f72bf10e024b0bad4601ccda7fdea7db46c71640"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "ASP.NET Core"
        ],
        "version": [
          "3.1.7.0"
        ],
        "composite": [
          "ASP.NET Core/3.1.7.0"
        ]
      },
      "language": {
        "name": [
          "C#"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "AWS_lambda",
          ".NET Core"
        ],
        "version": [
          "3.1.7"
        ],
        "composite": [
          ".NET Core/3.1.7"
        ]
      }
    }
  },
  "go": {
    "agent": {
      "activation_method": [],
      "version": [
        "2.6.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "gin"
        ],
        "version": [
          "v1.10.0"
        ],
        "composite": [
          "gin/v1.10.0"
        ]
      },
      "language": {
        "name": [
          "go"
        ],
        "version": [
          "go1.22.7",
          "go1.18.3"
        ],
        "composite": [
          "go/go1.22.7",
          "go/go1.18.3"
        ]
      },
      "runtime": {
        "name": [
          "gc"
        ],
        "version": [
          "go1.22.7",
          "go1.18.3"
        ],
        "composite": [
          "gc/go1.22.7",
          "gc/go1.18.3"
        ]
      }
    }
  },
  "iOS/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [
          "iOS"
        ],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "java"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "iOS"
        ],
        "version": [
          "13",
          "9",
          "11"
        ],
        "composite": [
          "iOS/13",
          "iOS/9",
          "iOS/11"
        ]
      }
    }
  },
  "java": {
    "agent": {
      "activation_method": [
        "k8s-attach"
      ],
      "version": [
        "1.38.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "Spring Web MVC",
          "Servlet API"
        ],
        "version": [
          "6.1.11"
        ],
        "composite": [
          "Spring Web MVC/6.1.11"
        ]
      },
      "language": {
        "name": [
          "Java"
        ],
        "version": [
          "17.0.12"
        ],
        "composite": [
          "Java/17.0.12"
        ]
      },
      "runtime": {
        "name": [
          "Java"
        ],
        "version": [
          "17.0.12"
        ],
        "composite": [
          "Java/17.0.12"
        ]
      }
    }
  },
  "js-base": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "nodejs": {
    "agent": {
      "activation_method": [
        "env-attach",
        "require"
      ],
      "version": [
        "3.46.0",
        "4.7.2"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "express"
        ],
        "version": [
          "4.19.2",
          "4.18.2"
        ],
        "composite": [
          "express/4.19.2",
          "express/4.18.2"
        ]
      },
      "language": {
        "name": [
          "javascript"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "AWS_lambda",
          "node"
        ],
        "version": [
          "18.13.0",
          "22.5.1"
        ],
        "composite": [
          "node/18.13.0",
          "node/22.5.1"
        ]
      }
    }
  },
  "php": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.8.4"
      ]
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "PHP"
        ],
        "version": [
          "8.0.30"
        ],
        "composite": [
          "PHP/8.0.30"
        ]
      },
      "runtime": {
        "name": [
          "PHP"
        ],
        "version": [
          "8.0.30"
        ],
        "composite": [
          "PHP/8.0.30"
        ]
      }
    }
  },
  "python": {
    "agent": {
      "activation_method": [
        "unknown"
      ],
      "version": [
        "6.22.3"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "django"
        ],
        "version": [
          "5.0.7"
        ],
        "composite": [
          "django/5.0.7"
        ]
      },
      "language": {
        "name": [
          "python"
        ],
        "version": [
          "3.12.4"
        ],
        "composite": [
          "python/3.12.4"
        ]
      },
      "runtime": {
        "name": [
          "AWS_lambda",
          "CPython"
        ],
        "version": [
          "3.12.4"
        ],
        "composite": [
          "CPython/3.12.4"
        ]
      }
    }
  },
  "ruby": {
    "agent": {
      "activation_method": [],
      "version": [
        "4.7.3"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "Ruby on Rails"
        ],
        "version": [
          "6.1.4.1"
        ],
        "composite": [
          "Ruby on Rails/6.1.4.1"
        ]
      },
      "language": {
        "name": [
          "ruby"
        ],
        "version": [
          "2.7.3"
        ],
        "composite": [
          "ruby/2.7.3"
        ]
      },
      "runtime": {
        "name": [
          "ruby"
        ],
        "version": [
          "2.7.3"
        ],
        "composite": [
          "ruby/2.7.3"
        ]
      }
    }
  },
  "rum-js": {
    "agent": {
      "activation_method": [],
      "version": [
        "5.16.0"
      ]
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "javascript"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "android/java": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [
          "Android Activity"
        ],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [
          "java"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "Android Runtime"
        ],
        "version": [
          "2.1.0",
          "1.9.0",
          "2.0.0"
        ],
        "composite": [
          "Android Runtime/2.1.0",
          "Android Runtime/1.9.0",
          "Android Runtime/2.0.0"
        ]
      }
    }
  },
  "ios/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/cpp": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/dotnet": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.4.0.802"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "OpenTelemetry.Instrumentation.Runtime"
        ],
        "version": [
          "1.1.0.2"
        ],
        "composite": [
          "OpenTelemetry.Instrumentation.Runtime/1.1.0.2"
        ]
      },
      "language": {
        "name": [
          "dotnet"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/erlang": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.2.1"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "opentelemetry_ecto",
          "opentelemetry_phoenix"
        ],
        "version": [
          "1.0.0"
        ],
        "composite": [
          "opentelemetry_ecto/1.0.0",
          "opentelemetry_phoenix/1.0.0"
        ]
      },
      "language": {
        "name": [
          "erlang"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "BEAM"
        ],
        "version": [
          "11.2.2.8"
        ],
        "composite": [
          "BEAM/11.2.2.8"
        ]
      }
    }
  },
  "opentelemetry/go": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.10.0",
        "1.11.2"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "go.opentelemetry.io/contrib/instrumentation/runtime"
        ],
        "version": [
          "semver:0.36.1",
          "semver:0.36.4"
        ],
        "composite": [
          "go.opentelemetry.io/contrib/instrumentation/runtime/semver:0.36.4",
          "go.opentelemetry.io/contrib/instrumentation/runtime/semver:0.36.1"
        ]
      },
      "language": {
        "name": [
          "go"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "go"
        ],
        "version": [
          "go1.19.2",
          "go1.19.4"
        ],
        "composite": [
          "go/go1.19.4",
          "go/go1.19.2"
        ]
      }
    }
  },
  "opentelemetry/java": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.10.1",
        "1.23.1",
        "1.24.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "io.opentelemetry.tomcat-10.0",
          "io.opentelemetry.jdbc",
          "io.opentelemetry.spring-data-1.8"
        ],
        "version": [
          "1.10.1",
          "1.23.0-alpha",
          "1.24.0-alpha"
        ],
        "composite": [
          "io.opentelemetry.tomcat-10.0/1.10.1",
          "io.opentelemetry.jdbc/1.10.1",
          "io.opentelemetry.spring-data-1.8/1.10.1"
        ]
      },
      "language": {
        "name": [
          "java"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "OpenJDK Runtime Environment"
        ],
        "version": [
          "17.0.12+7",
          "11.0.18+10-LTS",
          "17.0.6+10-Debian-1deb11u1"
        ],
        "composite": [
          "OpenJDK Runtime Environment/17.0.12+7",
          "OpenJDK Runtime Environment/11.0.18+10-LTS",
          "OpenJDK Runtime Environment/17.0.6+10-Debian-1deb11u1"
        ]
      }
    }
  },
  "opentelemetry/nodejs": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.10.1",
        "1.9.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "@opentelemetry/instrumentation-fs",
          "@opentelemetry/instrumentation-http",
          "@opentelemetry/instrumentation-net"
        ],
        "version": [
          "0.7.1",
          "0.6.0",
          "0.35.1"
        ],
        "composite": [
          "@opentelemetry/instrumentation-fs/0.7.1",
          "@opentelemetry/instrumentation-fs/0.6.0",
          "@opentelemetry/instrumentation-http/0.35.1"
        ]
      },
      "language": {
        "name": [
          "nodejs"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [
          "nodejs"
        ],
        "version": [
          "18.16.0",
          "16.20.0"
        ],
        "composite": [
          "nodejs/18.16.0",
          "nodejs/16.20.0"
        ]
      }
    }
  },
  "opentelemetry/php": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/python": {
    "agent": {
      "activation_method": [],
      "version": [
        "1.15.0"
      ]
    },
    "service": {
      "framework": {
        "name": [
          "opentelemetry.instrumentation.system_metrics"
        ],
        "version": [
          "0.36b0"
        ],
        "composite": [
          "opentelemetry.instrumentation.system_metrics/0.36b0"
        ]
      },
      "language": {
        "name": [
          "python"
        ],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/ruby": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/rust": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/android": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "opentelemetry/webjs": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/cpp": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/dotnet": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/erlang": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/go": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/java": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/nodejs": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/php": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/python": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/ruby": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/rust": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/swift": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/android": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  },
  "otlp/webjs": {
    "agent": {
      "activation_method": [],
      "version": []
    },
    "service": {
      "framework": {
        "name": [],
        "version": [],
        "composite": []
      },
      "language": {
        "name": [],
        "version": [],
        "composite": []
      },
      "runtime": {
        "name": [],
        "version": [],
        "composite": []
      }
    }
  }
}
```
</details>

---------

Co-authored-by: Alejandro Fernández Haro <[email protected]>
(cherry picked from commit 70d1597)
  • Loading branch information
miloszmarcinkowski committed Oct 16, 2024
1 parent ddcecd6 commit 03494bb
Show file tree
Hide file tree
Showing 11 changed files with 7,910 additions and 168 deletions.
34 changes: 5 additions & 29 deletions packages/kbn-elastic-agent-utils/src/agent_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,13 @@ export const ELASTIC_AGENT_NAMES: ElasticAgentName[] = [
];

export type OpenTelemetryAgentName =
| 'otlp'
| 'opentelemetry'
| 'opentelemetry/cpp'
| 'opentelemetry/dotnet'
| 'opentelemetry/erlang'
| 'opentelemetry/go'
| 'opentelemetry/java'
| 'opentelemetry/nodejs'
| 'opentelemetry/php'
| 'opentelemetry/python'
| 'opentelemetry/ruby'
| 'opentelemetry/rust'
| 'opentelemetry/swift'
| 'opentelemetry/android'
| 'opentelemetry/webjs'
| 'otlp/cpp'
| 'otlp/dotnet'
| 'otlp/erlang'
| 'otlp/go'
| 'otlp/java'
| 'otlp/nodejs'
| 'otlp/php'
| 'otlp/python'
| 'otlp/ruby'
| 'otlp/rust'
| 'otlp/swift'
| 'otlp/android'
| 'otlp/webjs';
| 'otlp'
| `opentelemetry/${string}`
| `otlp/${string}`;
export const OPEN_TELEMETRY_BASE_AGENT_NAMES: OpenTelemetryAgentName[] = ['otlp', 'opentelemetry'];
export const OPEN_TELEMETRY_AGENT_NAMES: OpenTelemetryAgentName[] = [
'otlp',
'opentelemetry',
...OPEN_TELEMETRY_BASE_AGENT_NAMES,
'opentelemetry/cpp',
'opentelemetry/dotnet',
'opentelemetry/erlang',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export interface MappedTypes {
mappedTypeWithOneInlineProp: {
[key in 'prop3']: number;
};
mappedTypeWithLiteralTemplates: {
[key in MappedTypeProps | `templated_prop/${string}`]: number;
};
}

export type RecordWithKnownProps = Record<MappedTypeProps, number>;
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-telemetry-tools/src/tools/serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ describe('getDescriptor', () => {
mappedTypeWithOneInlineProp: {
prop3: { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
},
mappedTypeWithLiteralTemplates: {
prop1: { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
prop2: { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
// ideally, it'd be `templated_prop/@@INDEX@@` to be more explicit. But we're going with the fuzzier approach
// for now as it may require more changes downstream that are not worth it.
'@@INDEX@@': { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
},
});
});

Expand Down
11 changes: 8 additions & 3 deletions packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ export function getConstraints(node: ts.Node, program: ts.Program): any {
return node.literal.text;
}

if (ts.isStringLiteral(node)) {
if (ts.isStringLiteral(node) || ts.isStringLiteralLike(node)) {
return node.text;
}

// template literals such as `smth/${string}`
if (ts.isTemplateLiteralTypeNode(node) || ts.isTemplateExpression(node)) {
return '@@INDEX@@'; // just map it to any kind of string. We can enforce it further in the future if we see fit.
}

if (ts.isImportSpecifier(node) || ts.isExportSpecifier(node)) {
const source = node.getSourceFile();
const importedModuleName = getModuleSpecifier(node);
Expand Down Expand Up @@ -180,9 +185,9 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
const constraintsArray = Array.isArray(constraints) ? constraints : [constraints];
if (typeof constraintsArray[0] === 'string') {
return constraintsArray.reduce((acc, c) => {
(acc as Record<string, unknown>)[c] = descriptor;
acc[c] = descriptor;
return acc;
}, {});
}, {} as Record<string, unknown>);
}
}
return { '@@INDEX@@': descriptor };
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 03494bb

Please sign in to comment.