Skip to content

Commit

Permalink
Fix analyzer issues in docs (#3026)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillig authored Mar 12, 2022
1 parent 36d5319 commit 3af5a3b
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 21 deletions.
6 changes: 4 additions & 2 deletions docs/logs/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry;

namespace ExtendingTheSdk;

public class Program
{
public static void Main()
Expand All @@ -37,8 +39,8 @@ public static void Main()
// 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);
Expand Down
2 changes: 2 additions & 0 deletions docs/logs/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

namespace GettingStarted;

public class Program
{
public static void Main()
Expand Down
2 changes: 2 additions & 0 deletions docs/logs/source-generation/FoodSupplyLogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

using Microsoft.Extensions.Logging;

namespace SourceGeneration;

public static partial class FoodSupplyLogs
{
[LoggerMessage(
Expand Down
2 changes: 2 additions & 0 deletions docs/logs/source-generation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;

namespace SourceGeneration;

public class Program
{
public static void Main()
Expand Down
4 changes: 3 additions & 1 deletion docs/metrics/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
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)
Expand Down
4 changes: 3 additions & 1 deletion docs/metrics/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using OpenTelemetry;
using OpenTelemetry.Metrics;

namespace ExtendingTheSdk;

public class Program
{
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
Expand All @@ -38,7 +40,7 @@ static Program()
});
}

public static void Main(string[] args)
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("MyCompany.MyProduct.MyLibrary")
Expand Down
4 changes: 3 additions & 1 deletion docs/metrics/getting-started-prometheus-grafana/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
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")
Expand Down
4 changes: 3 additions & 1 deletion docs/metrics/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
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")
Expand Down
4 changes: 3 additions & 1 deletion docs/metrics/learning-more-instruments/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using OpenTelemetry;
using OpenTelemetry.Metrics;

namespace LearningMoreInstruments;

public class Program
{
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
Expand All @@ -35,7 +37,7 @@ static 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")
Expand Down
2 changes: 2 additions & 0 deletions docs/trace/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using OpenTelemetry;
using OpenTelemetry.Trace;

namespace CustomizingTheSdk;

public class Program
{
private static readonly ActivitySource MyLibraryActivitySource = new(
Expand Down
14 changes: 2 additions & 12 deletions docs/trace/extending-the-sdk/MyFilteringProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions docs/trace/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

namespace ExtendingTheSdk;

public class Program
{
private static readonly ActivitySource DemoSource = new("OTel.Demo");
Expand Down
2 changes: 1 addition & 1 deletion docs/trace/extending-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions docs/trace/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using OpenTelemetry;
using OpenTelemetry.Trace;

namespace GettingStarted;

public class Program
{
private static readonly ActivitySource MyActivitySource = new(
Expand Down
2 changes: 2 additions & 0 deletions docs/trace/reporting-exceptions/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using OpenTelemetry;
using OpenTelemetry.Trace;

namespace ReportingExceptions;

public class Program
{
private static readonly ActivitySource MyActivitySource = new(
Expand Down
2 changes: 1 addition & 1 deletion docs/trace/reporting-exceptions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3af5a3b

Please sign in to comment.