An open API service indexing awesome lists of open source software.

https://github.com/telexintegrations/telexapm-for-dotnet

🌟 Telex APM – Global Error Tracking & Performance Monitoring for .NET. Lightweight APM SDK for .NET applications (ASP.NET Core & standalone C#). Tracks errors & performance automatically. πŸš€
https://github.com/telexintegrations/telexapm-for-dotnet

Last synced: over 1 year ago
JSON representation

🌟 Telex APM – Global Error Tracking & Performance Monitoring for .NET. Lightweight APM SDK for .NET applications (ASP.NET Core & standalone C#). Tracks errors & performance automatically. πŸš€

Awesome Lists containing this project

README

          

# TelexAPM SDK for c#(dotnet)

## Overview

🌟 Telex APM – Global Error Tracking & Performance Monitoring for .NET. Lightweight APM SDK for .NET applications (ASP.NET Core & standalone C#). Tracks errors & performance automatically. πŸš€

## Features

- πŸ“š Global Error Tracker/Reporting to Telex Channel
- βœ… Performance Tracker/Reporting to Telex Channel
- πŸ§ͺ Unit test coverage
- πŸ“ SDK documentation
- 🌎 ASP.NET Core Extensions and Middleware (Supports Dependency Injection)

## Project Structure

```
telexapm-for-dotnet/
β”œβ”€β”€ TelexAPM/
β”‚ β”œβ”€β”€ Extensions/ #ASP.NET Core Extensions
β”‚ β”‚ β”œβ”€β”€ AddTelex.cs #Service Registration for containers - DI injections
β”‚ β”‚ β”œβ”€β”€ AspNetCoreExtensions.cs #Configure to UseTelex middleware
β”‚ β”‚ └──TelexMiddleware.cs
β”‚ β”‚
β”‚ β”œβ”€β”€ Models/ #Models for Data to be sent
β”‚ β”‚ β”œβ”€β”€ ErrorReport.cs
β”‚ β”‚ β”œβ”€β”€ PerformanceReport.cs
β”‚ β”‚ β”œβ”€β”€ SuccessReport.cs
β”‚ β”‚ └── WebhookPayload.cs
β”‚ β”‚
β”‚ β”œβ”€β”€ Services/ #MTelex APM Core Services
β”‚ β”‚ β”œβ”€β”€ BaseTracker.cs #Internal - Clients should not access this directly
β”‚ β”‚ β”œβ”€β”€ ErrorTracker.cs #Internal - Clients should not access this directly
β”‚ β”‚ β”œβ”€β”€ PerformanceTracker.cs #Internal - Clients should not access this directly
β”‚ β”‚ └── TelexClient.cs #Public API - Accessible to Clients
| |
| β”œβ”€β”€ TelexAPM.ConsoleTest/ #Models for Data to be sent
β”‚ β”‚ β”œβ”€β”€ appsettings.json
β”‚ β”‚ β”œβ”€β”€ Program.cs
β”‚ β”‚ └── TelexApm.ConsoleTest.csproj
β”‚ β”œβ”€β”€ TelexAPM.csproj
β”‚
β”œβ”€β”€ TelexAPM.Tests/
β”‚ β”œβ”€β”€ TelexMiddlewareTest.cs # API endpoint tests
β”‚ └── TelexAPM.Test.csproj
β”œβ”€β”€ telexAPM-for-dotnet.sln # telexAPM-for-dotnet.sln
└── README.md
```

## Technologies Used

- C#
- ASP.NET Core
- XUnit

## Installation

### Step 1: Add TelexAPM Reference to Your Project

Since Telex is currently in build mode - this SDK is not yet published to NuGet, you'll need to reference it directly from GitHub in your project file.

```bash
git clone https://github.com/telexintegrations/telexAPM-for-dotnet.git
cd telexAPM-for-dotnet
```

### Step 2: Reference TelexAPM in Your Project

-Add a reference to TelexAPM in your project file:
Project Reference (preferred during development)
In your .csproj file, add:

```xml

```

You can check the csproj file in the TelexAPM.ConsoleTest Directory

### Step 3: Configure TelexAPM

Configuration in appsettings.json
Add the following section to your appsettings.json file:

```json
{
"Telex": {
"BaseUrl": "ping.telex.im/v1/webhooks", #this must be telex base-url for channels
"ChannelHookId": "YOUR_CHANNEL_HOOK_ID"
}
}
```

- Usage
- Console Applications

```cs
using TelexAPM.Services;
using Microsoft.Extensions.Configuration;

class Program
{
static async Task Main(string[] args)
{
// Config builder - setting appsettings as config file
var Config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();

TelexConfiguration telexConfig = GetTelexConfig(Config);
await Test(telexConfig);
}

public static async Task Test(TelexConfiguration telexConfig)
{
TelexClient telex = new(telexConfig);
var x = new Exception("Console Test Telex Error");
await telex.TrackErrorAsync(x);
Console.WriteLine("test done");
}

public static TelexConfiguration GetTelexConfig(IConfigurationRoot config)
{
TelexConfiguration telexConfig = new()
{
BaseUrl = config["Telex:BaseUrl"],
ChannelHookId = config["Telex:ChannelHookId"],
};
return telexConfig;
}
}
```

- Usage
- ASP.NET cORE applications:
Step 1: Register TelexAPM Services
In your Program.cs or Startup.cs, add TelexAPM services:

```cs
using TelexApm.Extensions;

// ...
services.AddTelex(Configuration); // Dependency Container
```

Step 2: Use TelexAPM Middleware
Add the TelexAPM middleware to your application pipeline:

```cs
using TelexAPM.Extensions;

// ...

app.UseTelex();
```

## API Reference

### TelexClient

The main client for interacting with TelexAPM.

```cs
// Create a new TelexClient
TelexClient telex = new(telexConfig);

// Track an error
await telex.TrackErrorAsync(exception);

// Track performance
await telex.TrackPerformanceAsync("Operation Name", timeSpan);
```

### TelexConfiguration

| Property | Description |
| --------------- | ---------------------------------------- |
| `BaseUrl` | The base URL of the Telex service |
| `ChannelHookId` | The channel hook ID for your application |

## Test Integration (HNG Mentors)

To test the integration, follow these steps:

### 1. Navigate to the Console Test Folder
Open a terminal and change the directory to the `TelexAPM.ConsoleTest` folder:

```sh
cd TelexAPM/TelexAPM.ConsoleTest
```

### 2. Create the `appsettings.json` File

Inside the `TelexAPM.ConsoleTest` folder, create a file named `appsettings.json` and add the following content:

Run the following command in your terminal to create and edit the file:
```sh
nano appsettings.json
```
Then, paste the following JSON configuration:
```json
{
"Telex": {
"BaseUrl": "ping.telex.im/v1/webhooks", #this must be telex base-url for channels
"ChannelHookId": "YOUR_CHANNEL_HOOK_ID"
}
}
```
Replace "YOUR_CHANNEL_HOOK_ID" with the actual channel hook ID.

### 3. Run the Application

Once the `appsettings.json` file is in place, execute the following command to run the console test:

```sh
dotnet run
```

## Telex Integration/Channel Configuration

TelexAPM includes extensions for easy integration with ASP.NET Core applications and Standalone applications

The APM automatically tracks request performance and catches unhandled exceptions and report/sends to your Telex Channel

## πŸ“Έ Screenshots

### Test Code
![Test Code](https://dotnet-apm.onrender.com/IMG_2897.jpeg)

### Message Screenshot In Telex
![Telex Screenshot](https://dotnet-apm.onrender.com/IMG_2895.jpeg)

## πŸš€ Telex Dotnet APM Integration Guide

Follow these steps to configure your Telex channel to use the Dotnet APM:
This assumes you have an organisation and channel created!

---

### πŸ› οΈ Step 1: Install the Dotnet APM Application

- Go to your **Telex dashboard**.
- Install the **Dotnet APM** application:
- The application url: https://dotnet-apm.onrender.com
- The application integration json url: https://dotnet-apm.onrender.com/integration.json
- The application target url: https://dotnet-apm.onrender.com/target_url (This url will be called by telex)

---

### βš™οΈ Step 2: Update the Webhook URL

- After installation, update the `webhookUrl` in the application settings to your **output webhook** (where you want Telex to send your messages).

---

### πŸ”§ Step 3: Activate/Configure Your Channel

- Activate and configure your channel to use the **Dotnet APM**.

---

### πŸŽ‰ Step 4: You're Done!

- **Voila!** πŸš€ Your Telex APM setup is now complete.

## Additional Resources

- πŸ“š [TelexAPM Documentation](https://docs.telex.im/docs)
- πŸ“– [.NET Configuration Documentation](https://dotnet.microsoft.com/en-us/apps/aspnet)

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit changes (`git commit -m 'Add AmazingFeature'`)
4. Push to branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

For support, please open an issue in the GitHub repository.