Add docs to solution. Add more to the doc. (#906)
* Add docs to solution. Add more to the doc. * text * no nuget version
This commit is contained in:
parent
8fbf6fa3de
commit
bacbf3e676
|
|
@ -149,6 +149,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentati
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.Grpc", "src\OpenTelemetry.Instrumentation.Grpc\OpenTelemetry.Instrumentation.Grpc.csproj", "{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docs\getting-started.md = docs\getting-started.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Install the
|
|||
package:
|
||||
|
||||
```sh
|
||||
dotnet add package OpenTelemetry.Exporter.Console -v 0.2.0-alpha.419
|
||||
dotnet add package OpenTelemetry.Exporter.Console
|
||||
```
|
||||
|
||||
Update the `Program.cs` file with the following code:
|
||||
|
|
@ -40,7 +40,7 @@ class Program
|
|||
{
|
||||
using var otel = OpenTelemetrySdk.CreateTracerProvider(b => b
|
||||
.AddActivitySource("MyCompany.MyProduct.MyLibrary")
|
||||
.UseConsoleExporter(options => options.DisplayAsJson = true));
|
||||
.UseConsoleExporter());
|
||||
|
||||
using (var activity = activitySource.StartActivity("SayHello"))
|
||||
{
|
||||
|
|
@ -54,61 +54,27 @@ class Program
|
|||
Run the application again (using `dotnet run`) and you should see the trace
|
||||
output from the console.
|
||||
|
||||
```json
|
||||
{
|
||||
"Kind": "Internal",
|
||||
"OperationName": "SayHello",
|
||||
"DisplayName": "SayHello",
|
||||
"Source": {
|
||||
"Name": "MyCompany.MyProduct.MyLibrary",
|
||||
"Version": ""
|
||||
},
|
||||
"Parent": null,
|
||||
"Duration": {
|
||||
"Ticks": 19138,
|
||||
"Days": 0,
|
||||
"Hours": 0,
|
||||
"Milliseconds": 1,
|
||||
"Minutes": 0,
|
||||
"Seconds": 0,
|
||||
"TotalDays": 2.2150462962962963E-08,
|
||||
"TotalHours": 5.316111111111111E-07,
|
||||
"TotalMilliseconds": 1.9138,
|
||||
"TotalMinutes": 3.189666666666667E-05,
|
||||
"TotalSeconds": 0.0019138
|
||||
},
|
||||
"StartTimeUtc": "2020-07-22T01:21:23.6303212Z",
|
||||
"Id": "00-6cfd9c572593ea448a0e5c1cbcde3a82-b79f6fe5ba84d040-01",
|
||||
"ParentId": null,
|
||||
"RootId": "6cfd9c572593ea448a0e5c1cbcde3a82",
|
||||
"Tags": [
|
||||
{
|
||||
"Key": "foo",
|
||||
"Value": "1"
|
||||
},
|
||||
{
|
||||
"Key": "bar",
|
||||
"Value": "Hello, World!"
|
||||
}
|
||||
],
|
||||
"Events": [],
|
||||
"Links": [],
|
||||
"Baggage": [],
|
||||
"Context": {
|
||||
"TraceId": "6cfd9c572593ea448a0e5c1cbcde3a82",
|
||||
"SpanId": "b79f6fe5ba84d040",
|
||||
"TraceFlags": "Recorded",
|
||||
"TraceState": null
|
||||
},
|
||||
"TraceStateString": null,
|
||||
"SpanId": "b79f6fe5ba84d040",
|
||||
"TraceId": "6cfd9c572593ea448a0e5c1cbcde3a82",
|
||||
"Recorded": true,
|
||||
"IsAllDataRequested": true,
|
||||
"ActivityTraceFlags": "Recorded",
|
||||
"ParentSpanId": "0000000000000000",
|
||||
"IdFormat": "W3C"
|
||||
}
|
||||
```text
|
||||
Activity ID - 00-3ae67370100cdc44a8d461d1b2cf846f-d80f2b1ab6d3bc4b-01
|
||||
Activity DisplayName - SayHello
|
||||
Activity Kind - Internal
|
||||
Activity StartTime - 7/24/2020 1:16:21 AM
|
||||
Activity Duration - 00:00:00.0018754
|
||||
Activity Tags
|
||||
foo : 1
|
||||
bar : Hello, World!
|
||||
```
|
||||
|
||||
Congratulations! You are now collecting traces using OpenTelemetry.
|
||||
|
||||
What does the above program do?
|
||||
|
||||
The program creates an `ActivitySource` which represents [OpenTelemetry
|
||||
Tracer](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#tracer).
|
||||
The activitysource instance is used to start an `Activity` which represent
|
||||
[OpenTelemetry
|
||||
Span](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#span).
|
||||
`OpenTelemetrySdk.CreateTracerProvider` sets up the OpenTelemetry Sdk, and
|
||||
configures it to subscribe to the activities from the source
|
||||
`MyCompany.MyProduct.MyLibrary`, and export it to `ConsoleExporter`, which
|
||||
simply displays it on the console.
|
||||
|
|
|
|||
Loading…
Reference in New Issue