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

Can I access extensions.http.routePrefix at runtime? #1366

Closed
martinjt opened this issue Feb 19, 2023 · 14 comments
Closed

Can I access extensions.http.routePrefix at runtime? #1366

martinjt opened this issue Feb 19, 2023 · 14 comments

Comments

@martinjt
Copy link

Is there anyway to access to the routePrefix set in host.json at the runtime?

{
    "version": "2.0",
    "extensions": {
      "http": {
        "routePrefix": ""
      }
    }
}

I'm trying to establish the actual route of a HttpTrigger function, which I can't do without the routePrefix as the method's route attribute doesn't include it.

@ghost ghost assigned kshyju Feb 19, 2023
@fabiocav
Copy link
Member

@martinjt this information is not made available to the worker today. The simplest way to get this information, today, would be to read the host.json file and get that information directly.

@fabiocav
Copy link
Member

fabiocav commented Feb 22, 2023

Another option is to define the route prefix as an app setting/environment variable (i.e., AzureFunctionsJobHost__extensions__http__routePrefix), and this would be automatically used by the host (no need to define that in host.json) and automatically added as a configuration value in the worker, accessible through IConfiguration

@lmolkova
Copy link
Member

I might miss some Functions context, but Isn't it something that ASP.NET Core instrumentation should populate along with http.route ?

@martinjt
Copy link
Author

This is specific to functions.

The wider host takes a config that will essentially add a base path to all routes. If you don't supply it, it adds /api/ to what the client would call.

http.route is what I want to populate with the route template from the function, so it get /company/{companyId:int}, and not /company/123 which is http.route vs http.url

When the function has been selected, we can get the attributes and find the route, but that doesn't take into account if someone has passed a routePrefix to the runtime.

@lmolkova
Copy link
Member

I believe with this recent change open-telemetry/opentelemetry-specification#3164 introduced in OTel HTTP spec http.route should have it captured.

Once Functions support OTel, I assume it should be possible to update http.route Activity tag to include the prefix.

@martinjt
Copy link
Author

This is purely "how do we get the prefix", the attribute is there, we can use it... but I can't get access to the prefix in order to add it to the attrivute.

@lmolkova
Copy link
Member

I mean functions can populate the attribute once they support OTel and adopt conventions, but today yes, no way.

@martinjt
Copy link
Author

To be clear, I'm not asking for it on an Activity. I'm asking where it exists so that the Runtime can have access to it outside the worker host.

@fabiocav
Copy link
Member

fabiocav commented Sep 6, 2023

Reviewing open items and this is still a gap.

@martinjt are the options I've shared above viable workarounds in the meantime?

@martinjt
Copy link
Author

martinjt commented Sep 6, 2023

I haven't looked at this recently, however, this wasn't viable at the time. I could look into why though.

@jviau
Copy link
Contributor

jviau commented Feb 7, 2024

@martinjt were you able to see if the proposed workarounds from @fabiocav work for you? Reading from host.json manually or using an appsetting.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

If you are not the original author (martinjt) and believe this issue is not stale, please comment with /bot not-stale and I will not close it.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

1 similar comment
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants