DataDog / dd-trace-dotnet

.NET Client Library for Datadog APM
https://docs.datadoghq.com/tracing/
Apache License 2.0
461 stars 141 forks source link

Readme code example doesn't compile with 2.8.0 #2778

Closed Jamie-Clayton closed 2 years ago

Jamie-Clayton commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Custom .net Configuration'
  2. Create a blank webapi .net core solution with '....'
  3. Scroll down to 'Simplification of the tracer interface'
  4. Copy and paste the example code into a sample controller method.
    var spanCreationSettings = new SpanCreationSettings() { Parent = spanContext };
  5. Compiler warning for spanContext

Expected behavior Quickly copy sample code into a solution and get the expected log/trace interaction working.

Ideally, logs and tracing for (web ui, webapi,SQL Server Database [3 tier]) solutions should work to ensure logging (including debugging logging) links traces and errors with custom spans. There are some differences to the api examples provided for open telemetry, see https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/examples/Console/InstrumentationWithActivitySource.cs.

Runtime environment (please complete the following information):

andrewlock commented 2 years ago

Hi @Jamie-Clayton, thanks for flagging this. Those specific instructions are not meant to be "getting started" copy-and-paste examples, but rather "if you were doing this before, do this instead". In that respect they're not intended to be "complete", just to show how things have changed.

That said, I think there's definitely value in having those "getting started" examples in that doc. We have some samples in the repository for specific scenarios, but those are related to specific scenarios. It makes sense to have a simple "create a span" example in the NuGet ReadMe too. Thanks!

lucaspimentel commented 2 years ago

It seems like we have the simple "create a span" example in the repository readme and the NuGet readme (same file, iirc). There are also more examples in the official docs: https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/dotnet/