Skip to content

Commit

Permalink
line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiningMassXAcc committed Dec 6, 2024
1 parent 13737c2 commit 619cd99
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 117 deletions.
12 changes: 6 additions & 6 deletions docs/logs/complex-objects/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using OpenTelemetry;
using OpenTelemetry.Logs;

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(logging => logging.AddConsoleExporter()));

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(logging => logging.AddConsoleExporter()));

var logger = sdk.GetLoggerFactory().CreateLogger<Program>();

var foodRecallNotice = new FoodRecallNotice
Expand All @@ -19,9 +19,9 @@
CompanyName = "Contoso Fresh Vegetables, Inc.",
};

logger.FoodRecallNotice(foodRecallNotice);

// Dispose SDK before the application ends.
logger.FoodRecallNotice(foodRecallNotice);

// Dispose SDK before the application ends.
sdk.Dispose();

internal static partial class LoggerExtensions
Expand Down
110 changes: 55 additions & 55 deletions docs/logs/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(
logging =>
{
logging.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(
serviceName: "MyService",
serviceVersion: "1.0.0"));
logging.AddConsoleExporter();
},
options => options.IncludeScopes = true));

var logger = sdk.GetLoggerFactory().CreateLogger<Program>();

logger.FoodPriceChanged("artichoke", 9.99);

using (logger.BeginScope(new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("store", "Seattle"),
}))
{
logger.FoodPriceChanged("truffle", 999.99);
}

logger.FoodRecallNotice(
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
recallReasonDescription: "due to a possible health risk from Listeria monocytogenes",
companyName: "Contoso Fresh Vegetables, Inc.");

// Dispose SDK before the application ends.
sdk.Dispose();

internal static partial class LoggerExtensions
{
[LoggerMessage(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

[LoggerMessage(LogLevel.Critical, "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
public static partial void FoodRecallNotice(
this ILogger logger,
string brandName,
string productDescription,
string productType,
string recallReasonDescription,
string companyName);
}
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(
logging =>
{
logging.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(
serviceName: "MyService",
serviceVersion: "1.0.0"));
logging.AddConsoleExporter();
},
options => options.IncludeScopes = true));

var logger = sdk.GetLoggerFactory().CreateLogger<Program>();

logger.FoodPriceChanged("artichoke", 9.99);

using (logger.BeginScope(new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("store", "Seattle"),
}))
{
logger.FoodPriceChanged("truffle", 999.99);
}

logger.FoodRecallNotice(
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
recallReasonDescription: "due to a possible health risk from Listeria monocytogenes",
companyName: "Contoso Fresh Vegetables, Inc.");

// Dispose SDK before the application ends.
sdk.Dispose();

internal static partial class LoggerExtensions
{
[LoggerMessage(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

[LoggerMessage(LogLevel.Critical, "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
public static partial void FoodRecallNotice(
this ILogger logger,
string brandName,
string productDescription,
string productType,
string recallReasonDescription,
string companyName);
}
36 changes: 18 additions & 18 deletions docs/logs/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ public class Program
{
public static void Main()
{
var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(
logging =>
{
logging.AddProcessor(new MyProcessor("ProcessorA"));
logging.AddProcessor(new MyProcessor("ProcessorB"));
logging.AddProcessor(new SimpleLogRecordExportProcessor(new MyExporter("ExporterX")));
logging.AddMyExporter();
},
options => options.IncludeScopes = true));

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(
logging =>
{
logging.AddProcessor(new MyProcessor("ProcessorA"));
logging.AddProcessor(new MyProcessor("ProcessorB"));
logging.AddProcessor(new SimpleLogRecordExportProcessor(new MyExporter("ExporterX")));
logging.AddMyExporter();
},
options => options.IncludeScopes = true));

var logger = sdk.GetLoggerFactory().CreateLogger<Program>();

// unstructured log
Expand Down Expand Up @@ -54,13 +54,13 @@ public static void Main()
}

// message will be redacted by MyRedactionProcessor
logger.LogInformation("OpenTelemetry {sensitiveString}.", "<secret>");

// Attempt to flush the remaining logs when using an exporter that may require it, such as the custom one defined here.
// Ignoring success or failure for flush after 5 seconds, but a richer application should choose to handle this in some manner.
sdk.LoggerProvider.ForceFlush(5000);

// Dispose SDK before the application ends.
logger.LogInformation("OpenTelemetry {sensitiveString}.", "<secret>");

// Attempt to flush the remaining logs when using an exporter that may require it, such as the custom one defined here.
// Ignoring success or failure for flush after 5 seconds, but a richer application should choose to handle this in some manner.
sdk.LoggerProvider.ForceFlush(5000);

// Dispose SDK before the application ends.
sdk.Dispose();
}

Expand Down
76 changes: 38 additions & 38 deletions docs/logs/getting-started-console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(logging => logging.AddConsoleExporter()));

var logger = sdk.GetLoggerFactory().CreateLogger<Program>();

logger.FoodPriceChanged("artichoke", 9.99);

logger.FoodRecallNotice(
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
recallReasonDescription: "due to a possible health risk from Listeria monocytogenes",
companyName: "Contoso Fresh Vegetables, Inc.");

// Dispose SDK before the application ends.
sdk.Dispose();

internal static partial class LoggerExtensions
{
[LoggerMessage(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

[LoggerMessage(LogLevel.Critical, "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
public static partial void FoodRecallNotice(
this ILogger logger,
string brandName,
string productDescription,
string productType,
string recallReasonDescription,
string companyName);
}
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;

var sdk = OpenTelemetrySdk.Create(builder => builder
.WithLogging(logging => logging.AddConsoleExporter()));

var logger = sdk.GetLoggerFactory().CreateLogger<Program>();

logger.FoodPriceChanged("artichoke", 9.99);

logger.FoodRecallNotice(
brandName: "Contoso",
productDescription: "Salads",
productType: "Food & Beverages",
recallReasonDescription: "due to a possible health risk from Listeria monocytogenes",
companyName: "Contoso Fresh Vegetables, Inc.");

// Dispose SDK before the application ends.
sdk.Dispose();

internal static partial class LoggerExtensions
{
[LoggerMessage(LogLevel.Information, "Food `{name}` price changed to `{price}`.")]
public static partial void FoodPriceChanged(this ILogger logger, string name, double price);

[LoggerMessage(LogLevel.Critical, "A `{productType}` recall notice was published for `{brandName} {productDescription}` produced by `{companyName}` ({recallReasonDescription}).")]
public static partial void FoodRecallNotice(
this ILogger logger,
string brandName,
string productDescription,
string productType,
string recallReasonDescription,
string companyName);
}

0 comments on commit 619cd99

Please sign in to comment.