nginxinc / nginx-otel

Apache License 2.0
168 stars 19 forks source link

Support arbitrary resource attributes #32

Closed bmerigan closed 1 week ago

bmerigan commented 9 months ago

Is your feature request related to a problem? Please describe

Currently the traces that are logged via this module don't have environment metadata which means I cannot filter traces by environment in Elastic APM. e.g. development/test/staging/production

This feature and why it's useful is explained perfectly in this opentelemetry doco

Describe the solution you'd like

Just like we can set otel_service_name as per nginx-otel doco
I'd like to be able to set the environment with a directive called otel_service_environment

Bonus if you include service.node.name and service.version too.

Describe alternatives you've considered

Adding the value using a resource processor within the otel-collector, which works, but isn't right IMO.

p-pautov commented 9 months ago

I think, we can add generic otel_resource block, which would allow setting any resource level attributes, e.g.

otel_resource {
    "deployment.environment" "prod";
    "service.node.name" "mysvc";
    "service.version" "1.0";
}
bmerigan commented 9 months ago

Yeah that would work well

sahilganguly commented 7 months ago

@bmerigan could you include these attributes using the otel_span_attr directive? Assuming of course you can get those attributes as a variable in nginx.

bmerigan commented 7 months ago

@bmerigan could you include these attributes using the otel_span_attr directive? Assuming of course you can get those attributes as a variable in nginx.

I do use the otel_span_attr for some things, but these attributes are more at the top, trace level.

oliveromahony commented 4 months ago

hi I think this request is necessary and will help in categorization of OTel data in the case of this module. The issue I foresee is that the proposal quoted only covers attribute tagging effectively:

I think, we can add generic otel_resource block, which would allow setting any resource level attributes, e.g.

otel_resource {
    "deployment.environment" "prod";
    "service.node.name" "mysvc";
    "service.version" "1.0";
}

e.g. if we have multiple OTel NGINX modules reporting to a single collector, the only distinction would be service.node.name. But how does this work if we syncronize configurations with https://docs.nginx.com/nginx/admin-guide/high-availability/configuration-sharing/ and https://docs.nginx.com/nginx-management-suite/nim/how-to/instances/manage-instance-groups/ where the configurations are duplicated and identical on each NGINX instance? In these cases the config would potentially replicate and have the same service.node.name?

p-pautov commented 4 months ago

I don't think, you have to have identical configs on each instance. Say, you can use instance specific file and include it into synced config. Another option is to use environment variables - #40.