Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Translate otel metrics to libbeat monitoring (backport #15094) #15440

Merged
merged 4 commits into from
Jan 31, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jan 28, 2025

Motivation/summary

use otel api to record metrics and export them to beats monitoring

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

  • run apm-server
  • send data
  • go to index management and validate the monitoring index is there and monitoring data is inside it

Related issues

Related to #14488


This is an automatic backport of pull request #15094 done by [Mergify](https://mergify.com).

* Translate otel metrics to libbeat monitoring

* demo: send metrics directly and add another reader

* Revert "demo: send metrics directly and add another reader"

This reverts commit 166a717.

* lint: fix linter issues

* lint: fix linter issues

* feat: refactor code to propagate meterprovider and fix tests

* lint: fix linter issues

* refactor: remove unused files

* refactor: remove more global meters

* refactor: cleanup more unused code

* refactor: remove more unused code

* test: account for agentcfg metric in test

* test: account for agentcfg metric in test

* fix: pass meter provider in main func

* Fix LSM metrics tests

* test: fix remaining test

* lint: fix linter issues

* fix: update docappender metrics name

* test: update systemtest metric assertions

* fix: update grpc interceptor meter path

metrics were not being exported because the meter was not recognized
as apm-server meter

* fix: add back output.type=elasticsearch

* test: upate remaining systemtest

* test: remove debug print

* fix: use correct outputRegistry variable

fix panic

* fix: remove panic on err

* fix: propagate meter provider to grpc services

* lint: add meterprovider field docs

* lint: fix comment typo

* feat: pass apmotel gatherer too

* refactor: use switch pattern consistently when mapping metrics

* Update beater.go

* Update beat.go

* Update beater.go

* fix: solve compile errors and systemtest fix

* refactor: reduce diff noise

* lint: fix linter issues

* lint: fix linter issues

* Update x-pack/apm-server/main.go

Co-authored-by: Andrew Wilkins <[email protected]>

* test: use legacy metrics for validating grpc tests

* fix: unregister callback if available

forgot to pus this

---------

Co-authored-by: Andrew Wilkins <[email protected]>
Co-authored-by: Andrew Wilkins <[email protected]>
(cherry picked from commit 378b60c)

# Conflicts:
#	internal/beatcmd/beat.go
#	internal/beater/beater.go
#	internal/beater/server.go
#	internal/beater/server_test.go
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Jan 28, 2025
@mergify mergify bot requested a review from a team as a code owner January 28, 2025 18:48
Copy link
Contributor Author

mergify bot commented Jan 28, 2025

Cherry-pick of 378b60c has failed:

On branch mergify/bp/8.x/pr-15094
Your branch is up to date with 'origin/8.x'.

You are currently cherry-picking commit 378b60c2.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   internal/agentcfg/elasticsearch.go
	modified:   internal/agentcfg/elasticsearch_test.go
	modified:   internal/beatcmd/reloader.go
	modified:   internal/beater/api/config/agent/handler.go
	modified:   internal/beater/api/intake/handler.go
	modified:   internal/beater/api/intake/handler_test.go
	modified:   internal/beater/api/mux.go
	modified:   internal/beater/api/mux_config_agent_test.go
	modified:   internal/beater/api/mux_intake_backend_test.go
	modified:   internal/beater/api/mux_intake_rum_test.go
	modified:   internal/beater/api/mux_root_test.go
	modified:   internal/beater/api/mux_test.go
	modified:   internal/beater/api/root/handler.go
	modified:   internal/beater/interceptors/metrics.go
	modified:   internal/beater/interceptors/metrics_test.go
	modified:   internal/beater/middleware/monitoring_middleware.go
	modified:   internal/beater/middleware/monitoring_middleware_test.go
	deleted:    internal/beater/monitoringtest/monitoring.go
	modified:   internal/beater/monitoringtest/opentelemetry.go
	deleted:    internal/beater/otlp/common.go
	modified:   internal/beater/otlp/grpc.go
	modified:   internal/beater/otlp/grpc_test.go
	modified:   internal/beater/otlp/http.go
	modified:   internal/beater/otlp/http_test.go
	modified:   internal/beater/request/result.go
	modified:   internal/beater/request/result_test.go
	modified:   internal/beater/tracing.go
	modified:   internal/model/modelprocessor/eventcounter.go
	modified:   internal/model/modelprocessor/eventcounter_test.go
	deleted:    internal/processor/stream/result.go
	deleted:    internal/processor/stream/result_test.go
	modified:   systemtest/otlp_test.go
	modified:   x-pack/apm-server/main.go
	modified:   x-pack/apm-server/main_test.go
	modified:   x-pack/apm-server/sampling/config.go
	modified:   x-pack/apm-server/sampling/groups.go
	modified:   x-pack/apm-server/sampling/groups_test.go
	modified:   x-pack/apm-server/sampling/processor.go
	modified:   x-pack/apm-server/sampling/processor_bench_test.go
	modified:   x-pack/apm-server/sampling/processor_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/beatcmd/beat.go
	both modified:   internal/beater/beater.go
	both modified:   internal/beater/server.go
	both modified:   internal/beater/server_test.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@carsonip
Copy link
Member

carsonip commented Jan 29, 2025

@kruskall why is this closed? Is it because we do not intend to backport this to 8.x?

@kruskall kruskall deleted the mergify/bp/8.x/pr-15094 branch January 31, 2025 14:33
@kruskall kruskall restored the mergify/bp/8.x/pr-15094 branch January 31, 2025 14:33
@kruskall kruskall reopened this Jan 31, 2025
@kruskall kruskall closed this Jan 31, 2025
@kruskall kruskall deleted the mergify/bp/8.x/pr-15094 branch January 31, 2025 14:33
@kruskall kruskall restored the mergify/bp/8.x/pr-15094 branch January 31, 2025 14:36
@kruskall kruskall reopened this Jan 31, 2025
Copy link
Contributor Author

mergify bot commented Jan 31, 2025

This pull request is now in conflicts. Could you fix it @mergify[bot]? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mergify/bp/8.x/pr-15094 upstream/mergify/bp/8.x/pr-15094
git merge upstream/8.x
git push upstream mergify/bp/8.x/pr-15094

@kruskall kruskall removed the conflicts There is a conflict in the backported pull request label Jan 31, 2025
@mergify mergify bot merged commit fb729b8 into 8.x Jan 31, 2025
14 checks passed
@mergify mergify bot deleted the mergify/bp/8.x/pr-15094 branch January 31, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants