diff --git a/Program.cs b/Program.cs new file mode 100644 index 00000000000..3751555cbd3 --- /dev/null +++ b/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/docs/trace/getting-started-console/Program.cs b/docs/trace/getting-started-console/Program.cs index 4acaf7b8a80..aba7d580cdc 100644 --- a/docs/trace/getting-started-console/Program.cs +++ b/docs/trace/getting-started-console/Program.cs @@ -11,21 +11,27 @@ public class Program public static void Main() { + // Initialize the tracerProvider var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("MyCompany.MyProduct.MyLibrary") .AddConsoleExporter() .Build(); - using (var activity = MyActivitySource.StartActivity("SayHello")) + // Create a new activity using the ActivitySource + var activity = MyActivitySource.StartActivity("SayHello"); + + if (activity != null) { - activity?.SetTag("foo", 1); - activity?.SetTag("bar", "Hello, World!"); - activity?.SetTag("baz", new int[] { 1, 2, 3 }); - activity?.SetStatus(ActivityStatusCode.Ok); + activity.SetTag("foo", 1); + activity.SetTag("bar", "Hello, World!"); + activity.SetTag("baz", new int[] { 1, 2, 3 }); + activity.SetStatus(ActivityStatusCode.Ok); + + // End the activity (implicitly done when activity goes out of scope) } - // Dispose tracer provider before the application ends. - // This will flush the remaining spans and shutdown the tracing pipeline. + // Dispose the tracerProvider explicitly to ensure cleanup + // and proper flushing of any telemetry data before the app exits tracerProvider.Dispose(); } } diff --git a/opentelemetry-dotnet.csproj b/opentelemetry-dotnet.csproj new file mode 100644 index 00000000000..0e5a1557d3b --- /dev/null +++ b/opentelemetry-dotnet.csproj @@ -0,0 +1,11 @@ + + + + Exe + net9.0 + opentelemetry_dotnet + enable + enable + + + diff --git a/package.json b/package.json new file mode 100644 index 00000000000..5398f43c630 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "opentelemetry-dotnet", + "version": "1.0.0", + "description": "[![Slack](https://img.shields.io/badge/slack-@cncf/otel/dotnet-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01N3BC2W7Q)\r [![codecov.io](https://codecov.io/gh/open-telemetry/opentelemetry-dotnet/branch/main/graphs/badge.svg?)](https://codecov.io/gh/open-telemetry/opentelemetry-dotnet/)\r [![Nuget](https://img.shields.io/nuget/v/OpenTelemetry.svg)](https://www.nuget.org/profiles/OpenTelemetry)\r [![NuGet](https://img.shields.io/nuget/dt/OpenTelemetry.svg)](https://www.nuget.org/profiles/OpenTelemetry)\r [![Build](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/ci.yml)", + "main": "index.js", + "directories": { + "doc": "docs", + "example": "examples", + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +}