CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other
Showing posts with label Packages. Show all posts
Showing posts with label Packages. Show all posts

29 March, 2023

Pest Architecture Plugin

 Programing Coderfunda     March 29, 2023     Laravel, Packages     No comments   

 With the release of PestPHP v2, we can now test the architecture of our applications. In this tutorial, we will walk through how to use this plugin.

It starts with creating an ArchTest.php file under tests/Feature in our application. From here, we can begin documenting our architectural requirements and rules - allowing us to test these with a great API and fantastic developer experience.

One test I recommend adding to your tests will ensure no stray debugging calls are left in our application.

test('Not debugging statements are left in our code.')
->expect(['dd', 'dump', 'ray'])
->not->toBeUsed();

Before we go too deeply into the available rules we could use, let's analyze the structure of these tests. It starts with a test call, where we define the name of the test - make sure this is something understandable that describes what you are testing for. We then use Pest higher-order expectations API to declare what we are testing. We start by expecting something. In the above case, we expect none of the following to be used, or we could expect something to appear.

Next, let's look at more specific tests we can create to ensure our architectural rules are followed. Obviously, the first thing we need to do is ensure we understand what our architectural practices are. You can't simply implement rules you don't intend to follow. During this tutorial, I will document some rules I like to apply to my projects. Being an un-opinionated developer as I am.

test('Our API controllers return responses that we expect')
->expect('Illuminate\Contracts\Support\Http\Responsable')
->toBeUsedIn('App\Http\Controllers\Api');

In this test, we want to ensure that we use Response classes in our API. Our Controllers should return Responsable classes so that we minimize code duplication and always return in a standard way.

test('We do not directly use Eloquent Models in our APIs.')
->expect('App\Models')
->not->toBeUsedIn('App\Http\Controllers\Api');

In this test, we want to ensure that we do not directly use Eloquent models in our API. We should use Action, Command, Query, or Service/Repository classes when working with the database. This is a rule I like to follow as much as possible as, again, it reduces code duplication.

test('We always use Resouce classes when responding')
->expect('App\Http\Resources')
->toBeUsedIn('App\Http\Controllers\Api');

In this test, we want to ensure we always use Resource classes in our controllers. This allows us to ensure that we have a standardized way to return data from the API.

The following rules will be more specific to how I code, so it may not be relevant to you - but it shows particular ways you can test the modular aspects of your code.

I lean heavily on my modular approach to Laravel, using separate namespaces where I need them. I also lean heavily on Commands for write actions and Queries for read actions. I can ensure that these are used where it makes sense to me.

test('We use Query classes where we need them in the Catalog domain')
->expect('Domains\Catalog\Queries')
->toBeUsedIn('App\Http\Controllers\Api\V1\Products\Read');

This is currently something that I would use as a temporary measure until the architecture plugin supports wildcards. We want to make sure that We are using queries in the right place. As soon as we allow wildcards in the architecture plugin, we can do something like this:

test('Query classes are used for read operations')
->expect('Domains\*\Queries')
->toBeUsedIn('App\Http\Controllers\Api\*\*\IndexController')
->toBeUsedIn('App\Http\Controllers\Api\*\*\ShowController')
->not->toBeUsedIn('App\Http\Controllers\Api\*\*\StoreController')
->not->toBeUsedIn('App\Http\Controllers\Api\*\*\UpdateController')
->not->toBeUsedIn('App\Http\Controllers\Api\*\*\DeleteController');

With this test, we can ensure that we are using queries in all of our read endpoints but not the write endpoints, allowing us to keep a tighter grip on our code architecture and approach.

Of course, this is not available right now, but perhaps it will allow us to have fewer architectural rules and the same amount of coverage in the future.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

27 March, 2023

How to choose between APM and an end-to-end monitoring tool

 Programing Coderfunda     March 27, 2023     Laravel, Packages     No comments   

 There was a time when APM was all anyone needed. Older monolithic web services were monitored with application performance monitoring (APM) tools. These tools provide detailed insights into how the web service performs and can alert administrators to potential issues before they become widespread. So APM brought us out of the era of having your users be the first people who noticed a serious problem. Instead, our monitoring tools could tell us trouble was brewing beforehand.

APM tools give insights into key performance indicators such as response time, request volume, error rates, resource utilization, and more. This data can be used to identify problems in code execution, detect memory leaks, or any other issue that may be affecting the web service's performance.

And many teams are still using traditional application monitoring and are very satisfied with the results!

But here are some questions to ask about tools like Scout APM:

1. Are we committed to open standards?

By using open standards, operations engineers can save time and resources by avoiding the need to develop complex proprietary workarounds or bespoke protocols for their systems. Furthermore, open standards provide a well-defined framework within which engineering teams can collaborate on developing better operational processes and systems across multiple organizations or departments within one organization. Standard APM tools transmit data in their own protocols, and the more you have to learn about them the more you're gaining specialized vendor experience rather than open standards. This leads us to the second concern:

2. Are we locked into one vendor?

The recent incident involving DataDog's attempt to quash an OpenTelemetry commit brought up a significant concern about APM vendors. When these vendors claim to 'embrace' open standards, are they really saying we'll consume whatever data you want to send us, you just can't take your data anywhere else.'

These policies remind us a bit of the bad old days of SaaS where removing your data from a CRM or office tool was nearly impossible. How have APM companies gotten away with this for so long? Probably because portability, in this case, isn't really about portability of historical data. Think about it: when migrating monitoring to another service it probably doesn't matter if you bring with you performance data from 2017.

So lock in, in this case, isn't so much about your data being held hostage, and more about the sometimes extreme difficulty of moving to different services.

If you're using an APM tool you really have to agree that you're going to stick with a single tool for a very long time, maybe for years.

3. How monolithic is our architecture?

While APM works well in a monolithic environment, and fine if you have 12 or so different services running, once you go much beyond that you're going to struggle. See 'Your Architecture defines your destiny' later in this piece

4. How much flexibility and customization do you need?

One of the original selling points of APM was a great 'out of the box' experience. When installing Scout APM on a Rails application, you get a great map of your tool within a few hours. But with any APM tool that 'out of the box' experience can start to feel like you're 'boxed in.'

After all, monitoring can do a lot more than finding performance problems. Maybe you'd like to do some security scanning, compliance checks, or gather business intelligence. With a closed source APM tool you'll largely be limited to the uses that the creators of the tool predicted.

With Open Telemetry, most especially with the use of the OpenTelemetry Collector, you can send, format, and view data from your services, no matter what your use case.

Your Architecture defines your destiny

Selecting TelemetryHub (and the underlying OpenTelemetry project that TelemetryHub is built for) is a lot easier if you have a large number of microservices. How many is a large number? By the time you have dozens of microservices, on a multiple of the number of developers on your team, it's time to think about OpenTelemetry.

OpenTelemetryallows us to instrument, monitor, and debug large numbers of microservices in an efficient manner. This is especially important in a distributed system with a large number of services that are communicating with each other. With OpenTelemetry, we can quickly diagnose issues across the services and detect performance bottlenecks. And with TelemetryHub, you can easily view and share the distributed traces that will show you how requests are traveling across your application.

Here's a table of key differences between Scout APM and TelemetryHub

Scout APM

TelemetryHub

Detailed tracing at a rate of 10 per min

Unlimited distributed tracing

Limited to back end monitoring

End to end monitoring (language agnostic) with added insight into your front-end code

Agent instrumentation that covers several of the top backend frameworks

Vendor agnostic, OpenTelemetry projects cover dozens of languages and frameworks

Tail based sampling with probability sampling
For efficient, compact footprint data

Advanced filtering that lets you send data you want to see, and filter noise

Error monitoring integrations

Error monitoring consolidation, with all errors standardized with OpenTelemetry

Limited Kubernetes monitoring (only what’s running inside the container

Deep understanding of Kubernetes with the OpenTelemetry K8s project

Custom context is limited, and specific to each agent

Search by custom attributes, and add as many as you like with the OpenTelemetry standards

Links to your log mgmt tool

Correlated Metrics & logs

Developed and maintained by the Scout team you love

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Older Posts Home

Meta

Popular Posts

  • Sitaare Zameen Par Full Movie Review
     Here’s a  complete Vue.js tutorial for beginners to master level , structured in a progressive and simple way. It covers all essential topi...
  • C++ in Hindi Introduction
    C ++ का परिचय C ++ एक ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग लैंग्वेज है। C ++ को Bjarne Stroustrup द्वारा विकसित किया गया था। C ++ में आने से पह...
  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • iOS 17 Force Screen Rotation not working on iPAD only
    I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devic...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (69)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • July (4)
  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda