elastic / elastic/apm-agent-php

Agent public API entry point class not found when APM disabled

Open
#542 0 comments 6 reactions 0 assignees View on GitHub
agent-php bug priority: low triaged
Dominant language
PHP
Stars
268
Forks
86
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I'm getting error `Class "Elastic\Apm\ElasticApm" not found` if APM is disabled and I want access current transaction. When I enable APM (by setting `ELASTIC_APM_ENABLED: 'true'`), everything works as expected.

**Versions**
- PHP 8.0.9
- apm-agent-php_1.2_all.deb
- Debian Buster

**To Reproduce**
Steps to reproduce the behavior:
1. Use this config (configured in docker compose file by env variables)
```
ELASTIC_APM_ENABLED: 'false'
ELASTIC_APM_ENVIRONMENT: test
ELASTIC_APM_SERVER_URL: ...
ELASTIC_APM_SECRET_TOKEN: ...
ELASTIC_APM_SERVICE_NAME: test
```
2. Then call `\Elastic\Apm\ElasticApm::getCurrentTransaction();`
4. See error

**Expected behavior**
Imho `null` or better `NoopTransaction` should be returned and no error should occur.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.