Decorator Design Pattern:

Adding Telemetry to HttpClient

This website demonstrates how to use the decorator design pattern to add telemetry to an HttpClient.

Read the Post
Decorator Design Pattern: Adding Telemetry to HttpClient
GitHub Repository
The source code for this project is available on GitHub: markhazleton/HttpClientDecoratorPattern
Hosted Application
httpclientdecorator.azurewebsites.net/ (Azure App Service)

The Decorator Pattern is a design pattern that allows developers to add additional functionality to existing classes/objects without modifying the existing class/object.

This repository demonstrates how to use the decorator design pattern to add telemetry to an HttpClient in C#. By the end of this demonstration, you will have a good understanding of the decorator pattern and how to use it to add telemetry to an HttpClient.

By using the Decorator Pattern, developers can add additional properties and methods to the existing HttpClient class to add telemetry data to the request. This allows for easy tracking of requests and their associated data, such as request time, response time, and response size. By using the Decorator Pattern, the original HttpClient class remains unchanged, and the telemetry data is added through a “wrapper” or “decorator” class. This makes the code more maintainable, as the changes are isolated to the decorator class, while the original HttpClient class remains unchanged.