question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding resource tags dinamically after initialization

See original GitHub issue

Question

First of all, congratulations on the awesome work!

On OpenTelemetry initialization we do something similar to the following:

var resource = Resources.CreateServiceResource(conf.ServiceName, serviceVersion: conf.ServiceVersion)
 .Merge(new Resource(new Dictionary<string, object>
 {
    {"deployment.environment", conf.DeploymentEnvironment},
    {"os.type", conf.OsType},
    {"os.description", conf.OsDescription},
    {"cloud.zone", conf.CloudZone},
    {"host.id", conf.HostID},
    {"host.name", conf.HostName},
    {"host.type", conf.HostType},
}));
builder.SetResource(resource);
...

However, to fetch host and cloud information we have to block the initialization process to make calls to AWS API. We would prefer not to block initialization because of this.

Is there a way to add tags to the resource after initialization? Do you guys think of an alternative solution?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
eddynakacommented, Nov 5, 2020

For the caching strategy, yes, that would help with the allocation since we would only need to allocate the new Resource once.

For the enrichment part, it will affect performance when you use Enrich.

I thought I did commit the benchmark for that. I will create a new PR adding it. But you can look here: https://github.com/open-telemetry/opentelemetry-dotnet/pull/1261#issuecomment-695062784

For the processor question, yes that should work as well.

1reaction
cijothomascommented, Nov 5, 2020

As per the current spec for Resource, resource is associated with a TracerProvider/MeterProvider, and is same for all the traces/metrics from that provider, and cannot be changed after provider creation. It is a bug that we allow overriding resource on a per span/activity level. This will very likely be fixed with one of the pending PRs. So do not count on this behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Initialize ResourceManager dynamically - asp.net
I have this function and it works fine to get a translated value from this specific resource file called OkayMessages. public static string ......
Read more >
settings custom resource tags · Issue #696 · aws/copilot-cli
You'll be able to specify tags while initializing a project so that all resources in your project will have these tags. $ ecs-preview...
Read more >
Grant permission to tag resources during creation
To enable users to tag resources on creation, they must have permissions to use the action that creates the resource, such as ec2:RunInstances...
Read more >
Configure default tags for AWS resources | Terraform
Configure the AWS Terraform provider to set default tags on resources. Override default tags on individual resources.
Read more >
Dynamic tags support based on resource annotation #2783
Currently I'm trying to use one provisioner that will provision nodes for all types of ML application, if an application using a specific...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found