Skip to content

APM telemetry collection Otel agent distro diferentiation - issue 489#210775

Merged
marcogavaz merged 3 commits intoelastic:mainfrom
marcogavaz:observability-apm-distro-telemetry-collection-issue-489
Feb 14, 2025
Merged

APM telemetry collection Otel agent distro diferentiation - issue 489#210775
marcogavaz merged 3 commits intoelastic:mainfrom
marcogavaz:observability-apm-distro-telemetry-collection-issue-489

Conversation

@marcogavaz
Copy link
Contributor

@marcogavaz marcogavaz commented Feb 12, 2025

Summary

This PRs follows the closed PR and Closes https://github.com/elastic/observability-bi/issues/489

As requested in this comment and tracked by the issue #186281 this PR handles main changes introduced to address the request for capturing open-ended OTel distro agent names with patter opentelemetry/<LANGUAGE>/<DISTRO_NAME>. These changes ensure that new agent names won’t be dropped in telemetry.

Changes introduced in services task

Previously telemetry code enumerated OTel agents using a static array (OPEN_TELEMETRY_AGENT_NAMES) listing known agent names (like opentelemetry/java, opentelemetry/go, etc.), while now it starts with an empty object and dynamically add whatever agent names es query returns, so after retrieving the results, we let the data from the terms aggregator define which agent names exist, rather than forcing them to match any fixed array.

This is taken care mainly in:

    const servicesPerOtelAgents = await OPEN_TELEMETRY_BASE_AGENT_NAMES.reduce(
        (prevJob, baseAgentName) => {
          return prevJob.then(async (accData) => {
            const response = await telemetryClient.search({
              index: [indices.error, indices.span, indices.metric, indices.transaction],
              body: {
                size: 0,
                track_total_hits: false,
                timeout,
                query: {
                  bool: {
                    filter: [{ prefix: { [AGENT_NAME]: baseAgentName } }, range1d],
                  },
                },
                aggs: {
                  agent_name: {
                    terms: {
                      field: AGENT_NAME,
                      size: 1000,
                    },
                    aggs: {
                      services: {
                        cardinality: {
                          field: SERVICE_NAME,
                        },
                      },
                    },
                  },
                },
              },
            });
            const aggregatedServices: Record<string, number> = {};
            for (const bucket of response.aggregations?.agent_name.buckets ?? []) {
              const fullAgentName = bucket.key as string;
              aggregatedServices[fullAgentName] = bucket.services.value || 0;
            }
            return {
              ...accData,
              ...aggregatedServices,
            };
          });
        },
        Promise.resolve({} as Record<string, number>)
      );

so for example if a new agent.name like opentelemetry/java/elastic appears in the data, we automatically add it to aggregatedServices

Changes introduced in agents task

Similarly telemetry code started with a large dictionary built from OPEN_TELEMETRY_AGENT_NAMES and then for each prefix opentelemetr or otlp it aggregated subfields (framework, language, runtime versions) and tried to map them to the dictionary.
While now after the prefix-based aggregator runs it look at the returned buckets. For each agentBucket (with a key opentelemetry/<LANGUAGE>/<DISTRO_NAME> ) an entry is dynamically created.

      const agentDataWithOtel = await OPEN_TELEMETRY_BASE_AGENT_NAMES.reduce(
        async (prevJob, baseAgentName) => {
          const data = await prevJob;

          const response = await telemetryClient.search({
            index: [indices.error, indices.metric, indices.transaction],
            body: {
              track_total_hits: false,
              size: 0,
              timeout,
              query: {
                bool: {
                  filter: [{ prefix: { [AGENT_NAME]: baseAgentName } }, range1d],
                },
              },
              sort: {
                '@timestamp': 'desc',
              },
              aggs: {
                agent_name: {
                  terms: {
                    field: AGENT_NAME,
                    size: 1000,
                  },
                  aggs: agentNameAggs,
                },
              },
            },
          });

This PR should be enough in order to be able to differentiate our distro from any other OTel distro as requested.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

@marcogavaz marcogavaz requested a review from kpatticha February 12, 2025 10:26
@marcogavaz marcogavaz self-assigned this Feb 12, 2025
@marcogavaz marcogavaz marked this pull request as ready for review February 12, 2025 14:24
@marcogavaz marcogavaz requested a review from a team February 12, 2025 14:24
@marcogavaz marcogavaz changed the title [DRAFT] APM telemetry collection Otel agent distro diferentiation - issue 489 APM telemetry collection Otel agent distro diferentiation - issue 489 Feb 12, 2025
@botelastic botelastic bot added the Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. label Feb 12, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@marcogavaz marcogavaz added the backport This PR is a backport of another PR label Feb 12, 2025
@marcogavaz
Copy link
Contributor Author

@elasticmachine merge upstream

@marcogavaz marcogavaz enabled auto-merge (squash) February 12, 2025 16:57
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @marcogavaz

Copy link
Contributor

@kpatticha kpatticha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work.

it would be great if you could update the PR description to include a short summary (for future reference_

@marcogavaz marcogavaz merged commit 1ee13ca into elastic:main Feb 14, 2025
9 checks passed
@kibanamachine kibanamachine added v9.1.0 backport:skip This PR does not require backporting labels Feb 14, 2025
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…elastic#210775)

## Summary

This PRs follows the [closed PR
](elastic#208770) and Closes
elastic/observability-bi#489

As requested in [this comment
](elastic#186281 (comment)) and
tracked by the issue elastic#186281
this PR handles main changes introduced to address the request for
capturing open-ended OTel distro agent names with patter
`opentelemetry/<LANGUAGE>/<DISTRO_NAME>`. These changes ensure that new
agent names won’t be dropped in telemetry.



### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@trentm
Copy link
Member

trentm commented Jun 16, 2025

FYI: I discussed with @basepi about backporting this to 8.19. He agrees that having this in 8.19 (along with 9.1) would be "just fine with us [BI team]".

My motivation for backporting this is so that x-pack/solutions/observability/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/__snapshots__/tasks.test.ts.snap is the same in 8.19 and 9.1 (main) branches so that backporting changes that touch that file don't run into merge conflicts. My recent #222883 has run into a merge conflict. There will be more similar PRs coming (e.g. this one in draft: #223565).

I'm not sure if adding the "8.19" label to the PR after it has been merged will trigger automatic backporting PR generation. I will try that. Failing that, I'll use ./scripts/backport manually.

@trentm
Copy link
Member

trentm commented Jun 16, 2025

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

trentm added a commit that referenced this pull request Jun 17, 2025
…sue 489 (#210775) (#224160)

# Backport

This will backport the following commits from `main` to `8.19`:
- [APM telemetry collection Otel agent distro diferentiation - issue 489
(#210775)](#210775)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Marco
Gavazzoni","email":"138492709+marcogavaz@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-14T14:11:29Z","message":"APM
telemetry collection Otel agent distro diferentiation - issue 489
(#210775)\n\n## Summary\r\n\r\nThis PRs follows the [closed
PR\r\n](#208770) and
Closes\r\nhttps://github.com/elastic/observability-bi/issues/489\r\n\r\nAs
requested in [this
comment\r\n](#186281 (comment))
and\r\ntracked by the issue
https://github.com/elastic/kibana/issues/186281\r\nthis PR handles main
changes introduced to address the request for\r\ncapturing open-ended
OTel distro agent names with
patter\r\n`opentelemetry/<LANGUAGE>/<DISTRO_NAME>`. These changes ensure
that new\r\nagent names won’t be dropped in
telemetry.\r\n\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies
following conditions. \r\n\r\nReviewers should verify this PR satisfies
this list as well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"1ee13cae705f2bf564a18c492bca4f9809245f7e","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","backport:skip","Team:obs-ux-infra_services","v9.1.0","v8.19.0"],"title":"APM
telemetry collection Otel agent distro diferentiation - issue
489","number":210775,"url":"https://github.com/elastic/kibana/pull/210775","mergeCommit":{"message":"APM
telemetry collection Otel agent distro diferentiation - issue 489
(#210775)\n\n## Summary\r\n\r\nThis PRs follows the [closed
PR\r\n](#208770) and
Closes\r\nhttps://github.com/elastic/observability-bi/issues/489\r\n\r\nAs
requested in [this
comment\r\n](#186281 (comment))
and\r\ntracked by the issue
https://github.com/elastic/kibana/issues/186281\r\nthis PR handles main
changes introduced to address the request for\r\ncapturing open-ended
OTel distro agent names with
patter\r\n`opentelemetry/<LANGUAGE>/<DISTRO_NAME>`. These changes ensure
that new\r\nagent names won’t be dropped in
telemetry.\r\n\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies
following conditions. \r\n\r\nReviewers should verify this PR satisfies
this list as well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"1ee13cae705f2bf564a18c492bca4f9809245f7e"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210775","number":210775,"mergeCommit":{"message":"APM
telemetry collection Otel agent distro diferentiation - issue 489
(#210775)\n\n## Summary\r\n\r\nThis PRs follows the [closed
PR\r\n](#208770) and
Closes\r\nhttps://github.com/elastic/observability-bi/issues/489\r\n\r\nAs
requested in [this
comment\r\n](#186281 (comment))
and\r\ntracked by the issue
https://github.com/elastic/kibana/issues/186281\r\nthis PR handles main
changes introduced to address the request for\r\ncapturing open-ended
OTel distro agent names with
patter\r\n`opentelemetry/<LANGUAGE>/<DISTRO_NAME>`. These changes ensure
that new\r\nagent names won’t be dropped in
telemetry.\r\n\r\n\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies
following conditions. \r\n\r\nReviewers should verify this PR satisfies
this list as well.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"1ee13cae705f2bf564a18c492bca4f9809245f7e"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Marco Gavazzoni <138492709+marcogavaz@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting backport This PR is a backport of another PR Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants