Apm-agent-dotnet: EntityFramework6 / Ef6Interceptor Spans does not contain Global Labels

Created on 18 Feb 2020  路  3Comments  路  Source: elastic/apm-agent-dotnet

Describe the bug

The Ef6Interceptor send ELASTIC_APM_GLOBAL_LABELS from Environment Variables,
but ignores IReadOnlyDictionary GlobalLabels from a AbstractConfigurationReader.

Elastic.Apm.AspNetFullFramework 1.3.0 (net462)
Elastic.Apm.EntityFramework6 1.3.0 (net462)

1) Create a AbstractConfigurationReader and add a global label:
public IReadOnlyDictionary<string, string> GlobalLabels => new Dictionary<string, string>() { { "teams", "myTeamLabel" } };

2) Application_Start in Global.asax

var configReader = new ApmConfigurationReader(ApmLogger.Instance);
var c = new AgentComponents(logger: ApmLogger.Instance, configurationReader: configReader);
Agent.Setup(c);
DbInterception.Add(new Elastic.Apm.EntityFramework6.Ef6Interceptor());

3) Some Test Controller:

public class TestController : Controller
{
    // Works (the 'Elastic.Apm.AspNetFullFramework.ElasticApmModule' attaches for the WebRequest also the Global Labels)
        public ActionResult Index()
        {
        // Ef6 Interceptor Works => but Global Labels in Spans are not included (as long no environment variables are set)
        using (TestEntities db = new TestEntities())
            {
                    var count = db.Files.Count();                                   
                }

        // Test Transaction (sent to Server with Global Labels from Agent Setup - without having the ELASTIC_APM_GLOBAL_LABELS env set)
        var transaction = Agent.Tracer.StartTransaction("SomeSelfTriggeredTransaction", "custom");
        transaction.End();

        return Content(DateTime.Now.ToString());
    }
}

Expected behavior
All send out messages should have the Global_Label attached if configured in Agent Setup.

Environment Vars are bad for IIS and multi App infrastruture.
The EF Interceptor works on interal refs... or there any hidden ways to add my Global Labels with code?

Kind regards, Otto.

bug

All 3 comments

APM Agents just send global labels in "metadata" part of the events payload - APM Server is the one that actually adds those labels to events before ingesting into Elasticsearch. APM Server 7.6:

Adds support for global labels in spans

Environment Vars are bad for IIS and multi App infrastruture.
The EF Interceptor works on interal refs... or there any hidden ways to add my Global Labels with code?

In addition to environment variable you can use Web.config to configure global labels.

APM Agents just send global labels in "metadata" part of the events payload - APM Server is the one that actually adds those labels to events before ingesting into Elasticsearch. APM Server 7.6:

Adds support for global labels in spans

Hey Sergey thanks for the quick answer and the hints...

Actually the problem is we still using 7.4 - I've traced the payloads, and the metadata part contains correct the global labels with the Agent... The Span was on the server was mixed up with normal transaction where the label was applied.

I guess after the update, we are fine ;-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nilsgstrabo picture nilsgstrabo  路  5Comments

fredeil picture fredeil  路  3Comments

bliles picture bliles  路  7Comments

fernandolamp picture fernandolamp  路  7Comments

luisfernandomoraes picture luisfernandomoraes  路  7Comments