@@ -126,13 +126,31 @@ app.UseTreblle();
126126```
127127
128128``` csharp
129+ // Import the Treblle SDK
130+ using Treblle .Net .Core ;
131+
132+ // Register Treblle Services
129133builder .Services .AddTreblle ();
134+
135+ // Build your application
136+ var app = builder .Build ();
137+
138+ // Enable the Treblle Middleware
130139app .UseTreblle ();
131140```
132141
133142** Option C: Manual Configuration**
134143``` csharp
144+ // Import the Treblle SDK
145+ using Treblle .Net .Core ;
146+
147+ // Register Treblle Services
135148builder .Services .AddTreblle (" your_sdk_token" , " your_api_key" );
149+
150+ // Build your application
151+ var app = builder .Build ();
152+
153+ // Enable the Treblle Middleware
136154app .UseTreblle ();
137155```
138156
@@ -148,21 +166,33 @@ Treblle offers several configuration options:
148166| ` DebugMode ` | ` false ` | Enable detailed logging for troubleshooting |
149167| ` DisableMasking ` | ` false ` | Disable data masking if not needed |
150168
151- ** Example with options:**
169+ ** Example with all options:**
152170``` csharp
171+ // Import the Treblle SDK
172+ using Treblle .Net .Core ;
173+
153174builder .Services .AddTreblle (options =>
154175{
155176 options .ExcludedPaths = new [] { " /health" , " /admin/*" , " /swagger/*" };
156177 options .DebugMode = true ;
157178 options .DisableMasking = false ;
158179});
180+
181+ // Build your application
182+ var app = builder .Build ();
183+
184+ // Enable the Treblle Middleware
185+ app .UseTreblle ();
159186```
160187
161188### Debug Mode
162189
163190For troubleshooting and development purposes, you can enable debug mode to get detailed logging about Treblle SDK operations:
164191
165192``` csharp
193+ // Import the Treblle SDK
194+ using Treblle .Net .Core ;
195+
166196// Option 1: Via AddTreblle parameter
167197builder .Services .AddTreblle (" YOUR_SDK_TOKEN" , " YOUR_API_KEY" , null , disableMasking : false , debugMode : true );
168198
@@ -178,6 +208,12 @@ builder.Services.AddTreblle(options =>
178208{
179209 options .DebugMode = true ;
180210});
211+
212+ // Build your application
213+ var app = builder .Build ();
214+
215+ // Enable the Treblle Middleware
216+ app .UseTreblle ();
181217```
182218
183219** Debug Information Provided:**
@@ -211,11 +247,20 @@ By default, Treblle now automatically tracks **all endpoints** without requiring
211247
212248** Configuration:**
213249``` csharp
250+ // Import the Treblle SDK
251+ using Treblle .Net .Core ;
252+
214253// Track all endpoints except specified exclusions
215254builder .Services .AddTreblle (" YOUR_SDK_TOKEN" , " YOUR_API_KEY" , options =>
216255{
217256 options .ExcludedPaths = new [] { " /health" , " /metrics" , " /admin/*" };
218257});
258+
259+ // Build your application
260+ var app = builder .Build ();
261+
262+ // Enable the Treblle Middleware
263+ app .UseTreblle ();
219264```
220265
221266** Advanced Exclusion Patterns:**
@@ -283,11 +328,20 @@ Treblle automatically masks sensitive fields in request and response bodies. The
283328If you want to expand the list of fields you want to hide, you can pass a list of property names you want to hide and appropriate maskers to use as a key-value pairs to the ` AddTreblle ` call:
284329
285330``` csharp
331+ // Import the Treblle SDK
332+ using Treblle .Net .Core ;
333+
286334builder .Services .AddTreblle (
287335 builder .Configuration [" Treblle:SdkToken" ],
288336 builder .Configuration [" Treblle:ApiKey" ],
289337 new Dictionary <string , string >( { { " customercreditCard" , " CreditCardMasker" }, { " firstName" , " DefaultStringMasker" } });
290338);
339+
340+ // Build your application
341+ var app = builder .Build ();
342+
343+ // Enable the Treblle Middleware
344+ app .UseTreblle ();
291345```
292346
293347Available Maskers:
@@ -315,6 +369,9 @@ By extending DefaultStringMasker class and implementing IStringMasker interface
315369For high-volume scenarios where data masking is not required, you can disable it entirely to significantly improve performance and reduce memory usage:
316370
317371``` csharp
372+ // Import the Treblle SDK
373+ using Treblle .Net .Core ;
374+
318375// Option 1: Via AddTreblle parameter
319376builder .Services .AddTreblle (" YOUR_SDK_TOKEN" , " YOUR_API_KEY" , null , disableMasking : true );
320377
@@ -330,24 +387,27 @@ builder.Services.AddTreblle(options =>
330387{
331388 options .DisableMasking = true ;
332389});
390+
391+ // Build your application
392+ var app = builder .Build ();
393+
394+ // Enable the Treblle Middleware
395+ app .UseTreblle ();
333396```
334397
335398** Performance Impact:** Disabling masking can reduce memory usage by up to 70% for large payloads, as it skips JSON parsing, object tree creation, and field processing operations. This is particularly beneficial for APIs handling large response bodies or high request volumes.
336399
337- ## Upgrading to v2.0 🚀
400+ ## Upgrading to v2.0
338401
339402Treblle .NET Core v2.0 introduces major improvements with ** breaking changes** . This guide will help you migrate from v1.x.
340403
341- ### 🔥 Major New Features
342-
343404- ✅ ** Zero-Configuration Auto-Discovery** - No more manual ` [Treblle] ` attributes required
344405- ✅ ** Auto-Configuration** - Automatic credential detection from environment/config
345406- ✅ ** Smart Path Exclusions** - Wildcard patterns like ` /admin/* ` , ` /api/v*/internal `
346407- ✅ ** Enhanced Debug Mode** - Comprehensive logging for troubleshooting
347408- ✅ ** Performance Optimizations** - Cached pattern matching, memory improvements
348409- ✅ ** Cleaner API** - Removed legacy/deprecated properties
349410
350-
351411### 📋 Migration Guide
352412
353413#### ** Step 1: Update Package Reference**
@@ -356,50 +416,31 @@ Treblle .NET Core v2.0 introduces major improvements with **breaking changes**.
356416<PackageReference Include =" Treblle.Net.Core" Version =" 2.0.0" />
357417```
358418
359- #### ** Step 2: Choose Your Migration Path **
419+ #### ** Step 2: Update SDK Initialization **
360420
361- ** Option A: Zero-Configuration (Recommended)**
362421``` csharp
363- // ❌ v1.x - Manual configuration
422+ // ❌ v1.x
364423builder .Services .AddTreblle (
365424 builder .Configuration [" Treblle:ApiKey" ],
366425 builder .Configuration [" Treblle:ProjectId" ]);
367426
368- // ✅ v2.0 - Auto-configuration
369- builder .Services .AddTreblle (); // That's it! Auto-detects from env/config
427+ // ✅ v2.0
428+ builder .Services .AddTreblle ();
370429```
371430
372- ** Option B: Manual Configuration**
373- ``` csharp
374- // ❌ v1.x
375- builder .Services .AddTreblle (" old-api-key" , " old-project-id" );
376-
377- // ✅ v2.0 - Same values, clearer parameter names
378- builder .Services .AddTreblle (" your-sdk-token" , " your-api-key" );
379- ```
380-
381- ** Option C: Advanced Configuration**
382- ``` csharp
383- // ✅ v2.0 - New powerful configuration options
384- builder .Services .AddTreblle (options =>
385- {
386- options .ExcludedPaths = new [] { " /health" , " /admin/*" };
387- options .DebugMode = true ;
388- });
389- ```
390-
391- #### ** Step 3: Update Configuration Sources**
392-
393- Choose one of these approaches:
394-
395- ** Environment Variables (Production Recommended):**
396- ``` bash
397- export TREBLLE_SDK_TOKEN=your_sdk_token
398- export TREBLLE_API_KEY=your_api_key
399- ```
431+ #### ** Step 3: Update Naming Conventions**
400432
401433** appsettings.json:**
402434``` json
435+ // ❌ v1.x
436+ {
437+ "Treblle" : {
438+ "ApiKey" : " your_api_key" ,
439+ "ProjectId" : " your_project_id"
440+ }
441+ }
442+
443+ // ✅ v2.0
403444{
404445 "Treblle" : {
405446 "SdkToken" : " your_sdk_token" ,
@@ -408,42 +449,21 @@ export TREBLLE_API_KEY=your_api_key
408449}
409450```
410451
411- ** Manual Configuration:**
412- ``` csharp
413- builder .Services .AddTreblle (" your_sdk_token" , " your_api_key" );
414- ```
415-
416- #### ** Step 4: Remove Manual Attributes (Optional)**
452+ #### ** Step 4: Remove Manual Attributes**
417453``` csharp
418- // ❌ v1.x - Manual attributes required
454+ // ❌ v1.x
419455 [Treblle ]
420456public class ProductsController : ControllerBase
421457{
422458 [Treblle ]
423459 public IActionResult GetProducts () => Ok ();
424460}
425461
426- // ✅ v2.0 - Auto-discovery (attributes optional)
462+ // ✅ v2.0
427463public class ProductsController : ControllerBase
428464{
429- public IActionResult GetProducts () => Ok (); // Automatically tracked!
465+ public IActionResult GetProducts () => Ok ();
430466}
431-
432- // Or exclude specific paths
433- builder .Services .AddTreblle (options =>
434- {
435- options .ExcludedPaths = new [] { " /health" , " /internal/*" };
436- });
437- ```
438-
439- #### ** Step 5: Test Your Migration**
440-
441- Enable debug mode to verify everything works:
442- ``` csharp
443- builder .Services .AddTreblle (options =>
444- {
445- options .DebugMode = true ; // See what's being tracked
446- });
447467```
448468
449469## Disabling Default .NET HTTP logging
0 commit comments