Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddLink to CurrentTransaction #2477

Open
javiaa opened this issue Nov 5, 2024 · 2 comments
Open

AddLink to CurrentTransaction #2477

javiaa opened this issue Nov 5, 2024 · 2 comments
Labels
community enhancement New feature or request

Comments

@javiaa
Copy link

javiaa commented Nov 5, 2024

Hi,

We would like to add an span link to the current transaction so the root span has a link to another transaction.
We have not find a good way of doing so.
We have seen that the CurrentTransaction has a inaccessible 'Links' property with a list of links.
In fact using reflection we have been able to add a link, but of course this is not a solution for production.

var links = Agent.Tracer.CurrentTransaction.GetType().GetProperty("Links");
links?.SetValue(Agent.Tracer.CurrentTransaction, new List<SpanLink>
  { new (parentContext.SpanId.ToString(), parentContext.TraceId.ToString()) });

For the moment we are relying on capturing a child span and we are adding the link there, but we would like to have an AddLink function on the CurrentTransaciton to be able to add the link from there.

Thanks!

@javiaa javiaa added the enhancement New feature or request label Nov 5, 2024
@stevejgordon
Copy link
Contributor

Hi, @javiaa. Thanks for the suggestion. We can review and discuss this within the APM Agent team. The current behaviour is based on the OTel spec when this feature was initially implemented. The OTel spec now supports adding links after creation; we may opt to align with that.

@javiaa
Copy link
Author

javiaa commented Nov 11, 2024

Perfect, thank you for looking into it @stevejgordon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants