Skip to content

Question: System.Diagnostics.ActivitySamplingResult usage #91070

Closed

Description

@WeihanLi

Hi there, I have a question about the System.Diagnostics.ActivitySamplingResult

Per the docs https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activitysamplingresult

From my understanding

  • When None, no activity would be created, use this when we do not want to record the activity
  • When AllDataAndRecorded, activity would be created and all data(propagation data and other properties such as Links, Tags, and Events) would be recorded and should be recorded in the tracing system, when we want to log data in the tracing system, use this one
  • When PropagationData, activity would be created and only Id(including ParentId/TraceId/SpanId)/Name/Source would have value, when we try to use it for logging, prefer this than others
  • When AllData, it likes the AllDataAndRecorded, but the recorded flag would be false, and would not be recorded in the tracing system

Is this correct? and when should we consider using the ActivitySamplingResult.AllData?

Thanks very much

Activity

  1. ghost added
    untriaged
    on Aug 24, 2023
  2. tarekgh commented on Aug 24, 2023

    @tarekgh
    Member

    Is this correct?

    Yes.

    when should we consider using the ActivitySamplingResult.AllData

    You may look at OpenTelemetry IsRecording. The definition there applies exactly to ActivitySamplingResult.AllData.
    Note, don't get confused with the names between .NET and OpenTelemetry. In .NET when having ActivitySamplingResult.AllData the created Activity object will have Activity.IsAllDataRequested = true and this will get mapped to OpenTelemetry Span.IsRecording.
    And in .NET Activity.Recorded means in this activity the W3C trace context sampling flag will be set to allow out of proc sampling. OpenTelemetry uses this for sampling too. The names can be confusion because Activity.Recorded is introduced long before OpenTelemetry and other specs. Activity.Recorded will be true if we have ActivitySamplingResult.AllDataAndRecorded

    I am closing this issue but feel free to respond with more questions if you have any.

  3. ghost removed
    untriaged
    on Aug 24, 2023
  4. WeihanLi commented on Aug 25, 2023

    @WeihanLi
    ContributorAuthor

    @tarekgh thanks very much

  5. ghost locked as resolved and limited conversation to collaborators on Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions