Giter Club home page Giter Club logo

Comments (10)

object avatar object commented on June 6, 2024 1

And this sample is using Phobos 2. Cool, I will check it out

from phobos-issues.

Arkatufus avatar Arkatufus commented on June 6, 2024

Hi @object,
Can you give us your Phobos configuration?
In the meantime, can you add Activity.Current = activity; right after you created it and see if that works?
You might also want to do an assertion that the activity isn't null, StartActivity can return null if the ActivitySource does not have any listener or if the ActivityListener.Sample isn't set

from phobos-issues.

object avatar object commented on June 6, 2024

@Arkatufus out Phobos configuration is quite simple, this is F# code:

    let createSetup (sp: IServiceProvider) enableMetrics enableTracing =
        let metrics = sp.GetRequiredService<IMetricsRoot>()
        let tracer = sp.GetRequiredService<OpenTracing.ITracer>()
        let builder = Phobos.Actor.Configuration.PhobosConfigBuilder()
        let builder =
            if enableMetrics then
                builder.WithMetrics(fun b -> b.SetMetricsRoot(metrics) |> ignore)
            else
                builder
        let builder =
            if enableTracing then
                builder.WithTracing (fun b -> b.SetTracer(tracer) |> ignore)
            else
                builder
        PhobosSetup.Create(builder)

The activity is not null because I can see it included in a distributed trace from a transaction originated by another system (that sends a RabbitMQ message to us).

from phobos-issues.

object avatar object commented on June 6, 2024

And setting Activity.Current = activity didn't help.

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 6, 2024

This is with the OpenTracing shim inside OpenTelemetry? How do you subscribe to that from the POV of the OTEL Sdk?

from phobos-issues.

object avatar object commented on June 6, 2024

Here's essentials of the bootstrapper code:

module PhobosBootstrapper =
    let private createMetrics (mb: IMetricsBuilder) =
        mb.Configuration.Configure (fun opts ->
            opts.GlobalTags.Add("host", Dns.GetHostName())
            opts.DefaultContextLabel <- "akka.net"
            opts.Enabled <- true
            opts.ReportingEnabled <- true)

    let createSetup (sp: IServiceProvider) =
        let metrics = sp.GetRequiredService<IMetricsRoot>()
        let tracer = sp.GetRequiredService<OpenTracing.ITracer>()
        let builder = Phobos.Actor.Configuration.PhobosConfigBuilder()
        let builder = builder.WithTracing (fun b -> b.SetTracer(tracer) |> ignore)
        PhobosSetup.Create(builder)


[<AutoOpen>]
module BootstrapperExtensions =
    let assemblyName = Reflection.Assembly.GetEntryAssembly().GetName().Name

    let buildTraceProvider (builder: TracerProviderBuilder) =
        builder
            .AddSource(assemblyName)
            .SetResourceBuilder(
                ResourceBuilder
                    .CreateDefault()
                    .AddService(assemblyName)
            )
            .AddAzureMonitorTraceExporter(fun o ->
                o.ConnectionString <-
                    "InstrumentationKey="MY_KEY";IngestionEndpoint=https://westeurope-2.in.applicationinsights.azure.com/")
            .Build()

    type IServiceCollection with
        member services.ConfigureTracing() : IServiceCollection =
            services.AddOpenTelemetryTracing(fun builder -> buildTraceProvider (Sdk.CreateTracerProviderBuilder()) |> ignore)
            |> ignore
            services.AddSingleton<ITracer> (fun sp ->
                let traceProvider = sp.GetRequiredService<TracerProvider>()
                let tracer = new TracerShim(traceProvider.GetTracer(assemblyName), Propagators.DefaultTextMapPropagator)
                GlobalTracer.RegisterIfAbsent(tracer) |> ignore
                tracer :> ITracer)

module Bootstrapper =
    let createActorSystem oddjobConfig serviceProvider enablePhobos =

        let actorSystemSetup =
            if oddjobConfig.Features.EnablePhobosInstrumentation && enablePhobos then
                let bootstrapSetup = loadAkkaClusterConfigurationWithPhobos () |> BootstrapSetup.Create().WithConfig
                (PhobosBootstrapper.createSetup serviceProvider oddjobConfig.Features.EnableAppMetrics oddjobConfig.Features.EnableOpenTracing)
                    .And(bootstrapSetup)
            else
                let bootstrapSetup = loadAkkaClusterConfiguration () |> BootstrapSetup.Create().WithConfig
                Akka.Actor.Setup.ActorSystemSetup.Create bootstrapSetup

        ActorSystem.Create(OddjobSystem, actorSystemSetup)


from phobos-issues.

object avatar object commented on June 6, 2024

BTW, I started playing with Phobos 2.0 Do you have any source code examples? All repos that I find at aaronontheweb refer to Phobos 1.x.

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 6, 2024

Thanks @object - I will take a look at that.

Best sample I have right now is the otel branch of our quickstart: https://github.com/petabridge/Petabridge.Phobos.Web/tree/otel

We're going to get Phobos 2.0 docs up soon though, so this shouldn't be as hard to find.

from phobos-issues.

object avatar object commented on June 6, 2024

@Aaronontheweb

Built small apps using Phobos 2.0. I can confirm that I distributed traces are propagated all the way, and after RabbitMQ messages are consumed its propagation context is used by Phobos actors.

I will continue testing this with a bigger app, but so far it looks good. If it works fine in Phobos 2.0, there is probably no need for you to spend time on investigating this issue for Phobos 1.x.

from phobos-issues.

Aaronontheweb avatar Aaronontheweb commented on June 6, 2024

Ok, thanks @object - I'll mark this as closed for now.

from phobos-issues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.