Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
20 changes: 13 additions & 7 deletions docs/trace/getting-started-console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
11 changes: 11 additions & 0 deletions opentelemetry-dotnet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>opentelemetry_dotnet</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}