Fix analyzer issues in docs (#3026)

This commit is contained in:
Travis Illig 2022-03-11 18:04:34 -08:00 committed by GitHub
parent 36d5319488
commit 3af5a3b0b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 37 additions and 21 deletions

View File

@ -18,6 +18,8 @@ using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
namespace ExtendingTheSdk;
public class Program
{
public static void Main()
@ -37,8 +39,8 @@ public class Program
// unstructured log
logger.LogInformation("Hello, World!");
// unstructured log with string interpolation
logger.LogInformation($"Hello from potato {0.99}.");
// String interpolation, as in the below line, results in unstructured logging, and is not recommended
// logger.LogInformation($"Hello from potato {0.99}.");
// structured log with template
logger.LogInformation("Hello from {name} {price}.", "tomato", 2.99);

View File

@ -17,6 +17,8 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;
namespace GettingStarted;
public class Program
{
public static void Main()

View File

@ -16,6 +16,8 @@
using Microsoft.Extensions.Logging;
namespace SourceGeneration;
public static partial class FoodSupplyLogs
{
[LoggerMessage(

View File

@ -17,6 +17,8 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;
namespace SourceGeneration;
public class Program
{
public static void Main()

View File

@ -19,12 +19,14 @@ using System.Diagnostics.Metrics;
using OpenTelemetry;
using OpenTelemetry.Metrics;
namespace CustomizingTheSdk;
public class Program
{
private static readonly Meter Meter1 = new("CompanyA.ProductA.Library1", "1.0");
private static readonly Meter Meter2 = new("CompanyA.ProductB.Library2", "1.0");
public static void Main(string[] args)
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter(Meter1.Name)

View File

@ -21,6 +21,8 @@ using System.Diagnostics.Metrics;
using OpenTelemetry;
using OpenTelemetry.Metrics;
namespace ExtendingTheSdk;
public class Program
{
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
@ -38,7 +40,7 @@ public class Program
});
}
public static void Main(string[] args)
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("MyCompany.MyProduct.MyLibrary")

View File

@ -20,12 +20,14 @@ using System.Threading;
using OpenTelemetry;
using OpenTelemetry.Metrics;
namespace GettingStartedPrometheusGrafana;
public class Program
{
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");
public static void Main(string[] args)
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("MyCompany.MyProduct.MyLibrary")

View File

@ -18,12 +18,14 @@ using System.Diagnostics.Metrics;
using OpenTelemetry;
using OpenTelemetry.Metrics;
namespace GettingStarted;
public class Program
{
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");
public static void Main(string[] args)
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("MyCompany.MyProduct.MyLibrary")

View File

@ -21,6 +21,8 @@ using System.Diagnostics.Metrics;
using OpenTelemetry;
using OpenTelemetry.Metrics;
namespace LearningMoreInstruments;
public class Program
{
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
@ -35,7 +37,7 @@ public class Program
MyMeter.CreateObservableGauge("Thread.State", () => GetThreadState(process));
}
public static void Main(string[] args)
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("MyCompany.MyProduct.MyLibrary")

View File

@ -18,6 +18,8 @@ using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Trace;
namespace CustomizingTheSdk;
public class Program
{
private static readonly ActivitySource MyLibraryActivitySource = new(

View File

@ -25,18 +25,8 @@ internal class MyFilteringProcessor : BaseProcessor<Activity>
public MyFilteringProcessor(BaseProcessor<Activity> processor, Func<Activity, bool> filter)
{
if (filter == null)
{
throw new ArgumentNullException(nameof(filter));
}
if (processor == null)
{
throw new ArgumentNullException(nameof(processor));
}
this.filter = filter;
this.processor = processor;
this.filter = filter ?? throw new ArgumentNullException(nameof(filter));
this.processor = processor ?? throw new ArgumentNullException(nameof(processor));
}
public override void OnEnd(Activity activity)

View File

@ -19,6 +19,8 @@ using OpenTelemetry;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
namespace ExtendingTheSdk;
public class Program
{
private static readonly ActivitySource DemoSource = new("OTel.Demo");

View File

@ -197,7 +197,7 @@ client .NET Core](../../../src/OpenTelemetry.Instrumentation.Http/README.md) .
Instrumentation libraries for these are already provided in this repo. The
[OpenTelemetry .NET
Contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib)
repostory also has instrumentations for libraries like
repository also has instrumentations for libraries like
[ElasticSearchClient](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.Contrib.Instrumentation.ElasticsearchClient)
etc. which fall in this category.

View File

@ -18,6 +18,8 @@ using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Trace;
namespace GettingStarted;
public class Program
{
private static readonly ActivitySource MyActivitySource = new(

View File

@ -19,6 +19,8 @@ using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Trace;
namespace ReportingExceptions;
public class Program
{
private static readonly ActivitySource MyActivitySource = new(

View File

@ -136,7 +136,7 @@ will depend on the presence of a debugger:
* If a debugger is attached, the debugger will be notified that an unhandled
exception happened.
* In case a postmortem debugger is configured, the postmortem debugger will be
activited and normally it will collect a crash dump.
activated and normally it will collect a crash dump.
It might be useful to automatically capture the unhandled exceptions, travel
through the unfinished activities and export them for troubleshooting. Here goes