Skip to content

Latest commit

 

History

History
 
 

api

Stackdriver Trace Sample for ASP.NET Core MVC

A sample demonstrating how to create traces using the ASP.NET Core and Google Cloud Stackdriver Trace.

This sample requires .NET Core 2.0 or later. That means using Visual Studio 2017, or the command line. Visual Studio 2015 users can use this older sample.

Build and Run

  1. Follow the set-up instructions in the documentation.

  2. In appsettings.json change the placeholder value of "YOUR-GOOGLE-PROJECT-ID" to be your project id.

  3. From a Powershell command line, run the Trace sample:

    PS C:\...\dotnet-docs-samples\trace\api> dotnet run
    Now listening on: http://localhost:5000
    Application started. Press Ctrl+C to shut down.
    Application is shutting down...
  4. Open the running sample web app http://localhost:5000 in a web browser which will display a confirmation that trace is configured along with a link to initiate a trace like:

Trace has been configured for use with this application.
See the Stackdriver Trace dashboard in the Google Cloud Console
to view traces for your application.

  •Initiate a trace
  1. Click the "Initiate a trace" link to create a sample trace.

  2. Go back to Powershell and Press Ctrl+C to close the web app which will still be running.

  3. The sample trace is viewable on the Stackdriver Trace page in the Cloud Platform Console.

Deploy to Google App Engine Flexible Environment

  1. Install the Google Cloud SDK. The Google Cloud SDK is required to deploy .NET applications to App Engine.

  2. Google Cloud Tools for Visual Studio make it easy to deploy to App Engine. Install them if you are running Visual Studio.

PowerShellUsing PowerShell

PS > dotnet restore
PS > dotnet publish
PS > gcloud beta app deploy .\bin\Debug\netcoreapp2.0\publish\app.yaml

Visual StudioUsing Visual Studio

  1. In Solution Explorer, right-click the Trace project and choose Publish to Google Cloud.

  2. Click App Engine Flex.

  3. Click Publish.

Contributing changes

Licensing