diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8b2e2460b314..ddb0ad957f1e 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -104,10 +104,10 @@ class Handler extends ExceptionHandler if (Ninja::isHosted()) { - if($exception instanceof ThrottleRequestsException && class_exists(\Modules\Admin\Events\ThrottledExceptionRaised::class)) { - $uri = urldecode(request()->getRequestUri()); + // if($exception instanceof ThrottleRequestsException && class_exists(\Modules\Admin\Events\ThrottledExceptionRaised::class)) { + // $uri = urldecode(request()->getRequestUri()); // event(new \Modules\Admin\Events\ThrottledExceptionRaised(auth()->user()?->account?->key, $uri, request()->ip())); - } + // } Integration::configureScope(function (Scope $scope): void { $name = 'hosted@invoiceninja.com'; diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index 96c86fa61966..454f82347eb8 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -67,9 +67,8 @@ class CompanyExport implements ShouldQueue public function handle() { MultiDB::setDb($this->company->db); - - // $this->company = Company::query()->where('company_key', $this->company->company_key)->first(); - + nlog("starting export"); + set_time_limit(0); $this->export_data['app_version'] = config('ninja.app_version'); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index e73897378eec..2c79b7c67490 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -26,6 +26,7 @@ use App\Utils\Traits\MakesReminders; use Illuminate\Support\Facades\Auth; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; +use Spatie\OpenTelemetry\Jobs\TraceAware; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -37,7 +38,7 @@ class ReminderJob implements ShouldQueue use SerializesModels; use MakesReminders; use MakesDates; - + public $tries = 1; public function __construct() diff --git a/app/Repositories/ClientContactRepository.php b/app/Repositories/ClientContactRepository.php index 4a508fc18964..4434a8a80c8e 100644 --- a/app/Repositories/ClientContactRepository.php +++ b/app/Repositories/ClientContactRepository.php @@ -86,8 +86,8 @@ class ClientContactRepository extends BaseRepository $update_contact->password = Hash::make($contact['password']); ClientContact::withTrashed() - ->where('company_id', $client->id) - ->where('client_id', $client->company_id) + ->where('company_id', $client->company_id) + ->where('client_id', $client->id) ->where('email', $update_contact->email)->cursor() ->each(function ($saveable_contact) use ($update_contact){ $saveable_contact->password = $update_contact->password; diff --git a/app/Services/Invoice/EInvoice/RoEInvoice.php b/app/Services/Invoice/EInvoice/RoEInvoice.php index 65127ea96eca..43691d632d73 100644 --- a/app/Services/Invoice/EInvoice/RoEInvoice.php +++ b/app/Services/Invoice/EInvoice/RoEInvoice.php @@ -368,7 +368,7 @@ class RoEInvoice extends AbstractService public function generateXml(): string { - $ubl_invoice = $this->handle(); // Call the existing handle method to get the UBLInvoice + $ubl_invoice = $this->run(); // Call the existing handle method to get the UBLInvoice $generator = new Generator(); return $generator->invoice($ubl_invoice, $this->invoice->client->getCurrencyCode()); } diff --git a/composer.json b/composer.json index c503a5a5b4b7..c2f34cadfc27 100644 --- a/composer.json +++ b/composer.json @@ -107,17 +107,19 @@ "php": "^8.1|^8.2", "barryvdh/laravel-debugbar": "^3.6", "barryvdh/laravel-ide-helper": "^2.13", + "beyondcode/laravel-query-detector": "^1.8", "brianium/paratest": "^7", "fakerphp/faker": "^1.14", "filp/whoops": "^2.7", "friendsofphp/php-cs-fixer": "^3.14", "laracasts/cypress": "^3.0", + "larastan/larastan": "^2", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", - "larastan/larastan": "^2", "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^10.0", "spatie/laravel-ignition": "^2.0", + "spatie/laravel-open-telemetry": "^0.0.9", "spaze/phpstan-stripe": "^3.0" }, "autoload": { @@ -180,4 +182,4 @@ ], "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 5a6b0f06e414..82bb75f38b56 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a1bebba0b0ac5d8ed26813339eee514c", + "content-hash": "61931b267752ed077ff3f1545b80259b", "packages": [ { "name": "afosto/yaac", @@ -16087,6 +16087,66 @@ }, "time": "2023-06-14T05:06:27+00:00" }, + { + "name": "beyondcode/laravel-query-detector", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/beyondcode/laravel-query-detector.git", + "reference": "722c45c07b96d88abd499c3ed7fd949798bede5a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/beyondcode/laravel-query-detector/zipball/722c45c07b96d88abd499c3ed7fd949798bede5a", + "reference": "722c45c07b96d88abd499c3ed7fd949798bede5a", + "shasum": "" + }, + "require": { + "illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0|^10.0", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "laravel/legacy-factories": "^1.0", + "orchestra/testbench": "^3.0 || ^4.0 || ^5.0 || ^6.0|^8.0", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "BeyondCode\\QueryDetector\\QueryDetectorServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "BeyondCode\\QueryDetector\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marcel Pociot", + "email": "marcel@beyondco.de", + "homepage": "https://beyondcode.de", + "role": "Developer" + } + ], + "description": "Laravel N+1 Query Detector", + "homepage": "https://github.com/beyondcode/laravel-query-detector", + "keywords": [ + "beyondcode", + "laravel-query-detector" + ], + "support": { + "issues": "https://github.com/beyondcode/laravel-query-detector/issues", + "source": "https://github.com/beyondcode/laravel-query-detector/tree/1.8.0" + }, + "time": "2023-11-15T08:04:32+00:00" + }, { "name": "brianium/paratest", "version": "v7.3.1", @@ -17211,6 +17271,274 @@ ], "time": "2023-10-11T15:45:01+00:00" }, + { + "name": "open-telemetry/api", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/api.git", + "reference": "401d04c6afe349afa78250ac862db2f89dbf94f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/401d04c6afe349afa78250ac862db2f89dbf94f6", + "reference": "401d04c6afe349afa78250ac862db2f89dbf94f6", + "shasum": "" + }, + "require": { + "open-telemetry/context": "^1.0", + "php": "^7.4 || ^8.0", + "psr/log": "^1.1|^2.0|^3.0", + "symfony/polyfill-php80": "^1.26", + "symfony/polyfill-php81": "^1.26", + "symfony/polyfill-php82": "^1.26" + }, + "conflict": { + "open-telemetry/sdk": "<=1.0.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "files": [ + "Trace/functions.php" + ], + "psr-4": { + "OpenTelemetry\\API\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "API for OpenTelemetry PHP.", + "keywords": [ + "Metrics", + "api", + "apm", + "logging", + "opentelemetry", + "otel", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-01-10T13:04:59+00:00" + }, + { + "name": "open-telemetry/context", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/context.git", + "reference": "e9d254a7c89885e63fd2fde54e31e81aaaf52b7c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/context/zipball/e9d254a7c89885e63fd2fde54e31e81aaaf52b7c", + "reference": "e9d254a7c89885e63fd2fde54e31e81aaaf52b7c", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "symfony/polyfill-php80": "^1.26", + "symfony/polyfill-php81": "^1.26", + "symfony/polyfill-php82": "^1.26" + }, + "suggest": { + "ext-ffi": "To allow context switching in Fibers" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "files": [ + "fiber/initialize_fiber_handler.php" + ], + "psr-4": { + "OpenTelemetry\\Context\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "Context implementation for OpenTelemetry PHP.", + "keywords": [ + "Context", + "opentelemetry", + "otel" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-01-13T05:50:44+00:00" + }, + { + "name": "open-telemetry/sdk", + "version": "1.0.7", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/sdk.git", + "reference": "818263750d299df5b9612a738440e56d92e5a296" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/818263750d299df5b9612a738440e56d92e5a296", + "reference": "818263750d299df5b9612a738440e56d92e5a296", + "shasum": "" + }, + "require": { + "ext-json": "*", + "open-telemetry/api": "^1.0", + "open-telemetry/context": "^1.0", + "open-telemetry/sem-conv": "^1.0", + "php": "^7.4 || ^8.0", + "php-http/discovery": "^1.14", + "psr/http-client": "^1.0", + "psr/http-client-implementation": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/http-message": "^1.0.1|^2.0", + "psr/log": "^1.1|^2.0|^3.0", + "symfony/polyfill-mbstring": "^1.23", + "symfony/polyfill-php80": "^1.26", + "symfony/polyfill-php81": "^1.26", + "symfony/polyfill-php82": "^1.26" + }, + "suggest": { + "ext-gmp": "To support unlimited number of synchronous metric readers", + "ext-mbstring": "To increase performance of string operations" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "files": [ + "Common/Util/functions.php", + "Logs/Exporter/_register.php", + "Metrics/MetricExporter/_register.php", + "Propagation/_register.php", + "Trace/SpanExporter/_register.php", + "Common/Dev/Compatibility/_load.php", + "_autoload.php" + ], + "psr-4": { + "OpenTelemetry\\SDK\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "SDK for OpenTelemetry PHP.", + "keywords": [ + "Metrics", + "apm", + "logging", + "opentelemetry", + "otel", + "sdk", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-01-24T12:00:22+00:00" + }, + { + "name": "open-telemetry/sem-conv", + "version": "1.24.0", + "source": { + "type": "git", + "url": "https://github.com/opentelemetry-php/sem-conv.git", + "reference": "d03e6501d21c04cd1b1e66e4cbcc7c2dd2e2cfa3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentelemetry-php/sem-conv/zipball/d03e6501d21c04cd1b1e66e4cbcc7c2dd2e2cfa3", + "reference": "d03e6501d21c04cd1b1e66e4cbcc7c2dd2e2cfa3", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "OpenTelemetry\\SemConv\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "opentelemetry-php contributors", + "homepage": "https://github.com/open-telemetry/opentelemetry-php/graphs/contributors" + } + ], + "description": "Semantic conventions for OpenTelemetry PHP.", + "keywords": [ + "Metrics", + "apm", + "logging", + "opentelemetry", + "otel", + "semantic conventions", + "semconv", + "tracing" + ], + "support": { + "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", + "docs": "https://opentelemetry.io/docs/php", + "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", + "source": "https://github.com/open-telemetry/opentelemetry-php" + }, + "time": "2024-01-23T21:47:17+00:00" + }, { "name": "phar-io/manifest", "version": "2.0.3", @@ -19115,6 +19443,86 @@ ], "time": "2024-01-12T13:14:58+00:00" }, + { + "name": "spatie/laravel-open-telemetry", + "version": "0.0.9", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-open-telemetry.git", + "reference": "3785efd133829ae6d1a27cccb99772c2a31295fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-open-telemetry/zipball/3785efd133829ae6d1a27cccb99772c2a31295fa", + "reference": "3785efd133829ae6d1a27cccb99772c2a31295fa", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0", + "illuminate/http": "^10.0", + "open-telemetry/api": "^1.0", + "open-telemetry/sdk": "^1.0", + "php": "^8.1", + "php-http/guzzle7-adapter": "^1.0", + "spatie/laravel-package-tools": "^1.13.8" + }, + "require-dev": { + "laravel/pint": "^1.3", + "nunomaduro/collision": "^7.0", + "nunomaduro/larastan": "^2.3.4", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.0", + "pestphp/pest-plugin-laravel": "^2.0", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.1.1", + "phpstan/phpstan-phpunit": "^1.3.3", + "spatie/laravel-ray": "^1.31", + "spatie/pest-plugin-snapshots": "^2.0", + "spatie/phpunit-snapshot-assertions": "^5.0", + "spatie/test-time": "^1.3", + "spatie/valuestore": "^1.3.2" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\OpenTelemetry\\OpenTelemetryServiceProvider" + ], + "aliases": { + "Measure": "Spatie\\OpenTelemetry\\Facades\\Measure" + } + } + }, + "autoload": { + "psr-4": { + "Spatie\\OpenTelemetry\\": "src", + "Spatie\\OpenTelemetry\\Database\\Factories\\": "database/factories" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Measure performance across jobs and services", + "homepage": "https://github.com/spatie/laravel-open-telemetry", + "keywords": [ + "laravel", + "laravel-open-telemetry", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-open-telemetry/issues", + "source": "https://github.com/spatie/laravel-open-telemetry/tree/0.0.9" + }, + "time": "2024-01-12T12:12:48+00:00" + }, { "name": "spaze/phpstan-stripe", "version": "v3.1.0", @@ -19256,6 +19664,85 @@ ], "time": "2023-01-26T09:26:14+00:00" }, + { + "name": "symfony/polyfill-php82", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php82.git", + "reference": "7716bea9c86776fb3362d6b52fe1fc9471056a49" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/7716bea9c86776fb3362d6b52fe1fc9471056a49", + "reference": "7716bea9c86776fb3362d6b52fe1fc9471056a49", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php82\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php82/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-08-25T17:27:25+00:00" + }, { "name": "symfony/stopwatch", "version": "v6.4.3", diff --git a/config/open-telemetry.php b/config/open-telemetry.php new file mode 100644 index 000000000000..355c0118e819 --- /dev/null +++ b/config/open-telemetry.php @@ -0,0 +1,98 @@ + null, + + /* + * A driver is responsible for transmitting any measurements. + */ + 'drivers' => [ + Spatie\OpenTelemetry\Drivers\HttpDriver::class => [ + 'url' => 'http://localhost:9411/api/v2/spans', + // 'url' => 'http://localhost:4318/v1/traces' + ], + ], + + /* + * This class determines if your measurements should actually be sent + * to the reporting drivers. + */ + 'sampler' => Spatie\OpenTelemetry\Support\Samplers\AlwaysSampler::class, + + /* + * Tags can be added to any measurement. These classes will determine the + * values of the tags when a new trace starts. + */ + 'trace_tag_providers' => [ + \Spatie\OpenTelemetry\Support\TagProviders\DefaultTagsProvider::class, + ], + + /* + * Tags can be added to any measurement. These classes will determine the + * values of the tags when a new span starts. + */ + 'span_tag_providers' => [ + + ], + + 'queue' => [ + /* + * When enabled, any measurements (spans) you make in a queued job that implements + * `TraceAware` will automatically belong to the same trace that was + * started in the process that dispatched the job. + */ + 'make_queue_trace_aware' => true, + + /* + * When this is set to `false`, only jobs the implement + * `TraceAware` will be trace aware. + */ + 'all_jobs_are_trace_aware_by_default' => true, + + /* + * When set to `true` all jobs will + * automatically start a span. + */ + 'all_jobs_auto_start_a_span' => true, + + /* + * These jobs will be trace aware even if they don't + * implement the `TraceAware` interface. + */ + 'trace_aware_jobs' => [ + + ], + + /* + * These jobs will never trace aware, regardless of `all_jobs_are_trace_aware_by_default`. + */ + 'not_trace_aware_jobs' => [ + + ], + ], + + /* + * These actions can be overridden to have fine-grained control over how + * the package performs certain tasks. + * + * In most cases, you should use the default values. + */ + 'actions' => [ + 'make_queue_trace_aware' => Spatie\OpenTelemetry\Actions\MakeQueueTraceAwareAction::class, + ], + + /* + * This class determines how the package measures time. + */ + 'stopwatch' => Spatie\OpenTelemetry\Support\Stopwatch::class, + + /* + * This class generates IDs for traces and spans. + */ + 'id_generator' => Spatie\OpenTelemetry\Support\IdGenerator::class, +];