continuing to struggle getting all of the telemetr...
# support
b
continuing to struggle getting all of the telemetry to come across. in fact, there is only one method that does produce telemetry in the backend.
configuring Orleans silo like this:
Copy code
silo.Services.AddOpenTelemetry()
            .WithTracing(trace =>
            {
                trace
                    .AddSource("*")
                    .SetResourceBuilder(
                        ResourceBuilder
                            .CreateDefault()
                            .AddEnvironmentVariableDetector()
                            .AddTelemetrySdk()
                            .AddService(serviceName: serviceName, serviceVersion: serviceVersion));
                trace.AddOtlpExporter(otlp => otlp.Endpoint = new Uri($"http://{hostContext.Configuration["Otel:Collector"]}"));
                trace.AddConsoleExporter();
            });
I can only see the console output for the following method:
Copy code
public Task<IList<Election>> GetElections(ElectionId? electionId = null, bool openOnly = true)

    {
        ActivityContext? activityContext = null;
        using var activity = _activities.StartActivity(ActivityKind.Server);
        IList<Election> elections;
        try
        {
            activity?.SetTag("electionId", electionId?.ToString());
            activity?.SetTag("openOnly", openOnly.ToString());
            elections = electionId == null
                ? State.Elections.Where(e => !e.Deleted &&
                                             (e.Status == "Active" || !openOnly)).ToList()
                : State.Elections.Where(x => x.Id == electionId && !x.Deleted).ToList();
            activity?.SetStatus(ActivityStatusCode.Ok);
        }
        catch (Exception ex)
        {
            activity?.RecordException(ex);
            activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
            throw;
        }
        return Task.FromResult(elections);
    }
here's one that doesn't work:
Copy code
public async Task Create(ElectionId id, Title title, Description? description)
    {
        var activity = _activities.StartActivity(ActivityKind.Consumer);
        try
        {
            activity?.SetTag("id", id);
            activity?.SetTag("title", title);
            activity?.SetTag("description", description);
            var @event = new Vote.Election.Created
            {
                Id = this.GetPrimaryKey(),
                Title = title,
                Description = description
            };
            var activityEvent = new ActivityEvent(@event.GetType().FullName ?? @event.GetType().Name, tags: new ActivityTagsCollection
            {
                { "Id", @event.Id },
                { "Title", @event.Title },
                { "Description", @event.Description }
            });
            RaiseEvent(@event);
            activity?.AddEvent(activityEvent);
            _subscribeToElections = this.GetStreamProvider("StreamProvider").GetStream<object>("Election", this.GetPrimaryKey());
            if (_publishToApplication != null) await _publishToApplication.OnNextAsync(@event);
            await ConfirmEvents();
            activity?.SetStatus(ActivityStatusCode.Ok);
        }
        catch (Exception ex)
        {
            activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
            throw;
        }
    }
I guess the only other thing worth mentioning is that I am injecting the
ActivitySource
as follows:
silo.Services.AddSingleton(activitySource);
so all grains have the same instance of
ActivitySource
, all activities are derived from that source, and yet only one method's activities are successfully generated?
found it:
var activity = ...
vs
using var activity = ...