How to inject custom tags into OpenTelemetry when using a side-car pattern

Viewed 30

I am new to OpenTelemetry. I am trying to understand how to set up custom tags when using a side-car Observability pattern as DAPR. My point is to find a way to add OpenTelemetry tags to a Trace in an app service.DAPR side-car container inject traceId, spanId etc. I have setup sample app on Kubernetes. I have modified the C# class SubtractController like this:

//POST: /subtract
    [HttpPost]
    public decimal Subtract(Operands operands)
    {
        //from here:
        using var source = new ActivitySource("Subtract");
        using var activity = source.StartActivity(
                            "",
                            ActivityKind.Consumer);
        activity?.SetTag("MyGreatTag", "here!");
        //to here.

        Console.WriteLine($"Subtracting {operands.OperandTwo} from {operands.OperandOne}"); 
        return Decimal.Parse(operands.OperandOne) - Decimal.Parse(operands.OperandTwo);
    }

Essentially I've tried to inject a tracing tag with System.Diagnostics lib. However in Zipkin this tag is absent. So I assume it does not work. Any hint?

0 Answers
Related