Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opens a json file when at Oracle connection.Open() line #57

Closed
nmarun opened this issue Jan 9, 2019 · 10 comments
Closed

Opens a json file when at Oracle connection.Open() line #57

nmarun opened this issue Jan 9, 2019 · 10 comments
Assignees

Comments

@nmarun
Copy link

nmarun commented Jan 9, 2019

Hi I'm trying to integrate Steeltoe to my .netcore application. The application connects to an Oracle db and fetches a few records for processing. While debugging locally, my app is opening the below json file when i execute the connection.Open() line. Once I open the json file, the debugging in VS gets stopped while the app continues to run.

I'm using the below packages:

<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="2.1.1" />
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="2.1.1" />
<PackageReference Include="steeltoe.management.tracingcore" Version="2.1.1" />

What am I missing?
S04W8QRC.txt

Program.cs file:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseHealthChecks("/health") // Healthcheck route
        .UseStartup<Startup>()
        .UseSerilog()
        .UseCloudFoundryHosting()
        .ConfigureAppConfiguration((builderContext, config) =>
        {
            config.AddCloudFoundry()
                  .AddEnvironmentVariables();
        })
        .ConfigureLogging((builderContext, logging) =>
        {
            logging.AddDynamicConsole();
        });

Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);

    //Zipkin integration using Steeltoe
    services.AddCloudFoundryActuators(Configuration);
    services.AddDistributedTracing(Configuration);
    // Add Steeltoe Cloud Foundry Options to service container
    services.ConfigureCloudFoundryOptions(Configuration);

    services.AddCors();
    ....
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

    var configSettings = app.ApplicationServices.GetRequiredService<IConfigSettings>();

    // if its in PCF forward it.
    if (configSettings.EnvironmentName != "Development")
    {
        app.UseForwardedHeaders(new ForwardedHeadersOptions()
        {
            ForwardedHeaders = ForwardedHeaders.XForwardedProto
        });
    }

    app.UseCloudFoundryActuators();

    app.UseCors(
        options => options
            .AllowAnyMethod()
            .AllowAnyHeader()
            .AllowAnyOrigin()
    );
    ...

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/163084679

The labels on this github issue will be updated when the story is started.

@hananiel
Copy link
Contributor

hananiel commented Jan 9, 2019

@nmarun sounds like your path (management:endpoints:path) is set to / (or perhaps not set). Look at https://steeltoe.io/docs/steeltoe-management/#1-2-usage and try setting this in your appsettings.json: management:endpoints:path=/cloudfoundryapplication.

@hananiel hananiel self-assigned this Jan 9, 2019
@nmarun
Copy link
Author

nmarun commented Jan 9, 2019

@hananiel thanks, yes it was missing, but that still didn't solve the problem.

I'm seeing these two lines in the output window in VS:
[09-01-2019 14:33:13 dbug Instance Index: 0] : Invoke(/)
[09-01-2019 14:33:13 dbug Instance Index: 0] : Returning: {"type":"steeltoe","_links":{"self":{"href":"http://localhost:54885/"},"dump":{"href":"http://localhost:54885//dump"},"heapdump":{"href":"http://localhost:54885//heapdump"},"info":{"href":"http://localhost:54885//info"},"health":{"href":"http://localhost:54885//health"},"loggers":{"href":"http://localhost:54885//loggers"},"trace":{"href":"http://localhost:54885//trace"},"mappings":{"href":"http://localhost:54885//mappings"}}}

Does that help in any way?

Also, I'm using IISExpress for local debugging.

@hananiel
Copy link
Contributor

hananiel commented Jan 9, 2019

nmarun, can you confirm that your appsettings.json is in your application root, and it is set to "copy if new" and getting copied to bin folder. If that doesn't work, can you try commenting out
services.AddCloudFoundryActuators(Configuration); and app.UseCloudFoundryActuators(); Tracing will not work but your app should, allowing you to figure out issues. If that still doesn't work, can you share your project or a simplified project to take a look at. Also caveat that there are known issues with Serilog and dynamic loggers and the loggers actuator. But that is something after you fix this initial problem of app not running.

@nmarun
Copy link
Author

nmarun commented Jan 10, 2019

@hananiel I had updated the management:endpoints:path in the wrong appsettings.json. So just adding that config in the correct file helped me get rid of the issue and now my app is working. One question still remains is that doesn't it show the trace id and span id while local debugging?

I did read a couple of articles which talked about Steeltoe-Serilog incompatibility. Isn't there any work around for that? Please let me know.

Arun

@hananiel
Copy link
Contributor

@nmarun can you confirm that removing Serilog makes things work? I would recommend we test each component one by one and find what is breaking . Ex. Start with just actuators and verify trace functionality. And slowly add the other things. Also try increasing the log level and attach the logs so we can take a look.

@nmarun
Copy link
Author

nmarun commented Jan 10, 2019

I created a simple application by following the steps in https://steeltoe.io/docs/steeltoe-management/#2-1-1-running-locally. This one doesn't have Serilog but when I deploy, it doesn't show my the trace id / span id details in PCF (or even local, if it should show there).

steeltoetest.zip

@hananiel
Copy link
Contributor

hananiel commented Jan 10, 2019

@nmarun I looked at your solution. I am not sure how you are trying to view the traces but adding a zipkin trace exporter worked for me as how the sample works. Please take a look and see if this helps: https://github.com/hananiel/nmarun/commit/511ba80b627388f2bcb97a6fe02edd0442f70d95

@hananiel
Copy link
Contributor

hananiel commented Jan 10, 2019

So two options to view traces locally :

  1. Add app.UseCloudFoundryActuators() and then you can see your traces here https://localhost:5001/cloudfoundryapplication/trace
  2. Add the UseZipkin Exporter and view the traces in zipkin

In Cloud Foundry, you can just add the app.UseCloudFoundryActuators with the path set to "/cloudfoundryapplication" and the traces window in apps manager should show you the traces,

@TimHess
Copy link
Member

TimHess commented Jun 6, 2019

This issue has been dormant for months, I'm assuming you found a solution. Please re-open if you need further help with this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants