agentleFS
MovGP0MovGP0/Skills/activity-tracing/SKILL.md

activity-tracing

Skill1 starsChanged 5 months agoMITView on GitHub

Guides activity tracing with generated ActivitySources, tags, parent activities, exception status handling, and registration. Use when adding or reviewing OpenTelemetry activity tracing in Bendex flows.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use activity tracing for user-triggered flows, important domain actions, and cross-component transitions where we need to see call order …

    line 7
  2. Distinctive:

    Do not add activity tracking to

    line 8
  3. Very specific:

    Prefer activity tracing instead of LogDebug in methods that are traced.

    line 15
  4. Very specific:

    Ensure the class has [GenerateActivitySources] and using System.Diagnostics;.

    line 17
  5. Very specific:

    Add key inputs via activity?.AddTag("arg.<name>", value);.

    line 19
  6. Very specific:

    If a method has a parent activity, pass it through to downstream calls and to Create(parentActivity).

    line 21

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Activity Tracing

  • Use activity tracing for user-triggered flows, important domain actions, and cross-component transitions where we need to see call order and inputs.
  • Do not add activity tracking to
    • Constructors, destructors
    • HandleCreated events
    • Dispose() methods.
    • Properties (including Get<PropertyName>() or Set<PropertyName>() methods)
    • Methods that are called often, like OnLoad(), OnDraw() or OnMouseMove()
    • *.Designer.cs files
  • Prefer activity tracing instead of LogDebug in methods that are traced; remove those debug logs when adding tracing.
  • Implementation pattern:
    • Ensure the class has [GenerateActivitySources] and using System.Diagnostics;.
    • Wrap method bodies with using var activity = <Type>ActivitySources.<MethodName>.Create(parentActivity);.
    • Add key inputs via activity?.AddTag("arg.<name>", value);.
    • On exceptions: activity?.AddException(ex); activity?.SetStatus(ActivityStatusCode.Error, ex.Message); then rethrow.
    • If a method has a parent activity, pass it through to downstream calls and to Create(parentActivity).
    • Register the generated activity sources in the module ActivitySources.cs (e.g. add .Concat(<Type>ActivitySources.GetAll()) to the module's GetAll() method).

Example:

[GenerateActivitySources]
public sealed class ExampleService
{
    public void DoWork(int stepIndex, Activity? parentActivity = null)
    {
        using var activity = ExampleServiceActivitySources.DoWork.Create(parentActivity);
        activity?.AddTag("arg.stepIndex", stepIndex);
        try
        {
            // work here
        }
        catch (Exception ex)
        {
            activity?.AddException(ex);
            activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
            throw;
        }
    }
}

Event Handler:

public void OnSomeEvent(object? sender, EventArgs args)
{
    using var activity = ExampleServiceActivitySources.OnSomeEvent.Create();
    try
    {
        // work here
    }
    catch (Exception ex)
    {
        activity?.AddException(ex);
        activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
        throw;
    }
}

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.