Describe the bug
The Ef6Interceptor send ELASTIC_APM_GLOBAL_LABELS from Environment Variables,
but ignores IReadOnlyDictionary
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.
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 ;-)