apm-agent-dotnet
apm-agent-dotnet copied to clipboard
Transaction API - cannot set manual Transaction/Span Timestamp
I cannot set custom Transaction/Span Timestamp using the dotnet SDK. The Span Timestamp property is read-only and there's no Timestamp property on Transaction.
I saw that the Javascript SDK Transaction API supports setting custom Timestamp (https://www.elastic.co/guide/en/apm/agent/rum-js/current/transaction-api.html#transaction-timestamp). This feature is crucial to ingest and process back dated events to reflect the original timestamp of the old captured events correctly.
Any thoughts?
It wasn't part of the design to have back dated transactions, so unfortunately this won't work with the current state of the API.
We can discuss this for a later iteration.
One thing I can say is that there is an internal API which enables this and we use that for testing, but so far there were no plans to make it public.
Thank you for the prompt response.
Our scenario is that we didn't want to integrate APM instrumentation in each of our microservices. Instead we wanted to subscribe to an Audit queue, that has all the events ingested from our microservices, and generate instrumentation from the audit data. Audit messages have key instrumentation properties such as CorrelationId, Message Id, Conversation Id, Timestamp, duration etc. as we use NServiceBus for message processing.
So our requirement was not only to set custom Timestamp but to also be able to generate our own Transaction Ids and Span Ids to enable distributed tracing and be able to visualize our services in Service Map. Is it currently possible to generate our own Ids? What is your recommendation on how we can use Elastic APM for cases like these?
Thanks for elaborating @Nehmiabm,
well, that makes it a bit different. In this case making our internal API for accepting timestamps won't really help you I'm afraid. The agent has it's own id rules and we haven't really designed it for accepting ids as well.
What you describe sounds to me more like something where you already have the whole data model and you just want to push it to APM Server, right?
For that once option would be to go all in and send the data manually - the intake API of the APM Server is public - here is how it looks. That'd be a whole bunch of work, but so far I don't see any better option with the existing agent I'm afraid.
I use reflection for this purpose, since parts of the execution is taking place in shared thread and I want this information to be a part of the current transaction.
Once in the execution thread I start a transaction, set the timestamp and duration, before ending the transaction. That makes it show up perfectly in the UI as a part of a call distribution between several systems.
We use it both for queue time and for database executions using unsupported databases.
Would be much preferred to have the Timestamp setter exposed by the IExecutionSegment